summaryrefslogtreecommitdiff
path: root/usr.bin/grep
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2010-07-02 22:18:04 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2010-07-02 22:18:04 +0000
commit046db12c08f574744ecb1667c9f620be4edb2cd8 (patch)
treeb1aa5c8900ba0e29aaf52bd79647915c64676845 /usr.bin/grep
parent0e0c76b0b9681df1f311463288e4181d8863e2f6 (diff)
Remove the "fast" grep code if SMALL. This has the side effect of breaking
fgrep -w, but oh well. ok deraadt millert
Diffstat (limited to 'usr.bin/grep')
-rw-r--r--usr.bin/grep/grep.c14
-rw-r--r--usr.bin/grep/util.c16
2 files changed, 27 insertions, 3 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c
index 184e6fd6b82..d34fd959750 100644
--- a/usr.bin/grep/grep.c
+++ b/usr.bin/grep/grep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grep.c,v 1.41 2010/04/20 15:58:08 jacekm Exp $ */
+/* $OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -444,13 +444,23 @@ main(int argc, char *argv[])
if (Eflag)
cflags |= REG_EXTENDED;
+ if (Fflag)
+ cflags |= REG_NOSPEC;
+#ifdef SMALL
+ /* Sorry, this won't work */
+ if (Fflag && wflag)
+ errx(1, "Can't use small fgrep with -w");
+#endif
fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern));
r_pattern = grep_calloc(patterns, sizeof(*r_pattern));
for (i = 0; i < patterns; ++i) {
/* Check if cheating is allowed (always is for fgrep). */
+#ifndef SMALL
if (Fflag) {
fgrepcomp(&fg_pattern[i], pattern[i]);
- } else {
+ } else
+#endif
+ {
if (fastcomp(&fg_pattern[i], pattern[i])) {
/* Fall back to full regex library */
c = regcomp(&r_pattern[i], pattern[i], cflags);
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c
index eb9da8b74ee..77755fb70ca 100644
--- a/usr.bin/grep/util.c
+++ b/usr.bin/grep/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.38 2010/04/25 14:13:36 eric Exp $ */
+/* $OpenBSD: util.c,v 1.39 2010/07/02 22:18:03 tedu Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -49,8 +49,10 @@
static int linesqueued;
static int procline(str_t *l, int);
static int grep_search(fastgrep_t *, unsigned char *, size_t, regmatch_t *pmatch);
+#ifndef SMALL
static int grep_cmp(const unsigned char *, const unsigned char *, size_t);
static void grep_revstr(unsigned char *, int);
+#endif
int
grep_tree(char **argv)
@@ -217,6 +219,7 @@ print:
return c;
}
+#ifndef SMALL
void
fgrepcomp(fastgrep_t *fg, const char *pattern)
{
@@ -255,6 +258,7 @@ fgrepcomp(fastgrep_t *fg, const char *pattern)
fg->qsBc[tolower(fg->pattern[i])] = fg->patternLen - i;
}
}
+#endif
/*
* Returns: -1 on failure, 0 on success
@@ -262,6 +266,9 @@ fgrepcomp(fastgrep_t *fg, const char *pattern)
int
fastcomp(fastgrep_t *fg, const char *pattern)
{
+#ifdef SMALL
+ return -1;
+#else
int i;
int bol = 0;
int eol = 0;
@@ -402,6 +409,7 @@ fastcomp(fastgrep_t *fg, const char *pattern)
grep_revstr(fg->pattern, fg->patternLen);
return (0);
+#endif
}
/*
@@ -418,6 +426,9 @@ fastcomp(fastgrep_t *fg, const char *pattern)
static int
grep_search(fastgrep_t *fg, unsigned char *data, size_t dataLen, regmatch_t *pmatch)
{
+#ifdef SMALL
+ return 0;
+#else
int j;
int rtrnVal = REG_NOMATCH;
@@ -491,6 +502,7 @@ grep_search(fastgrep_t *fg, unsigned char *data, size_t dataLen, regmatch_t *pma
}
return (rtrnVal);
+#endif
}
@@ -522,6 +534,7 @@ grep_realloc(void *ptr, size_t size)
return ptr;
}
+#ifndef SMALL
/*
* Returns: i >= 0 on failure (position that it failed)
* -1 on success
@@ -553,6 +566,7 @@ grep_revstr(unsigned char *str, int len)
str[len - i - 1] = c;
}
}
+#endif
void
printline(str_t *line, int sep)