Module Name: src
Committed By: joerg
Date: Sun May 6 22:27:01 UTC 2012
Modified Files:
src/usr.bin/grep: grep.c grep.h util.c
Log Message:
Remove matchall handling for now, it doesn't work correctly and as such,
it is a premature optimisation.
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/grep/grep.c
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/grep/grep.h
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/grep/util.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/grep/grep.c
diff -u src/usr.bin/grep/grep.c:1.10 src/usr.bin/grep/grep.c:1.11
--- src/usr.bin/grep/grep.c:1.10 Fri Sep 16 15:39:26 2011
+++ src/usr.bin/grep/grep.c Sun May 6 22:27:00 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: grep.c,v 1.10 2011/09/16 15:39:26 joerg Exp $ */
+/* $NetBSD: grep.c,v 1.11 2012/05/06 22:27:00 joerg Exp $ */
/* $FreeBSD: head/usr.bin/grep/grep.c 211519 2010-08-19 22:55:17Z delphij $ */
/* $OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $ */
@@ -34,7 +34,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: grep.c,v 1.10 2011/09/16 15:39:26 joerg Exp $");
+__RCSID("$NetBSD: grep.c,v 1.11 2012/05/06 22:27:00 joerg Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@@ -80,9 +80,6 @@ const char *errstr[] = {
int cflags = 0;
int eflags = REG_STARTEND;
-/* Shortcut for matching all cases like empty regex */
-bool matchall;
-
/* Searching patterns */
unsigned int patterns, pattern_sz;
char **pattern;
@@ -229,11 +226,8 @@ static void
add_pattern(char *pat, size_t len)
{
- /* Check if we can do a shortcut */
- if (len == 0 || matchall) {
- matchall = true;
- return;
- }
+ /* TODO: Check for empty patterns and shortcut */
+
/* Increase size if necessary */
if (patterns == pattern_sz) {
pattern_sz *= 2;
Index: src/usr.bin/grep/grep.h
diff -u src/usr.bin/grep/grep.h:1.7 src/usr.bin/grep/grep.h:1.8
--- src/usr.bin/grep/grep.h:1.7 Mon Apr 18 22:46:48 2011
+++ src/usr.bin/grep/grep.h Sun May 6 22:27:00 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: grep.h,v 1.7 2011/04/18 22:46:48 joerg Exp $ */
+/* $NetBSD: grep.h,v 1.8 2012/05/06 22:27:00 joerg Exp $ */
/* $OpenBSD: grep.h,v 1.15 2010/04/05 03:03:55 tedu Exp $ */
/* $FreeBSD: head/usr.bin/grep/grep.h 211496 2010-08-19 09:28:59Z des $ */
@@ -120,7 +120,7 @@ extern char *label;
extern const char *color;
extern int binbehave, devbehave, dirbehave, filebehave, grepbehave, linkbehave;
-extern bool matchall, notfound;
+extern bool notfound;
extern int tail;
extern unsigned int dpatterns, fpatterns, patterns;
extern char **pattern;
Index: src/usr.bin/grep/util.c
diff -u src/usr.bin/grep/util.c:1.14 src/usr.bin/grep/util.c:1.15
--- src/usr.bin/grep/util.c:1.14 Sun May 6 21:56:08 2012
+++ src/usr.bin/grep/util.c Sun May 6 22:27:01 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: util.c,v 1.14 2012/05/06 21:56:08 joerg Exp $ */
+/* $NetBSD: util.c,v 1.15 2012/05/06 22:27:01 joerg Exp $ */
/* $FreeBSD: head/usr.bin/grep/util.c 211496 2010-08-19 09:28:59Z des $ */
/* $OpenBSD: util.c,v 1.39 2010/07/02 22:18:03 tedu Exp $ */
@@ -34,7 +34,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: util.c,v 1.14 2012/05/06 21:56:08 joerg Exp $");
+__RCSID("$NetBSD: util.c,v 1.15 2012/05/06 22:27:01 joerg Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@@ -227,12 +227,8 @@ procfile(const char *fn)
for (first = true, c = 0; c == 0 || !(lflag || qflag); ) {
ln.off += ln.len + 1;
- if ((ln.dat = grep_fgetln(f, &ln.len)) == NULL || ln.len == 0) {
- if (ln.line_no == 0 && matchall)
- exit(0);
- else
- break;
- }
+ if ((ln.dat = grep_fgetln(f, &ln.len)) == NULL || ln.len == 0)
+ break;
if (ln.len > 0 && ln.dat[ln.len - 1] == line_sep)
--ln.len;
ln.line_no++;
@@ -295,17 +291,6 @@ procline(struct str *l, int nottext)
unsigned int i;
int c = 0, m = 0, r = 0;
- if (matchall) {
- /* Short cut the case of (not) matching wild card pattern */
- if (vflag)
- return (0);
- if ((binbehave == BINFILE_BIN && nottext) || cflag || qflag ||
- lflag || Lflag)
- return (1);
- printline(l, ':', matches, m);
- return (1);
- }
-
/* Loop to process the whole line */
while (st <= l->len) {
pmatch.rm_so = st;