Unicode changes, take code points into account

This commit is contained in:
Justin Ethier 2017-10-22 18:59:35 -04:00
parent ac8b280578
commit 14626f15c4

View file

@ -2032,7 +2032,7 @@ object Cyc_string_cmp(void *data, object str1, object str2)
}
#define Cyc_string_append_va_list(data, argc) { \
int i = 0, total_len = 1; \
int i = 0, total_cp = 0, total_len = 1; \
int *len = alloca(sizeof(int) * argc); \
char *buffer, *bufferp, **str = alloca(sizeof(char *) * argc); \
object tmp; \
@ -2041,6 +2041,7 @@ object Cyc_string_cmp(void *data, object str1, object str2)
str[i] = ((string_type *)str1)->str; \
len[i] = string_len((str1)); \
total_len += len[i]; \
total_cp += string_num_cp(str1); \
} \
for (i = 1; i < argc; i++) { \
tmp = va_arg(ap, object); \
@ -2048,6 +2049,7 @@ object Cyc_string_cmp(void *data, object str1, object str2)
str[i] = ((string_type *)tmp)->str; \
len[i] = string_len((tmp)); \
total_len += len[i]; \
total_cp += string_num_cp(tmp); \
} \
buffer = bufferp = alloca(sizeof(char) * total_len); \
for (i = 0; i < argc; i++) { \
@ -2056,6 +2058,7 @@ object Cyc_string_cmp(void *data, object str1, object str2)
} \
*bufferp = '\0'; \
make_string(result, buffer); \
string_num_cp(result) = total_cp; \
va_end(ap); \
_return_closcall1(data, cont, &result); \
}
@ -2078,7 +2081,7 @@ object Cyc_string_append(void *data, object cont, int _argc, object str1, ...)
object Cyc_string_length(void *data, object str)
{
Cyc_check_str(data, str);
return obj_int2obj(string_len(str));
return obj_int2obj(string_num_cp(str));
}
object Cyc_string_set(void *data, object str, object k, object chr)