From b15443ba83936fa4e0bc4e843c9bd783c5e19b3b Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Fri, 4 Apr 1997 20:10:53 +0000 Subject: [PATCH] Speedup in case locale not used --- lib/libcompat/Makefile | 2 +- lib/libcompat/regexp/regexp.c | 42 +++++++++++++---------------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/lib/libcompat/Makefile b/lib/libcompat/Makefile index 9596594c6449..5bf8c3354c24 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 a442b962cfd2..fc97378f759f 100644 --- a/lib/libcompat/regexp/regexp.c +++ b/lib/libcompat/regexp/regexp.c @@ -38,6 +38,7 @@ #include #include #include +#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