summaryrefslogtreecommitdiff
path: root/src/scheme
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-01-08 13:46:17 -0800
committerKeith Packard <keithp@keithp.com>2018-01-08 13:46:17 -0800
commit4b52fc6eea9a478cb3dd42dcd32c92838df39734 (patch)
tree28c5594e42896b7a191539b7c21563e92f73e1da /src/scheme
parentf8a967959b2f5ca3486ab3422f30fe4ad4ba17a8 (diff)
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 <keithp@keithp.com>
Diffstat (limited to 'src/scheme')
-rw-r--r--src/scheme/ao_scheme_read.c5
-rw-r--r--src/scheme/ao_scheme_string.c6
2 files changed, 7 insertions, 4 deletions
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;