From: Keith Packard Date: Mon, 8 Jan 2018 21:46:17 +0000 (-0800) Subject: altos/scheme: Allow unicode in lexer X-Git-Tag: 1.8.5~1^2~2^2~4 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=4b52fc6eea9a478cb3dd42dcd32c92838df39734;hp=f8a967959b2f5ca3486ab3422f30fe4ad4ba17a8;p=fw%2Faltos altos/scheme: Allow unicode in lexer This just passes any bytes with the high bit set through the system so programs can include UTF-8 in strings and symbols. What the heck. Signed-off-by: Keith Packard --- diff --git a/src/scheme/ao_scheme_read.c b/src/scheme/ao_scheme_read.c index f9630d39..3575ff3f 100644 --- a/src/scheme/ao_scheme_read.c +++ b/src/scheme/ao_scheme_read.c @@ -186,8 +186,9 @@ lexc(FILE *in) c = 0; lex_class = ENDOFFILE; } else { - c &= 0x7f; - lex_class = lex_classes[c]; + lex_class = PRINTABLE; + if (c <= 0x7f) + lex_class = lex_classes[c]; } } while (lex_class & IGNORE); return c; diff --git a/src/scheme/ao_scheme_string.c b/src/scheme/ao_scheme_string.c index c49e1e32..2c6d0960 100644 --- a/src/scheme/ao_scheme_string.c +++ b/src/scheme/ao_scheme_string.c @@ -47,6 +47,8 @@ ao_scheme_string_alloc(int len) { struct ao_scheme_string *s; + if (len < 0) + return NULL; s = ao_scheme_alloc(len + 2); if (!s) return NULL; @@ -182,8 +184,8 @@ ao_scheme_string_write(FILE *out, ao_poly p, bool write) fputs("\\\\", out); break; default: - if (c < ' ') - fprintf(out, "\\%03o", c); + if ((uint8_t) c < ' ') + fprintf(out, "\\%03o", (uint8_t) c); else putc(c, out); break;