1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

Cleanup and bugfix:

When looking for uppercase characters, iterate over multibyte
characters with the standard function mbtowc(3) rather than with
the buggy and outdated step_char(), skipping invalid bytes,
and correctly use iswupper(3) instead of the inapplicable isupper(3).
OK stsp@
This commit is contained in:
schwarze 2019-03-14 16:21:35 +00:00
parent fee69528d2
commit d0dcf7a64d

View File

@ -75,12 +75,14 @@ static struct pattern_info filter_info;
static int
is_ucase(char *str)
{
char *str_end = str + strlen(str);
LWCHAR ch;
wchar_t ch;
int len;
while (str < str_end) {
ch = step_char(&str, +1, str_end);
if (isupper(ch))
for (; *str != '\0'; str += len) {
if ((len = mbtowc(&ch, str, MB_CUR_MAX)) == -1) {
mbtowc(NULL, NULL, MB_CUR_MAX);
len = 1;
} else if (iswupper(ch))
return (1);
}
return (0);