diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-06-13 06:24:53 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-06-13 06:24:53 +0000 |
commit | 053b1462b72feea51b3b8745662447d5f8d18fda (patch) | |
tree | 83edeea4d3913d4bbfab0fef6f46f5f4cbbd548c /findutils/grep.c | |
parent | baf22bff21f91a8c715729892113c1bf5b7b8c4a (diff) | |
download | busybox-w32-053b1462b72feea51b3b8745662447d5f8d18fda.tar.gz busybox-w32-053b1462b72feea51b3b8745662447d5f8d18fda.tar.bz2 busybox-w32-053b1462b72feea51b3b8745662447d5f8d18fda.zip |
Fix a bug pointed out by Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
where you used to see:
./grep -q -i B some_file
B: No such file or directory
This is now fixed.
-Erik
Diffstat (limited to 'findutils/grep.c')
-rw-r--r-- | findutils/grep.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/findutils/grep.c b/findutils/grep.c index bb1a14622..1272a464b 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -39,6 +39,9 @@ | |||
39 | #include <signal.h> | 39 | #include <signal.h> |
40 | #include <time.h> | 40 | #include <time.h> |
41 | #include <ctype.h> | 41 | #include <ctype.h> |
42 | #define BB_DECLARE_EXTERN | ||
43 | #define bb_need_too_few_args | ||
44 | #include "messages.c" | ||
42 | 45 | ||
43 | static const char grep_usage[] = | 46 | static const char grep_usage[] = |
44 | "grep [OPTIONS]... PATTERN [FILE]...\n" | 47 | "grep [OPTIONS]... PATTERN [FILE]...\n" |
@@ -92,7 +95,6 @@ static void do_grep(FILE * fp, char *needle, char *fileName, int tellName, | |||
92 | extern int grep_main(int argc, char **argv) | 95 | extern int grep_main(int argc, char **argv) |
93 | { | 96 | { |
94 | FILE *fp; | 97 | FILE *fp; |
95 | char *cp; | ||
96 | char *needle; | 98 | char *needle; |
97 | char *fileName; | 99 | char *fileName; |
98 | int tellName = TRUE; | 100 | int tellName = TRUE; |
@@ -100,18 +102,14 @@ extern int grep_main(int argc, char **argv) | |||
100 | int tellLine = FALSE; | 102 | int tellLine = FALSE; |
101 | int invertSearch = FALSE; | 103 | int invertSearch = FALSE; |
102 | 104 | ||
103 | argc--; | ||
104 | argv++; | ||
105 | if (argc < 1) { | 105 | if (argc < 1) { |
106 | usage(grep_usage); | 106 | usage(grep_usage); |
107 | } | 107 | } |
108 | argv++; | ||
108 | 109 | ||
109 | if (**argv == '-') { | 110 | while (--argc >= 0 && *argv && (**argv == '-')) { |
110 | argc--; | 111 | while (*++(*argv)) { |
111 | cp = *argv++; | 112 | switch (**argv) { |
112 | |||
113 | while (*++cp) | ||
114 | switch (*cp) { | ||
115 | case 'i': | 113 | case 'i': |
116 | ignoreCase = TRUE; | 114 | ignoreCase = TRUE; |
117 | break; | 115 | break; |
@@ -135,6 +133,12 @@ extern int grep_main(int argc, char **argv) | |||
135 | default: | 133 | default: |
136 | usage(grep_usage); | 134 | usage(grep_usage); |
137 | } | 135 | } |
136 | } | ||
137 | argv++; | ||
138 | } | ||
139 | |||
140 | if (argc == 0 || *argv == NULL) { | ||
141 | fatalError(too_few_args, "grep"); | ||
138 | } | 142 | } |
139 | 143 | ||
140 | needle = *argv++; | 144 | needle = *argv++; |