mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-25 04:55:04 +02:00
WIP
This commit is contained in:
parent
118822f353
commit
a38295b22b
2 changed files with 7 additions and 7 deletions
|
@ -776,7 +776,7 @@ typedef struct {
|
||||||
cs.hdr.mark = gc_color_red; \
|
cs.hdr.mark = gc_color_red; \
|
||||||
cs.hdr.grayed = 0; \
|
cs.hdr.grayed = 0; \
|
||||||
cs.tag = string_tag; \
|
cs.tag = string_tag; \
|
||||||
cs.num_cp = Cyc_utf8_count_code_points(s); \
|
cs.num_cp = Cyc_utf8_count_code_points((uint8_t *)s); \
|
||||||
if (cs.num_cp < 0) { \
|
if (cs.num_cp < 0) { \
|
||||||
Cyc_rt_raise_msg(data, "Invalid UTF-8 characters in string"); \
|
Cyc_rt_raise_msg(data, "Invalid UTF-8 characters in string"); \
|
||||||
} \
|
} \
|
||||||
|
|
12
runtime.c
12
runtime.c
|
@ -2143,7 +2143,7 @@ fprintf(stderr, "DEBUG %s, num_cp = %d, len = %d\n", raw, string_num_cp(str), le
|
||||||
int i = 0, count, start_len = 0, start_cp = 0;
|
int i = 0, count, start_len = 0, start_cp = 0;
|
||||||
|
|
||||||
for (count = 0; *tmp; ++tmp){
|
for (count = 0; *tmp; ++tmp){
|
||||||
if (!Cyc_utf8_decode(&state, &codepoint, *tmp)){
|
if (!Cyc_utf8_decode(&state, &codepoint, (uint8_t)*tmp)){
|
||||||
if (count < idx) {
|
if (count < idx) {
|
||||||
start_len = i;
|
start_len = i;
|
||||||
start_cp = count;
|
start_cp = count;
|
||||||
|
@ -2193,7 +2193,7 @@ object Cyc_string_ref(void *data, object str, object k)
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
for (count = 0; *raw; ++raw){
|
for (count = 0; *raw; ++raw){
|
||||||
if (!Cyc_utf8_decode(&state, &codepoint, *raw)){
|
if (!Cyc_utf8_decode(&state, &codepoint, (uint8_t)*raw)){
|
||||||
if (count == idx) break; // Reached requested index
|
if (count == idx) break; // Reached requested index
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
|
@ -2241,7 +2241,7 @@ object Cyc_substring(void *data, object cont, object str, object start,
|
||||||
int count, start_i = 0, end_i = 0;
|
int count, start_i = 0, end_i = 0;
|
||||||
|
|
||||||
for (count = 0; *tmp; ++tmp){
|
for (count = 0; *tmp; ++tmp){
|
||||||
if (!Cyc_utf8_decode(&state, &codepoint, *tmp)){
|
if (!Cyc_utf8_decode(&state, &codepoint, (uint8_t)*tmp)){
|
||||||
if (count == s) {
|
if (count == s) {
|
||||||
start_i = end_i;
|
start_i = end_i;
|
||||||
} else if (count == e) {
|
} else if (count == e) {
|
||||||
|
@ -2637,7 +2637,7 @@ object Cyc_string2utf8(void *data, object cont, object str, object start,
|
||||||
char_type codepoint;
|
char_type codepoint;
|
||||||
uint32_t state = 0;
|
uint32_t state = 0;
|
||||||
for (i = 0; *tmp; ++tmp) {
|
for (i = 0; *tmp; ++tmp) {
|
||||||
if (!Cyc_utf8_decode(&state, &codepoint, *tmp)){
|
if (!Cyc_utf8_decode(&state, &codepoint, (uint8_t)*tmp)){
|
||||||
if (i == s) {
|
if (i == s) {
|
||||||
start_i = i;
|
start_i = i;
|
||||||
} else if (i == e) {
|
} else if (i == e) {
|
||||||
|
@ -6023,8 +6023,8 @@ void _read_string(void *data, object cont, port_type *p)
|
||||||
{
|
{
|
||||||
// TODO: need to change this below, but run into trouble in icyc, eg:
|
// TODO: need to change this below, but run into trouble in icyc, eg:
|
||||||
// (string-ref "ab\x3bb;" 2) crashes
|
// (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);
|
make_utf8_string(data, str, p->tok_buf);
|
||||||
return_thread_runnable(data, &str);
|
return_thread_runnable(data, &str);
|
||||||
}
|
}
|
||||||
} else if (c == '\\') {
|
} else if (c == '\\') {
|
||||||
|
|
Loading…
Add table
Reference in a new issue