don't push back final char when reading a bignum-sized float (issue 32, part 2)

This commit is contained in:
Alex Shinn 2010-02-06 21:33:45 +09:00
parent 4dcfb8aa6b
commit efb6f24a61

View file

@ -223,17 +223,18 @@ sexp sexp_read_bignum (sexp ctx, sexp in, sexp_uint_t init,
res = sexp_bignum_fxadd(ctx, res, digit); res = sexp_bignum_fxadd(ctx, res, digit);
} }
if (c=='.' || c=='e' || c=='E') { if (c=='.' || c=='e' || c=='E') {
if (base != 10) if (base != 10) {
res = sexp_read_error(ctx, "found non-base 10 float", SEXP_NULL, in); res = sexp_read_error(ctx, "found non-base 10 float", SEXP_NULL, in);
else { } else {
if (c!='.') sexp_push_char(ctx, c, in); /* push the e back */ if (c!='.') sexp_push_char(ctx, c, in); /* push the e back */
res = sexp_read_float_tail(ctx, in, sexp_bignum_to_double(res), (sign==-1)); res = sexp_read_float_tail(ctx, in, sexp_bignum_to_double(res), (sign==-1));
} }
} else if ((c!=EOF) && ! is_separator(c)) { } else if ((c!=EOF) && ! is_separator(c)) {
res = sexp_read_error(ctx, "invalid numeric syntax", res = sexp_read_error(ctx, "invalid numeric syntax",
sexp_make_character(c), in); sexp_make_character(c), in);
} } else {
sexp_push_char(ctx, c, in); sexp_push_char(ctx, c, in);
}
sexp_gc_release1(ctx); sexp_gc_release1(ctx);
return sexp_bignum_normalize(res); return sexp_bignum_normalize(res);
} }