reducing default limit for sexp_equalp_bound

This commit is contained in:
Alex Shinn 2011-11-11 22:52:39 +09:00
parent 04a330c43b
commit 846b9a1e40
2 changed files with 16 additions and 3 deletions

View file

@ -534,6 +534,10 @@
#define SEXP_MAX_STACK_SIZE SEXP_INIT_STACK_SIZE*1000 #define SEXP_MAX_STACK_SIZE SEXP_INIT_STACK_SIZE*1000
#endif #endif
#ifndef SEXP_DEFAULT_EQUAL_BOUND
#define SEXP_DEFAULT_EQUAL_BOUND 100000
#endif
#ifndef SEXP_USE_IMAGE_LOADING #ifndef SEXP_USE_IMAGE_LOADING
#define SEXP_USE_IMAGE_LOADING SEXP_USE_DL && !SEXP_USE_GLOBAL_HEAP && !SEXP_USE_BOEHM && !SEXP_USE_NO_FEATURES #define SEXP_USE_IMAGE_LOADING SEXP_USE_DL && !SEXP_USE_GLOBAL_HEAP && !SEXP_USE_BOEHM && !SEXP_USE_NO_FEATURES
#endif #endif

15
sexp.c
View file

@ -747,7 +747,7 @@ sexp sexp_equalp_bound (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b, sexp
loop: loop:
if (a == b) if (a == b)
return bound; 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))) || (sexp_pointer_tag(a) != sexp_pointer_tag(b)))
return SEXP_FALSE; 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) if (sexp_pointer_tag(a) == SEXP_FLONUM)
return (sexp_flonum_value(a) == sexp_flonum_value(b)) ? bound : SEXP_FALSE; return (sexp_flonum_value(a) == sexp_flonum_value(b)) ? bound : SEXP_FALSE;
#endif #endif
if (sexp_unbox_fixnum(bound) < 0) if (sexp_unbox_fixnum(bound) < 0) /* exceeded limit */
return bound; return bound;
bound = sexp_fx_sub(bound, SEXP_ONE); bound = sexp_fx_sub(bound, SEXP_ONE);
t = sexp_object_type(ctx, a); 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 */ /* check eq-object slots */
len = sexp_type_num_eq_slots_of_object(t, a); len = sexp_type_num_eq_slots_of_object(t, a);
if (len > 0) { 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<len-1; i++) { for (i=0; i<len-1; i++) {
bound = sexp_equalp_bound(ctx, self, n, p[i], q[i], bound); bound = sexp_equalp_bound(ctx, self, n, p[i], q[i], bound);
if (sexp_not(bound)) return SEXP_FALSE; if (sexp_not(bound)) return SEXP_FALSE;
@ -798,7 +807,7 @@ sexp sexp_equalp_bound (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b, sexp
sexp sexp_equalp_op (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b) { sexp sexp_equalp_op (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b) {
return sexp_make_boolean( return sexp_make_boolean(
sexp_truep(sexp_equalp_bound(ctx, self, n, a, b, sexp_truep(sexp_equalp_bound(ctx, self, n, a, b,
sexp_make_fixnum(SEXP_MAX_FIXNUM)))); sexp_make_fixnum(SEXP_DEFAULT_EQUAL_BOUND))));
} }
/********************* strings, symbols, vectors **********************/ /********************* strings, symbols, vectors **********************/