mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-14 21:32:49 -08:00
unicode: Improve unicode handling for characters.
Additional sanity checks and bugfixes in case of providing extended strings to character low-level functions. Signed-off-by: Daniel Kochmański <dkochmanski@turtle-solutions.eu>
This commit is contained in:
parent
8977a7cc85
commit
3938eb8893
2 changed files with 26 additions and 10 deletions
|
|
@ -5,6 +5,7 @@
|
|||
/*
|
||||
Copyright (c) 1984, Taiichi Yuasa and Masami Hagiya.
|
||||
Copyright (c) 1990, Giuseppe Attardi.
|
||||
Copyright (c) 2015, Daniel Kochmański.
|
||||
|
||||
ECL is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
|
|
@ -86,6 +87,8 @@ ucd_char_data(ecl_character code)
|
|||
static cl_index
|
||||
ucd_value_0(ecl_character code)
|
||||
{
|
||||
if (ecl_unlikely((code >= 0x110000)))
|
||||
FEerror("The value ~A is not of type (MOD 1114112)", 1, code);
|
||||
return ucd_char_data(code)[0];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
/*
|
||||
Copyright (c) 1984, Taiichi Yuasa and Masami Hagiya.
|
||||
Copyright (c) 1990, Giuseppe Attardi.
|
||||
Copyright (c) 2015, Daniel Kochmański.
|
||||
|
||||
ECL is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
|
|
@ -103,17 +104,29 @@ ecl_string_case(cl_object s)
|
|||
{
|
||||
int upcase;
|
||||
cl_index i;
|
||||
const ecl_base_char *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])) {
|
||||
if (upcase < 0)
|
||||
return 0;
|
||||
upcase = +1;
|
||||
} else if (ecl_lower_case_p(text[i])) {
|
||||
if (upcase > 0)
|
||||
return 0;
|
||||
upcase = -1;
|
||||
ecl_base_char *text;
|
||||
|
||||
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])) {
|
||||
if (upcase < 0)
|
||||
return 0;
|
||||
upcase = +1;
|
||||
} else if (ecl_lower_case_p(text[i])) {
|
||||
if (upcase > 0)
|
||||
return 0;
|
||||
upcase = -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FEwrong_type_argument(@[string], s);
|
||||
}
|
||||
return upcase;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue