mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 00:37:35 +02:00
Bugfix: Cyc_utf8_encode returns char count, not bytes
This commit is contained in:
parent
734a6e1911
commit
3aa2a159b7
1 changed files with 5 additions and 2 deletions
|
@ -1860,7 +1860,8 @@ object Cyc_list2string(void *data, object cont, object lst)
|
||||||
if (!obj_is_char(cbox)) {
|
if (!obj_is_char(cbox)) {
|
||||||
Cyc_rt_raise2(data, "Expected character but received", cbox);
|
Cyc_rt_raise2(data, "Expected character but received", cbox);
|
||||||
}
|
}
|
||||||
len += Cyc_utf8_encode_char(cbuf, 5, ch);
|
Cyc_utf8_encode_char(cbuf, 5, ch);
|
||||||
|
len += strlen(cbuf);
|
||||||
tmp = cdr(tmp);
|
tmp = cdr(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1870,7 +1871,8 @@ object Cyc_list2string(void *data, object cont, object lst)
|
||||||
while ((lst != NULL)) {
|
while ((lst != NULL)) {
|
||||||
cbox = car(lst);
|
cbox = car(lst);
|
||||||
ch = obj_obj2char(cbox); // Already validated, can assume chars now
|
ch = obj_obj2char(cbox); // Already validated, can assume chars now
|
||||||
i += Cyc_utf8_encode_char(&(buf[i]), 5, ch);
|
Cyc_utf8_encode_char(&(buf[i]), 5, ch);
|
||||||
|
i += strlen(buf+i);
|
||||||
lst = cdr(lst);
|
lst = cdr(lst);
|
||||||
}
|
}
|
||||||
buf[i] = '\0';
|
buf[i] = '\0';
|
||||||
|
@ -6013,6 +6015,7 @@ void _read_string(void *data, object cont, port_type *p)
|
||||||
int i;
|
int i;
|
||||||
Cyc_utf8_encode_char(cbuf, 5, result);
|
Cyc_utf8_encode_char(cbuf, 5, result);
|
||||||
// TODO: infinite loop here or above if ; is not provided???
|
// TODO: infinite loop here or above if ; is not provided???
|
||||||
|
// only because it is still waiting for the ; after it reads the closing quote
|
||||||
for (i = 0; cbuf[i] != 0; i++) {
|
for (i = 0; cbuf[i] != 0; i++) {
|
||||||
_read_add_to_tok_buf(p, cbuf[i]);
|
_read_add_to_tok_buf(p, cbuf[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue