PERFORCE change 150343 for review

Gabor Kovesdan gabor at FreeBSD.org
Tue Sep 23 13:06:24 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=150343

Change 150343 by gabor at 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 <stdio.h>
 #include <zlib.h>
 
-#ifdef WITH_PCRE
-#include <pcre.h>
-#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;


More information about the p4-projects mailing list