mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-15 00:47:34 +02:00
Allowing arbitrary length #\xNNNN char literals.
This commit is contained in:
parent
8d5ea4cdf4
commit
dc70094472
1 changed files with 33 additions and 28 deletions
15
sexp.c
15
sexp.c
|
@ -2683,6 +2683,15 @@ sexp sexp_read_raw (sexp ctx, sexp in) {
|
|||
goto scan_loop;
|
||||
case '\\':
|
||||
c1 = sexp_read_char(ctx, in);
|
||||
c2 = sexp_read_char(ctx, in);
|
||||
sexp_push_char(ctx, c2, in);
|
||||
if ((c1 == 'x' || c1 == 'X') && (sexp_isxdigit(c2))) {
|
||||
res = sexp_read_number(ctx, in, 16);
|
||||
if (sexp_fixnump(res) && sexp_unbox_fixnum(res) >= 0 && sexp_unbox_fixnum(res) <= 0x10FFFF)
|
||||
res = sexp_make_character(sexp_unbox_fixnum(res));
|
||||
else if (!sexp_exceptionp(res))
|
||||
res = sexp_read_error(ctx, "bad character #\\x literal", res, in);
|
||||
} else {
|
||||
res = sexp_read_symbol(ctx, in, c1, 0);
|
||||
if (sexp_stringp(res)) {
|
||||
str = sexp_string_data(res);
|
||||
|
@ -2692,11 +2701,6 @@ sexp sexp_read_raw (sexp ctx, sexp in) {
|
|||
SEXP_NULL, in);
|
||||
if (sexp_string_length(res) == 1) {
|
||||
res = sexp_make_character(c1);
|
||||
} else if ((c1 == 'x' || c1 == 'X') &&
|
||||
sexp_isxdigit((unsigned char)(str[1]))
|
||||
&& sexp_isxdigit((unsigned char)(str[2])) && str[3] == '\0') {
|
||||
res = sexp_make_character(16 * digit_value(str[1])
|
||||
+ digit_value(str[2]));
|
||||
} else {
|
||||
res = 0;
|
||||
for (c2=0; c2 < sexp_num_char_names; c2++) {
|
||||
|
@ -2717,6 +2721,7 @@ sexp sexp_read_raw (sexp ctx, sexp in) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '(':
|
||||
sexp_push_char(ctx, c1, in);
|
||||
|
|
Loading…
Add table
Reference in a new issue