mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-07 13:16:36 +02:00
Tweaks for leading chars in string->number.
This commit is contained in:
parent
f9686315d9
commit
44fa0dd2c0
1 changed files with 5 additions and 0 deletions
5
sexp.c
5
sexp.c
|
@ -2377,8 +2377,13 @@ sexp sexp_string_to_number_op (sexp ctx sexp_api_params(self, n), sexp str, sexp
|
||||||
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, b);
|
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, b);
|
||||||
if (((base=sexp_unbox_fixnum(b)) < 2) || (base > 36))
|
if (((base=sexp_unbox_fixnum(b)) < 2) || (base > 36))
|
||||||
return sexp_user_exception(ctx, self, "invalid numeric base", b);
|
return sexp_user_exception(ctx, self, "invalid numeric base", b);
|
||||||
|
if (sexp_string_data(str)[0] == '\0'
|
||||||
|
|| (sexp_string_data(str)[0] == '.' && sexp_string_data(str)[1] == '\0'))
|
||||||
|
return SEXP_FALSE;
|
||||||
sexp_gc_preserve1(ctx, in);
|
sexp_gc_preserve1(ctx, in);
|
||||||
in = sexp_make_input_string_port(ctx, str);
|
in = sexp_make_input_string_port(ctx, str);
|
||||||
|
if (sexp_string_data(str)[0] == '+')
|
||||||
|
sexp_read_char(ctx, in);
|
||||||
in = ((sexp_string_data(str)[0] == '#') ?
|
in = ((sexp_string_data(str)[0] == '#') ?
|
||||||
sexp_read(ctx, in) : sexp_read_number(ctx, in, base));
|
sexp_read(ctx, in) : sexp_read_number(ctx, in, base));
|
||||||
sexp_gc_release1(ctx);
|
sexp_gc_release1(ctx);
|
||||||
|
|
Loading…
Add table
Reference in a new issue