mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-24 05:21:20 -08:00
unicode: fix ecl_string_case for non-ascii characters
Problem reported and fix provided by Vladimir Sedach on the ecl-devel mailing list.
This commit is contained in:
parent
4cac9bc5e0
commit
ca01514a47
1 changed files with 5 additions and 4 deletions
|
|
@ -99,6 +99,7 @@ cl_both_case_p(cl_object c)
|
|||
int
|
||||
ecl_string_case(cl_object s)
|
||||
{
|
||||
/* Returns 1 if string is all uppercase, -1 if all lowercase, and 0 if mixed case */
|
||||
int upcase;
|
||||
cl_index i;
|
||||
ecl_base_char *text;
|
||||
|
|
@ -106,16 +107,16 @@ ecl_string_case(cl_object s)
|
|||
switch (ecl_t_of(s)) {
|
||||
#ifdef ECL_UNICODE
|
||||
case t_string:
|
||||
s = si_coerce_to_base_string(s);
|
||||
#endif
|
||||
case t_base_string:
|
||||
text = (ecl_base_char*)s->base_string.self;
|
||||
for (i = 0, upcase = 0; i < s->base_string.dim; i++) {
|
||||
if (ecl_upper_case_p(text[i])) {
|
||||
ecl_character c = ecl_char(s, i);
|
||||
|
||||
if (ecl_upper_case_p(c)) {
|
||||
if (upcase < 0)
|
||||
return 0;
|
||||
upcase = +1;
|
||||
} else if (ecl_lower_case_p(text[i])) {
|
||||
} else if (ecl_lower_case_p(c)) {
|
||||
if (upcase > 0)
|
||||
return 0;
|
||||
upcase = -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue