mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 09:17:35 +02:00
Handle the null character
This commit is contained in:
parent
40b729e11b
commit
a492ca379d
2 changed files with 24 additions and 8 deletions
24
runtime.c
24
runtime.c
|
@ -1860,8 +1860,12 @@ 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);
|
||||||
}
|
}
|
||||||
Cyc_utf8_encode_char(cbuf, 5, ch);
|
if (!ch) {
|
||||||
len += strlen(cbuf);
|
len++;
|
||||||
|
} else {
|
||||||
|
Cyc_utf8_encode_char(cbuf, 5, ch);
|
||||||
|
len += strlen(cbuf);
|
||||||
|
}
|
||||||
tmp = cdr(tmp);
|
tmp = cdr(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1871,8 +1875,12 @@ 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
|
||||||
Cyc_utf8_encode_char(&(buf[i]), 5, ch);
|
if (!ch) {
|
||||||
i += strlen(buf+i);
|
i++;
|
||||||
|
} else {
|
||||||
|
Cyc_utf8_encode_char(&(buf[i]), 5, ch);
|
||||||
|
i += strlen(buf+i);
|
||||||
|
}
|
||||||
lst = cdr(lst);
|
lst = cdr(lst);
|
||||||
}
|
}
|
||||||
buf[i] = '\0';
|
buf[i] = '\0';
|
||||||
|
@ -2130,8 +2138,12 @@ object Cyc_string_set(void *data, object str, object k, object chr)
|
||||||
}
|
}
|
||||||
|
|
||||||
input_char = obj_obj2char(chr);
|
input_char = obj_obj2char(chr);
|
||||||
Cyc_utf8_encode_char(buf, 5, input_char);
|
if (!input_char) {
|
||||||
buf_len = strlen(buf);
|
buf_len = 1;
|
||||||
|
} else {
|
||||||
|
Cyc_utf8_encode_char(buf, 5, input_char);
|
||||||
|
buf_len = strlen(buf);
|
||||||
|
}
|
||||||
|
|
||||||
raw = string_str(str);
|
raw = string_str(str);
|
||||||
idx = unbox_number(k);
|
idx = unbox_number(k);
|
||||||
|
|
|
@ -958,8 +958,12 @@
|
||||||
Cyc_rt_raise2(data, \"Expected character buf received\", fill);
|
Cyc_rt_raise2(data, \"Expected character buf received\", fill);
|
||||||
}
|
}
|
||||||
c = obj_obj2char(fill);
|
c = obj_obj2char(fill);
|
||||||
Cyc_utf8_encode_char(ch_buf, 5, c);
|
if (!c) {
|
||||||
buflen = strlen(ch_buf);
|
buflen = 1;
|
||||||
|
} else {
|
||||||
|
Cyc_utf8_encode_char(ch_buf, 5, c);
|
||||||
|
buflen = strlen(ch_buf);
|
||||||
|
}
|
||||||
num_cp = obj_obj2int(count);
|
num_cp = obj_obj2int(count);
|
||||||
len = num_cp * buflen;
|
len = num_cp * buflen;
|
||||||
if (len >= MAX_STACK_OBJ) {
|
if (len >= MAX_STACK_OBJ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue