diff --git a/include/chibi/features.h b/include/chibi/features.h index 2a07711f..174f0b98 100644 --- a/include/chibi/features.h +++ b/include/chibi/features.h @@ -534,6 +534,10 @@ #define SEXP_MAX_STACK_SIZE SEXP_INIT_STACK_SIZE*1000 #endif +#ifndef SEXP_DEFAULT_EQUAL_BOUND +#define SEXP_DEFAULT_EQUAL_BOUND 100000 +#endif + #ifndef SEXP_USE_IMAGE_LOADING #define SEXP_USE_IMAGE_LOADING SEXP_USE_DL && !SEXP_USE_GLOBAL_HEAP && !SEXP_USE_BOEHM && !SEXP_USE_NO_FEATURES #endif diff --git a/sexp.c b/sexp.c index 7cb818d2..09dd7bb2 100644 --- a/sexp.c +++ b/sexp.c @@ -747,7 +747,7 @@ sexp sexp_equalp_bound (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b, sexp loop: if (a == b) return bound; - else if ((! sexp_pointerp(a)) || (! sexp_pointerp(b)) + else if ((!a || !sexp_pointerp(a)) || (!b || !sexp_pointerp(b)) || (sexp_pointer_tag(a) != sexp_pointer_tag(b))) return SEXP_FALSE; @@ -760,7 +760,7 @@ sexp sexp_equalp_bound (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b, sexp if (sexp_pointer_tag(a) == SEXP_FLONUM) return (sexp_flonum_value(a) == sexp_flonum_value(b)) ? bound : SEXP_FALSE; #endif - if (sexp_unbox_fixnum(bound) < 0) + if (sexp_unbox_fixnum(bound) < 0) /* exceeded limit */ return bound; bound = sexp_fx_sub(bound, SEXP_ONE); t = sexp_object_type(ctx, a); @@ -785,6 +785,15 @@ sexp sexp_equalp_bound (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b, sexp /* check eq-object slots */ len = sexp_type_num_eq_slots_of_object(t, a); if (len > 0) { + for (; len > 1; len--) { + a = p[len-1]; b = q[len-1]; + if (a != b) { + if ((!a || !sexp_pointerp(a)) || (!b || !sexp_pointerp(b)) + || (sexp_pointer_tag(a) != sexp_pointer_tag(b))) + return SEXP_FALSE; + else break; + } + } for (i=0; i