summaryrefslogtreecommitdiffstats
path: root/lib/libc/regex/regcomp.c
diff options
context:
space:
mode:
authordcs <dcs@FreeBSD.org>2000-07-07 07:46:36 +0000
committerdcs <dcs@FreeBSD.org>2000-07-07 07:46:36 +0000
commit88593e5a993ce0a65b73111dbfbeafda775878e6 (patch)
tree5cbd0ce0d84cc805324f2ad32fc58780ab35f177 /lib/libc/regex/regcomp.c
parentf5198f88cf58e1d0eafa9a3b8ea70511589ea363 (diff)
downloadFreeBSD-src-88593e5a993ce0a65b73111dbfbeafda775878e6.zip
FreeBSD-src-88593e5a993ce0a65b73111dbfbeafda775878e6.tar.gz
Deal with the signed/unsigned chars issue in a more proper manner. We
use a CHAR_MIN-based array, like elsewhere in the code. Remove a number of unused variables (some due to the above change, one that was left after a number of optimizing steps through the source). Brucified by: bde
Diffstat (limited to 'lib/libc/regex/regcomp.c')
-rw-r--r--lib/libc/regex/regcomp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index e943374..9664084 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -1942,14 +1942,16 @@ struct re_guts *g;
if (p->error != 0)
return;
- g->charjump = malloc((UCHAR_MAX+1) * sizeof(int));
+ g->charjump = malloc((NC + 1) * sizeof(int));
if (g->charjump == NULL) /* Not a fatal error */
return;
+ /* Adjust for signed chars, if necessary */
+ g->charjump = &g->charjump[-(CHAR_MIN)];
/* If the character does not exist in the pattern, the jump
* is equal to the number of characters in the pattern.
*/
- for (ch = 0; ch < (UCHAR_MAX+1); ch++)
+ for (ch = CHAR_MIN; ch < (CHAR_MAX + 1); ch++)
g->charjump[ch] = g->mlen;
/* If the character does exist, compute the jump that would
@@ -1958,7 +1960,7 @@ struct re_guts *g;
* is the first one that would be matched).
*/
for (mindex = 0; mindex < g->mlen; mindex++)
- g->charjump[(unsigned char)g->must[mindex]] = g->mlen - mindex - 1;
+ g->charjump[g->must[mindex]] = g->mlen - mindex - 1;
}
/*
OpenPOWER on IntegriCloud