diff options
author | ache <ache@FreeBSD.org> | 1996-08-12 12:13:16 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1996-08-12 12:13:16 +0000 |
commit | e853c124679267b145ce0c56e87a85867e02995f (patch) | |
tree | 2ff7e0b2fd755077db70f7ae17b3bb510444a5f7 /lib/libcompat | |
parent | 592128dcde9d5b776c7c4f7f0d75dd30da680658 (diff) | |
download | FreeBSD-src-e853c124679267b145ce0c56e87a85867e02995f.zip FreeBSD-src-e853c124679267b145ce0c56e87a85867e02995f.tar.gz |
Use collate info for alpha character ranges
8bit cleanup
Diffstat (limited to 'lib/libcompat')
-rw-r--r-- | lib/libcompat/Makefile | 2 | ||||
-rw-r--r-- | lib/libcompat/regexp/regexp.c | 21 |
2 files changed, 14 insertions, 9 deletions
diff --git a/lib/libcompat/Makefile b/lib/libcompat/Makefile index 8940719..a9a5477 100644 --- a/lib/libcompat/Makefile +++ b/lib/libcompat/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/4/93 LIB=compat -CFLAGS+=-DLIBC_SCCS -DSYSLIBC_SCCS +CFLAGS+=-DLIBC_SCCS -DSYSLIBC_SCCS -I${.CURDIR}/../libc/locale AINC= -I${.CURDIR}/../libc/${MACHINE} NOPIC= diff --git a/lib/libcompat/regexp/regexp.c b/lib/libcompat/regexp/regexp.c index 3e84968..8bfa3ca 100644 --- a/lib/libcompat/regexp/regexp.c +++ b/lib/libcompat/regexp/regexp.c @@ -38,6 +38,7 @@ #include <stdlib.h> #include <string.h> #include "regmagic.h" +#include "collate.h" /* * The "internal use only" fields in regexp.h are present to pass info from @@ -489,6 +490,7 @@ int *flagp; case '[': { register int class; register int classend; + int i; if (*regparse == '^') { /* Complement of range. */ ret = regnode(ANYBUT); @@ -503,12 +505,16 @@ int *flagp; if (*regparse == ']' || *regparse == '\0') regc('-'); else { - class = UCHARAT(regparse-2)+1; + class = UCHARAT(regparse-2); classend = UCHARAT(regparse); - if (class > classend+1) + if (__collcmp(class, classend) > 0) FAIL("invalid [] range"); - for (; class <= classend; class++) - regc(class); + for (i = 0; i <= UCHAR_MAX; i++) + if ( i != class + && __collcmp(class, i) <= 0 + && __collcmp(i, classend) <= 0 + ) + regc(i); regparse++; } } else @@ -888,7 +894,6 @@ char *prog; { register char *scan; /* Current node. */ char *next; /* Next node. */ - extern char *strchr(); scan = prog; #ifdef DEBUG @@ -913,16 +918,16 @@ char *prog; break; case WORDA: /* Must be looking at a letter, digit, or _ */ - if ((!isalnum(*reginput)) && *reginput != '_') + if ((!isalnum((unsigned char)*reginput)) && *reginput != '_') return(0); /* Prev must be BOL or nonword */ if (reginput > regbol && - (isalnum(reginput[-1]) || reginput[-1] == '_')) + (isalnum((unsigned char)reginput[-1]) || reginput[-1] == '_')) return(0); break; case WORDZ: /* Must be looking at non letter, digit, or _ */ - if (isalnum(*reginput) || *reginput == '_') + if (isalnum((unsigned char)*reginput) || *reginput == '_') return(0); /* We don't care what the previous char was */ break; |