This commit is contained in:
Justin Ethier 2017-10-30 16:57:39 +00:00
parent 7f8cc02c50
commit 118822f353
2 changed files with 14 additions and 2 deletions

View file

@ -6001,8 +6001,15 @@ void _read_string(void *data, object cont, port_type *p)
} }
buf[i] = '\0'; buf[i] = '\0';
{ {
int result = (int)strtol(buf, NULL, 16); char_type result = strtol(buf, NULL, 16);
p->tok_buf[p->tok_end++] = (char)result; char cbuf[5];
int i;
Cyc_utf8_encode_char(cbuf, 5, result);
// TODO: infinite loop here or above if ; is not provided???
for (i = 0; cbuf[i] != 0; i++) {
_read_add_to_tok_buf(p, cbuf[i]);
}
//p->tok_buf[p->tok_end++] = (char)result;
} }
break; break;
} }
@ -6014,7 +6021,10 @@ void _read_string(void *data, object cont, port_type *p)
p->tok_buf[p->tok_end] = '\0'; // TODO: what if buffer is full? p->tok_buf[p->tok_end] = '\0'; // TODO: what if buffer is full?
p->tok_end = 0; // Reset for next atom p->tok_end = 0; // Reset for next atom
{ {
// TODO: need to change this below, but run into trouble in icyc, eg:
// (string-ref "ab\x3bb;" 2) crashes
make_string(str, p->tok_buf); make_string(str, p->tok_buf);
//make_utf8_string(data, str, p->tok_buf);
return_thread_runnable(data, &str); return_thread_runnable(data, &str);
} }
} else if (c == '\\') { } else if (c == '\\') {

2
test.c
View file

@ -155,5 +155,7 @@ void main(){
encode(0x3bb); encode(0x3bb);
encode(65); encode(65);
encode(0xcebb); encode(0xcebb);
printf("%06X\n", 0x0fff);
return; return;
} }