summaryrefslogtreecommitdiff
path: root/lib/libc/regex
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2003-12-07 06:17:18 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2003-12-07 06:17:18 +0000
commitdf4a0d4c010e7d84be1300d9d6cac2d5a9261646 (patch)
tree51373251c8b9b1cc9ed17dd4f08a49096e22aa41 /lib/libc/regex
parent0669e5906cdd980624223eea52373fe1b274a8af (diff)
Unbreak handling of non-ASCII chars. Fixes PR 3594. From FreeBSD
regcmp.c rev 1.13. ok deraadt@
Diffstat (limited to 'lib/libc/regex')
-rw-r--r--lib/libc/regex/regcomp.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index aeba43017ee..394fa9f53cf 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
#else
-static char rcsid[] = "$OpenBSD: regcomp.c,v 1.10 2003/06/02 20:18:36 millert Exp $";
+static char rcsid[] = "$OpenBSD: regcomp.c,v 1.11 2003/12/07 06:17:17 otto Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -400,7 +400,7 @@ register struct parse *p;
ordinary(p, c);
break;
case '{': /* okay as ordinary except if digit follows */
- REQUIRE(!MORE() || !isdigit(PEEK()), REG_BADRPT);
+ REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
/* FALLTHROUGH */
default:
ordinary(p, c);
@@ -412,7 +412,7 @@ register struct parse *p;
c = PEEK();
/* we call { a repetition if followed by a digit */
if (!( c == '*' || c == '+' || c == '?' ||
- (c == '{' && MORE2() && isdigit(PEEK2())) ))
+ (c == '{' && MORE2() && isdigit((uch)PEEK2())) ))
return; /* no repetition, we're done */
NEXT();
@@ -441,7 +441,7 @@ register struct parse *p;
case '{':
count = p_count(p);
if (EAT(',')) {
- if (isdigit(PEEK())) {
+ if (isdigit((uch)PEEK())) {
count2 = p_count(p);
REQUIRE(count <= count2, REG_BADBR);
} else /* single number with comma */
@@ -462,7 +462,7 @@ register struct parse *p;
return;
c = PEEK();
if (!( c == '*' || c == '+' || c == '?' ||
- (c == '{' && MORE2() && isdigit(PEEK2())) ) )
+ (c == '{' && MORE2() && isdigit((uch)PEEK2())) ) )
return;
SETERROR(REG_BADRPT);
}
@@ -544,7 +544,7 @@ int starordinary; /* is a leading * an ordinary character? */
c = GETNEXT();
if (c == '\\') {
REQUIRE(MORE(), REG_EESCAPE);
- c = BACKSL | (unsigned char)GETNEXT();
+ c = BACKSL | GETNEXT();
}
switch (c) {
case '.':
@@ -606,7 +606,7 @@ int starordinary; /* is a leading * an ordinary character? */
REQUIRE(starordinary, REG_BADRPT);
/* FALLTHROUGH */
default:
- ordinary(p, c &~ BACKSL);
+ ordinary(p, (char)c);
break;
}
@@ -619,7 +619,7 @@ int starordinary; /* is a leading * an ordinary character? */
} else if (EATTWO('\\', '{')) {
count = p_count(p);
if (EAT(',')) {
- if (MORE() && isdigit(PEEK())) {
+ if (MORE() && isdigit((uch)PEEK())) {
count2 = p_count(p);
REQUIRE(count <= count2, REG_BADBR);
} else /* single number with comma */
@@ -633,7 +633,7 @@ int starordinary; /* is a leading * an ordinary character? */
REQUIRE(MORE(), REG_EBRACE);
SETERROR(REG_BADBR);
}
- } else if (c == (unsigned char)'$') /* $ (but not \$) ends it */
+ } else if (c == '$') /* $ (but not \$) ends it */
return(1);
return(0);
@@ -650,7 +650,7 @@ register struct parse *p;
register int count = 0;
register int ndigits = 0;
- while (MORE() && isdigit(PEEK()) && count <= DUPMAX) {
+ while (MORE() && isdigit((uch)PEEK()) && count <= DUPMAX) {
count = count*10 + (GETNEXT() - '0');
ndigits++;
}
@@ -910,6 +910,7 @@ static char /* if no counterpart, return ch */
othercase(ch)
int ch;
{
+ ch = (uch)ch;
assert(isalpha(ch));
if (isupper(ch))
return(tolower(ch));
@@ -934,6 +935,7 @@ int ch;
register char *oldend = p->end;
char bracket[3];
+ ch = (uch)ch;
assert(othercase(ch) != ch); /* p_bracket() would recurse */
p->next = bracket;
p->end = bracket+2;
@@ -957,10 +959,10 @@ register int ch;
{
register cat_t *cap = p->g->categories;
- if ((p->g->cflags&REG_ICASE) && isalpha(ch) && othercase(ch) != ch)
+ if ((p->g->cflags&REG_ICASE) && isalpha((uch)ch) && othercase(ch) != ch)
bothcases(p, ch);
else {
- EMIT(OCHAR, (unsigned char)ch);
+ EMIT(OCHAR, (uch)ch);
if (cap[ch] == 0)
cap[ch] = p->g->ncategories++;
}
@@ -1328,7 +1330,7 @@ int c;
register uch *col;
register int i;
register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
- register unsigned uc = (unsigned char)c;
+ register unsigned uc = (uch)c;
for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
if (col[uc] != 0)
@@ -1349,8 +1351,8 @@ int c2;
register uch *col;
register int i;
register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
- register unsigned uc1 = (unsigned char)c1;
- register unsigned uc2 = (unsigned char)c2;
+ register unsigned uc1 = (uch)c1;
+ register unsigned uc2 = (uch)c2;
for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
if (col[uc1] != col[uc2])