mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-12 23:37:38 +02:00
Fixes for make-string
This commit is contained in:
parent
0bd0eeb7a6
commit
703f863e48
2 changed files with 12 additions and 10 deletions
|
@ -722,6 +722,7 @@ void Cyc_set_globals_changed(gc_thread_data *thd);
|
|||
#define Cyc_utf8_encode_char(dest, dest_size, char_value) \
|
||||
Cyc_utf8_encode(dest, dest_size, &char_value, 1)
|
||||
|
||||
int Cyc_utf8_encode(char *dest, int sz, uint32_t *src, int srcsz);
|
||||
uint32_t Cyc_utf8_decode(uint32_t* state, uint32_t* codep, uint32_t byte);
|
||||
int Cyc_utf8_count_code_points(uint8_t* s);
|
||||
uint32_t Cyc_utf8_validate_stream(uint32_t *state, char *str, size_t len);
|
||||
|
|
|
@ -953,9 +953,9 @@
|
|||
char ch_buf[5];
|
||||
Cyc_check_int(data, count);
|
||||
char_type c = obj_obj2char(fill);
|
||||
Cyc_utf8_encode_char(ch_buf, 5, &c);
|
||||
Cyc_utf8_encode_char(ch_buf, 5, c);
|
||||
int num_cp = obj_obj2int(count);
|
||||
TODO: read encoded ch_buf int len = num_cp * uint32_num_bytes(c);
|
||||
int len = num_cp * strlen(ch_buf);
|
||||
if (len >= MAX_STACK_OBJ) {
|
||||
int heap_grown;
|
||||
s = gc_alloc(((gc_thread_data *)data)->heap,
|
||||
|
@ -978,14 +978,15 @@ TODO: read encoded ch_buf int len = num_cp * uint32_num_bytes(c);
|
|||
((string_type *)s)->num_cp = num_cp;
|
||||
((string_type *)s)->str = alloca(sizeof(char) * (len + 1));
|
||||
}
|
||||
//if (num_cp == 1) { /* Fast path */
|
||||
memset(((string_type *)s)->str, c, len);
|
||||
//} else {
|
||||
// int i;
|
||||
// uint32_t*
|
||||
// for (i = 0; i < len; i++) {
|
||||
// }
|
||||
//}
|
||||
if (0 && num_cp == 1) { /* Fast path */
|
||||
memset(((string_type *)s)->str, ch_buf[0], len);
|
||||
} else {
|
||||
char *buf = ((string_type *)s)->str;
|
||||
int bi, si, slen = strlen(ch_buf);
|
||||
for (bi = 0, si = 0; bi < len; bi++, si++) {
|
||||
buf[bi] = ch_buf[si % slen];
|
||||
}
|
||||
}
|
||||
((string_type *)s)->str[len] = '\\0';
|
||||
return_closcall1(data, k, s);
|
||||
")
|
||||
|
|
Loading…
Add table
Reference in a new issue