From owner-p4-projects@FreeBSD.ORG Tue Sep 23 13:06:23 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C229E1065679; Tue, 23 Sep 2008 13:06:23 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 858631065673 for ; Tue, 23 Sep 2008 13:06:23 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 765048FC14 for ; Tue, 23 Sep 2008 13:06:23 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id m8ND6NRN093093 for ; Tue, 23 Sep 2008 13:06:23 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m8ND6NnD093087 for perforce@freebsd.org; Tue, 23 Sep 2008 13:06:23 GMT (envelope-from gabor@freebsd.org) Date: Tue, 23 Sep 2008 13:06:23 GMT Message-Id: <200809231306.m8ND6NnD093087@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gabor@freebsd.org using -f From: Gabor Kovesdan To: Perforce Change Reviews Cc: Subject: PERFORCE change 150343 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Sep 2008 13:06:24 -0000 http://perforce.freebsd.org/chv.cgi?CH=150343 Change 150343 by gabor@gabor_server on 2008/09/23 13:05:23 - Eliminate wip PCRE parts, it is not really demanded Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/Makefile#15 edit .. //depot/projects/soc2008/gabor_textproc/grep/grep.c#75 edit .. //depot/projects/soc2008/gabor_textproc/grep/grep.h#43 edit .. //depot/projects/soc2008/gabor_textproc/grep/util.c#76 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/Makefile#15 (text+ko) ==== @@ -20,13 +20,6 @@ LDADD= -lz -lbz2 DPADD= ${LIBZ} ${LIBBZ2} -.if defined(WITH_PCRE) -CFLAGS+= -DWITH_PCRE=yes -I/usr/local/include -LDFLAGS+= -L/usr/local/lib -LDADD+= -lpcre -DPADD+= /usr/local/lib/libpcre.a -.endif - .if !defined(WITHOUT_NLS) NLS= hu_HU.ISO8859-2 NLS+= pt_BR.ISO8859-1 ==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#75 (text+ko) ==== @@ -79,9 +79,6 @@ /*14*/ "unknown -d or --directory option", /*15*/ "unknown --color option", /*16*/ "cannot read bzip2 compressed file", -/*17*/ "PCRE is not enabled in this version of grep. " - "To enable this feature, please install libpcre and" - "recompile grep with WITH_PCRE set." }; /* Flags passed to regcomp() and regexec() */ @@ -96,9 +93,6 @@ char **pattern; regex_t *r_pattern; fastgrep_t *fg_pattern; -#ifdef WITH_PCRE -pcre **perl_pattern; -#endif /* Filename exclusion/inclusion patterns */ int epatterns, epattern_sz; @@ -209,7 +203,6 @@ {"max-count", required_argument, NULL, 'm'}, {"line-number", no_argument, NULL, 'n'}, {"only-matching", no_argument, NULL, 'o'}, - {"perl-regexp", no_argument, NULL, 'P'}, {"quiet", no_argument, NULL, 'q'}, {"silent", no_argument, NULL, 'q'}, {"recursive", no_argument, NULL, 'r'}, @@ -462,9 +455,6 @@ case 'o': oflag++; break; - case 'P': - grepbehave = GREP_PERL; - break; case 'p': linkbehave = LINK_SKIP; break; @@ -581,53 +571,32 @@ case GREP_EXTENDED: cflags |= REG_EXTENDED; break; - case GREP_PERL: -#ifndef WITH_PCRE - errx(2, getstr(17)); -#endif - break; default: /* NOTREACHED */ usage(); } - if (grepbehave != GREP_PERL) { - fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern)); - r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); + + fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern)); + r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); /* * XXX: fgrepcomp() and fastcomp() are workarounds for regexec() performance. * Optimizations should be done there. */ - for (i = 0; i < patterns; ++i) { - /* Check if cheating is allowed (always is for fgrep). */ - if (grepbehave == GREP_FIXED) - fgrepcomp(&fg_pattern[i], pattern[i]); - else { - if (fastcomp(&fg_pattern[i], pattern[i])) { - /* Fall back to full regex library */ - c = regcomp(&r_pattern[i], pattern[i], cflags); - if (c != 0) { - regerror(c, &r_pattern[i], re_error, - RE_ERROR_BUF); - errx(2, "%s", re_error); - } + for (i = 0; i < patterns; ++i) { + /* Check if cheating is allowed (always is for fgrep). */ + if (grepbehave == GREP_FIXED) + fgrepcomp(&fg_pattern[i], pattern[i]); + else { + if (fastcomp(&fg_pattern[i], pattern[i])) { + /* Fall back to full regex library */ + c = regcomp(&r_pattern[i], pattern[i], cflags); + if (c != 0) { + regerror(c, &r_pattern[i], re_error, + RE_ERROR_BUF); + errx(2, "%s", re_error); } } } - } else { -#ifdef WITH_PCRE - /* Compile Perl regexes with pcre_compile() */ - perl_pattern = grep_calloc(patterns, sizeof(perl_pattern)); - for (i = 0; i < patterns; ++i) { - char **err_msg = NULL; - int erroff; - - perl_pattern[i] = pcre_compile(pattern[i], 0, (const char **)err_msg, &erroff, NULL); - if (perl_pattern[i] != NULL) - errx(2, "wrong PCRE: %s", err_msg[0]); - } -#else - ; -#endif } if (lbflag) ==== //depot/projects/soc2008/gabor_textproc/grep/grep.h#43 (text+ko) ==== @@ -32,10 +32,6 @@ #include #include -#ifdef WITH_PCRE -#include -#endif - #ifdef WITHOUT_NLS #define getstr(n) errstr[n] #else @@ -52,7 +48,6 @@ #define GREP_FIXED 0 #define GREP_BASIC 1 #define GREP_EXTENDED 2 -#define GREP_PERL 3 #define BINFILE_BIN 0 #define BINFILE_SKIP 1 @@ -118,11 +113,6 @@ extern regex_t *r_pattern, *er_pattern; extern fastgrep_t *fg_pattern; -#ifdef WITH_PCRE -extern pcre **perl_pattern; -#endif - - /* For regex errors */ #define RE_ERROR_BUF 512 extern char re_error[RE_ERROR_BUF + 1]; /* Seems big enough */ ==== //depot/projects/soc2008/gabor_textproc/grep/util.c#76 (text+ko) ==== @@ -263,19 +263,10 @@ l->len, &pmatch); r = (r == 0) ? (vflag ? REG_NOMATCH : 0) : (vflag ? 0 : REG_NOMATCH); st = pmatch.rm_eo; - } else if (grepbehave != GREP_PERL) { + } else { r = regexec(&r_pattern[i], l->dat, 1, &pmatch, eflags); r = (r == 0) ? (vflag ? REG_NOMATCH : 0) : (vflag ? 0 : REG_NOMATCH); st = pmatch.rm_eo; - } else { -#ifdef WITH_PCRE - r = pcre_exec(perl_pattern[i], NULL, l->dat, l->len, st, 0, ovector, 3); - pmatch.rm_so = ovector[0]; - pmatch.rm_eo = ovector[1]; - st = ovector[1]; -#else - ; -#endif } if (r == REG_NOMATCH) continue;