mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 14:19:18 +02:00
making inf/nan reading case-insensitive.
adding complex and ratios to definition of sexp_numberp.
This commit is contained in:
parent
5d92523bf4
commit
4e60bba376
2 changed files with 24 additions and 9 deletions
|
@ -656,10 +656,20 @@ SEXP_API sexp sexp_make_unsigned_integer(sexp ctx, sexp_luint_t x);
|
||||||
|
|
||||||
#if SEXP_USE_FLONUMS
|
#if SEXP_USE_FLONUMS
|
||||||
#define sexp_fixnum_to_flonum(ctx, x) (sexp_make_flonum(ctx, sexp_unbox_fixnum(x)))
|
#define sexp_fixnum_to_flonum(ctx, x) (sexp_make_flonum(ctx, sexp_unbox_fixnum(x)))
|
||||||
#define sexp_numberp(x) (sexp_exact_integerp(x) || sexp_flonump(x))
|
#if SEXP_USE_RATIOS
|
||||||
|
#define sexp_realp(x) (sexp_exact_integerp(x) || sexp_flonump(x))
|
||||||
|
#else
|
||||||
|
#define sexp_realp(x) (sexp_exact_integerp(x) || sexp_flonump(x) || sexp_ratiop(x))
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define sexp_fixnum_to_flonum(ctx, x) (x)
|
#define sexp_fixnum_to_flonum(ctx, x) (x)
|
||||||
#define sexp_numberp(x) sexp_exact_integerp(x)
|
#define sexp_realp(x) sexp_exact_integerp(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SEXP_USE_COMPLEX
|
||||||
|
#define sexp_numberp(x) (sexp_realp(x) || sexp_complexp(x))
|
||||||
|
#else
|
||||||
|
#define sexp_numberp(x) (sexp_realp(x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define sexp_exact_negativep(x) (sexp_fixnump(x) ? (sexp_unbox_fixnum(x) < 0) \
|
#define sexp_exact_negativep(x) (sexp_fixnump(x) ? (sexp_unbox_fixnum(x) < 0) \
|
||||||
|
|
13
sexp.c
13
sexp.c
|
@ -2305,14 +2305,19 @@ sexp sexp_read_raw (sexp ctx, sexp in) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sexp_push_char(ctx, c2, in);
|
sexp_push_char(ctx, c2, in);
|
||||||
res = sexp_read_symbol(ctx, in, c1, 1);
|
res = sexp_read_symbol(ctx, in, c1, 0);
|
||||||
#if SEXP_USE_INFINITIES
|
#if SEXP_USE_INFINITIES
|
||||||
if (res == sexp_intern(ctx, "+inf.0", -1))
|
if (sexp_stringp(res)) {
|
||||||
|
str = sexp_string_data(res);
|
||||||
|
if (strcasecmp(str, "+inf.0") == 0)
|
||||||
res = sexp_make_flonum(ctx, sexp_pos_infinity);
|
res = sexp_make_flonum(ctx, sexp_pos_infinity);
|
||||||
else if (res == sexp_intern(ctx, "-inf.0", -1))
|
else if (strcasecmp(str, "-inf.0") == 0)
|
||||||
res = sexp_make_flonum(ctx, sexp_neg_infinity);
|
res = sexp_make_flonum(ctx, sexp_neg_infinity);
|
||||||
else if (res == sexp_intern(ctx, "+nan.0", -1))
|
else if (strcasecmp(str, "+nan.0") == 0)
|
||||||
res = sexp_make_flonum(ctx, sexp_nan);
|
res = sexp_make_flonum(ctx, sexp_nan);
|
||||||
|
else
|
||||||
|
res = sexp_intern(ctx, str, sexp_string_length(res));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if SEXP_USE_COMPLEX
|
#if SEXP_USE_COMPLEX
|
||||||
if (res == sexp_intern(ctx, "+i", -1))
|
if (res == sexp_intern(ctx, "+i", -1))
|
||||||
|
|
Loading…
Add table
Reference in a new issue