diff options
author | ache <ache@FreeBSD.org> | 1997-04-04 20:10:53 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-04-04 20:10:53 +0000 |
commit | 1aefb8ae80064d515617534ba57f5859b3d3f308 (patch) | |
tree | 329db2e7d5ee957fe0d8245f47da9c4316c1d301 /lib/libcompat | |
parent | f9d135173d727a644b7a44b7a30a67686041501c (diff) | |
download | FreeBSD-src-1aefb8ae80064d515617534ba57f5859b3d3f308.zip FreeBSD-src-1aefb8ae80064d515617534ba57f5859b3d3f308.tar.gz |
Speedup in case locale not used
Diffstat (limited to 'lib/libcompat')
-rw-r--r-- | lib/libcompat/Makefile | 2 | ||||
-rw-r--r-- | lib/libcompat/regexp/regexp.c | 42 |
2 files changed, 17 insertions, 27 deletions
diff --git a/lib/libcompat/Makefile b/lib/libcompat/Makefile index 9596594..5bf8c33 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 a442b96..fc97378 100644 --- a/lib/libcompat/regexp/regexp.c +++ b/lib/libcompat/regexp/regexp.c @@ -38,6 +38,7 @@ #include <ctype.h> #include <stdlib.h> #include <string.h> +#include "collate.h" #include "regmagic.h" /* @@ -181,28 +182,10 @@ STATIC void regc(); STATIC void reginsert(); STATIC void regtail(); STATIC void regoptail(); -STATIC int collate_range_cmp(); #ifdef STRCSPN STATIC int strcspn(); #endif -static int collate_range_cmp (c1, c2) - int c1, c2; -{ - static char s1[2], s2[2]; - int ret; - - c1 &= UCHAR_MAX; - c2 &= UCHAR_MAX; - if (c1 == c2) - return (0); - s1[0] = c1; - s2[0] = c2; - if ((ret = strcoll(s1, s2)) != 0) - return (ret); - return (c1 - c2); -} - /* - regcomp - compile a regular expression into internal code * @@ -525,14 +508,21 @@ int *flagp; else { class = UCHARAT(regparse-2); classend = UCHARAT(regparse); - if (collate_range_cmp(class, classend) > 0) - FAIL("invalid [] range"); - for (i = 0; i <= UCHAR_MAX; i++) - if ( i != class - && collate_range_cmp(class, i) <= 0 - && collate_range_cmp(i, classend) <= 0 - ) - regc(i); + if (__collate_load_error) { + if (class > classend) + FAIL("invalid [] range"); + for (class++; class <= classend; class++) + regc(class); + } else { + if (__collate_range_cmp(class, classend) > 0) + FAIL("invalid [] range"); + for (i = 0; i <= UCHAR_MAX; i++) + if ( i != class + && __collate_range_cmp(class, i) <= 0 + && __collate_range_cmp(i, classend) <= 0 + ) + regc(i); + } regparse++; } } else |