sh: Fix locale-dependent ranges in bracket expressions.

When I added UTF-8 support in r221646, the LC_COLLATE-based ordering broke
because of sign extension of char.

Because of libc restrictions, this does not work for UTF-8. For UTF-8
locales, ranges always use character code order.
This commit is contained in:
Jilles Tjoelker 2011-06-12 12:54:52 +00:00
parent 69a6d1985d
commit f5ac5937d3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=223010

View File

@ -1430,7 +1430,7 @@ patmatch(const char *pattern, const char *string, int squoted)
if (localeisutf8)
wc = get_wc(&q);
else
wc = *q++;
wc = (unsigned char)*q++;
if (wc == '\0')
return 0;
break;
@ -1487,7 +1487,7 @@ patmatch(const char *pattern, const char *string, int squoted)
if (localeisutf8)
chr = get_wc(&q);
else
chr = *q++;
chr = (unsigned char)*q++;
if (chr == '\0')
return 0;
c = *p++;
@ -1502,7 +1502,7 @@ patmatch(const char *pattern, const char *string, int squoted)
if (wc == 0) /* bad utf-8 */
return 0;
} else
wc = c;
wc = (unsigned char)c;
if (*p == '-' && p[1] != ']') {
p++;
while (*p == CTLQUOTEMARK)
@ -1514,7 +1514,7 @@ patmatch(const char *pattern, const char *string, int squoted)
if (wc2 == 0) /* bad utf-8 */
return 0;
} else
wc2 = *p++;
wc2 = (unsigned char)*p++;
if ( collate_range_cmp(chr, wc) >= 0
&& collate_range_cmp(chr, wc2) <= 0
)