diff options
| author | Tim J. Robbins <tjr@FreeBSD.org> | 2004-09-05 08:30:42 +0000 | 
|---|---|---|
| committer | Tim J. Robbins <tjr@FreeBSD.org> | 2004-09-05 08:30:42 +0000 | 
| commit | 33176f1755c655c3485a95b87f4979a3d715d07d (patch) | |
| tree | 6203250c9def2e38b4900eb5e5a064134c75336a /lib/libc/regex/regcomp.c | |
| parent | 95269a89517a57a1f3da5a6850753a0aeb7b4cd1 (diff) | |
Notes
Diffstat (limited to 'lib/libc/regex/regcomp.c')
| -rw-r--r-- | lib/libc/regex/regcomp.c | 23 | 
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index 7c10f621ba5c..ace6d0a46f67 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -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) {  | 
