mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 08:17:35 +02:00
Unicode changes, take code points into account
This commit is contained in:
parent
ac8b280578
commit
14626f15c4
1 changed files with 5 additions and 2 deletions
|
@ -2032,7 +2032,7 @@ object Cyc_string_cmp(void *data, object str1, object str2)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Cyc_string_append_va_list(data, argc) { \
|
#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); \
|
int *len = alloca(sizeof(int) * argc); \
|
||||||
char *buffer, *bufferp, **str = alloca(sizeof(char *) * argc); \
|
char *buffer, *bufferp, **str = alloca(sizeof(char *) * argc); \
|
||||||
object tmp; \
|
object tmp; \
|
||||||
|
@ -2041,6 +2041,7 @@ object Cyc_string_cmp(void *data, object str1, object str2)
|
||||||
str[i] = ((string_type *)str1)->str; \
|
str[i] = ((string_type *)str1)->str; \
|
||||||
len[i] = string_len((str1)); \
|
len[i] = string_len((str1)); \
|
||||||
total_len += len[i]; \
|
total_len += len[i]; \
|
||||||
|
total_cp += string_num_cp(str1); \
|
||||||
} \
|
} \
|
||||||
for (i = 1; i < argc; i++) { \
|
for (i = 1; i < argc; i++) { \
|
||||||
tmp = va_arg(ap, object); \
|
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; \
|
str[i] = ((string_type *)tmp)->str; \
|
||||||
len[i] = string_len((tmp)); \
|
len[i] = string_len((tmp)); \
|
||||||
total_len += len[i]; \
|
total_len += len[i]; \
|
||||||
|
total_cp += string_num_cp(tmp); \
|
||||||
} \
|
} \
|
||||||
buffer = bufferp = alloca(sizeof(char) * total_len); \
|
buffer = bufferp = alloca(sizeof(char) * total_len); \
|
||||||
for (i = 0; i < argc; i++) { \
|
for (i = 0; i < argc; i++) { \
|
||||||
|
@ -2056,6 +2058,7 @@ object Cyc_string_cmp(void *data, object str1, object str2)
|
||||||
} \
|
} \
|
||||||
*bufferp = '\0'; \
|
*bufferp = '\0'; \
|
||||||
make_string(result, buffer); \
|
make_string(result, buffer); \
|
||||||
|
string_num_cp(result) = total_cp; \
|
||||||
va_end(ap); \
|
va_end(ap); \
|
||||||
_return_closcall1(data, cont, &result); \
|
_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)
|
object Cyc_string_length(void *data, object str)
|
||||||
{
|
{
|
||||||
Cyc_check_str(data, 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)
|
object Cyc_string_set(void *data, object str, object k, object chr)
|
||||||
|
|
Loading…
Add table
Reference in a new issue