1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-04 12:52:15 +00:00

Fix two problems with REG_ICASE that were introduced with the addition of

multibyte character support:
- In CHadd(), avoid writing past the end of the character set bitmap when
  the opposite-case counterpart of wide characters with values less than
  NC have values greater than or equal to NC.
- In CHaddtype(), fix a braino that caused alphabetic characters to be
  added to all character classes! (but only with REG_ICASE)

PR:		71367
This commit is contained in:
Tim J. Robbins 2004-09-05 08:30:42 +00:00
parent 95269a8951
commit 33176f1755
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=134802

View File

@ -1199,15 +1199,11 @@ struct parse *p;
cset *cs;
wint_t ch;
{
wint_t *newwides;
wint_t nch, *newwides;
assert(ch >= 0);
if (ch < NC) {
if (ch < NC)
cs->bmp[ch >> 3] |= 1 << (ch & 7);
if (cs->icase) {
cs->bmp[towlower(ch) >> 3] |= 1 << (towlower(ch) & 7);
cs->bmp[towupper(ch) >> 3] |= 1 << (towupper(ch) & 7);
}
} else {
else {
newwides = realloc(cs->wides, (cs->nwides + 1) *
sizeof(*cs->wides));
if (newwides == NULL) {
@ -1217,6 +1213,12 @@ wint_t ch;
cs->wides = newwides;
cs->wides[cs->nwides++] = ch;
}
if (cs->icase) {
if ((nch = towlower(ch)) < NC)
cs->bmp[nch >> 3] |= 1 << (nch & 7);
if ((nch = towupper(ch)) < NC)
cs->bmp[nch >> 3] |= 1 << (nch & 7);
}
}
/*
@ -1258,14 +1260,9 @@ wctype_t wct;
wint_t i;
wctype_t *newtypes;
for (i = 0; i < NC; i++) {
for (i = 0; i < NC; i++)
if (iswctype(i, wct))
CHadd(p, cs, i);
if (cs->icase && i != towlower(i))
CHadd(p, cs, towlower(i));
if (cs->icase && i != towupper(i))
CHadd(p, cs, towupper(i));
}
newtypes = realloc(cs->types, (cs->ntypes + 1) *
sizeof(*cs->types));
if (newtypes == NULL) {