mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-09 22:17:34 +02:00
Fix for additional edge cases in escaping symbols on output.
This commit is contained in:
parent
55257b75e3
commit
fec1016254
2 changed files with 11 additions and 5 deletions
12
sexp.c
12
sexp.c
|
@ -1192,7 +1192,7 @@ sexp sexp_intern(sexp ctx, const char *str, sexp_sint_t len) {
|
||||||
res = 0;
|
res = 0;
|
||||||
space = 3;
|
space = 3;
|
||||||
if (len == 0 || sexp_isdigit(p[0])
|
if (len == 0 || sexp_isdigit(p[0])
|
||||||
|| ((p[0] == '+' || p[0] == '-') && len > 1 && sexp_isdigit(p[1])))
|
|| ((p[0] == '+' || p[0] == '-') && len > 1))
|
||||||
goto normal_intern;
|
goto normal_intern;
|
||||||
for ( ; i<len; i++, p++) {
|
for ( ; i<len; i++, p++) {
|
||||||
c = *p;
|
c = *p;
|
||||||
|
@ -1920,10 +1920,12 @@ sexp sexp_write_one (sexp ctx, sexp obj, sexp out) {
|
||||||
(sexp_lsymbol_length(obj) == 1 && str[0] == '.') ||
|
(sexp_lsymbol_length(obj) == 1 && str[0] == '.') ||
|
||||||
sexp_isdigit(str[0]) ||
|
sexp_isdigit(str[0]) ||
|
||||||
(sexp_lsymbol_length(obj) > 1 &&
|
(sexp_lsymbol_length(obj) > 1 &&
|
||||||
(((str[0] == '+' || str[0] == '-')
|
((str[0] == '+' || str[0] == '-')
|
||||||
&& (sexp_isdigit(str[1]) || str[1] == '.')) ||
|
&& (sexp_isdigit(str[1]) || str[1] == '.' || str[1] == 'i' ||
|
||||||
(str[sexp_lsymbol_length(obj)-1] == '0' &&
|
((sexp_lsymbol_length(obj) > 3) &&
|
||||||
str[sexp_lsymbol_length(obj)-2] == '.'))))
|
sexp_tolower(str[1]) == 'n' &&
|
||||||
|
sexp_tolower(str[2]) == 'a' &&
|
||||||
|
sexp_tolower(str[3]) == 'n')))))
|
||||||
? '|' : EOF;
|
? '|' : EOF;
|
||||||
for (i=sexp_lsymbol_length(obj)-1; i>=0; i--)
|
for (i=sexp_lsymbol_length(obj)-1; i>=0; i--)
|
||||||
if (str[i] <= ' ' || str[i] == '\\' || sexp_is_separator(str[i]))
|
if (str[i] <= ' ' || str[i] == '\\' || sexp_is_separator(str[i]))
|
||||||
|
|
|
@ -2107,9 +2107,13 @@
|
||||||
(test-write-syntax "|2|" '|2|)
|
(test-write-syntax "|2|" '|2|)
|
||||||
(test-write-syntax "|+3|" '|+3|)
|
(test-write-syntax "|+3|" '|+3|)
|
||||||
(test-write-syntax "|-.4|" '|-.4|)
|
(test-write-syntax "|-.4|" '|-.4|)
|
||||||
|
(test-write-syntax "|+i|" '|+i|)
|
||||||
|
(test-write-syntax "|-i|" '|-i|)
|
||||||
(test-write-syntax "|+inf.0|" '|+inf.0|)
|
(test-write-syntax "|+inf.0|" '|+inf.0|)
|
||||||
(test-write-syntax "|-inf.0|" '|-inf.0|)
|
(test-write-syntax "|-inf.0|" '|-inf.0|)
|
||||||
(test-write-syntax "|+nan.0|" '|+nan.0|)
|
(test-write-syntax "|+nan.0|" '|+nan.0|)
|
||||||
|
(test-write-syntax "|+NaN.0|" '|+NaN.0|)
|
||||||
|
(test-write-syntax "|+NaN.0abc|" '|+NaN.0abc|)
|
||||||
|
|
||||||
(test-end)
|
(test-end)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue