aboutsummaryrefslogtreecommitdiff
path: root/findutils/grep.c
diff options
context:
space:
mode:
authorMark Whitley <markw@lineo.com>2000-07-11 16:53:56 +0000
committerMark Whitley <markw@lineo.com>2000-07-11 16:53:56 +0000
commitdf5f6ba1159f8c1af500fa1b8eb9c9646e4de2a6 (patch)
tree90005f171e95b4fc0eefca5171593ba0b105b3f7 /findutils/grep.c
parentda9841efc1e924ab3f645d931ae17c6d4aaf766f (diff)
downloadbusybox-w32-df5f6ba1159f8c1af500fa1b8eb9c9646e4de2a6.tar.gz
busybox-w32-df5f6ba1159f8c1af500fa1b8eb9c9646e4de2a6.tar.bz2
busybox-w32-df5f6ba1159f8c1af500fa1b8eb9c9646e4de2a6.zip
Applied patch from Matt Kraai which does the following:
- adds case-insensitive matching in sed s/// epxressions - consolodates common regcomp code in grep & sed into bb_regcomp and put in utility.c - cleans up a bunch of cruft
Diffstat (limited to 'findutils/grep.c')
-rw-r--r--findutils/grep.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index 8d2c915be..dec365f05 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -104,7 +104,6 @@ extern int grep_main(int argc, char **argv)
104{ 104{
105 int opt; 105 int opt;
106 int reflags; 106 int reflags;
107 int ret;
108 107
109 /* do special-case option parsing */ 108 /* do special-case option parsing */
110 if (argv[1] && (strcmp(argv[1], "--help") == 0)) 109 if (argv[1] && (strcmp(argv[1], "--help") == 0))
@@ -147,20 +146,8 @@ extern int grep_main(int argc, char **argv)
147 reflags = REG_NOSUB | REG_NEWLINE; 146 reflags = REG_NOSUB | REG_NEWLINE;
148 if (ignore_case) 147 if (ignore_case)
149 reflags |= REG_ICASE; 148 reflags |= REG_ICASE;
150 if ((ret = regcomp(&regex, argv[optind], reflags)) != 0) { 149 if (bb_regcomp(&regex, argv[optind], reflags) != 0)
151 int errmsgsz = regerror(ret, &regex, NULL, 0);
152 char *errmsg = malloc(errmsgsz);
153 if (errmsg == NULL) {
154 fprintf(stderr, "grep: memory error\n");
155 regfree(&regex);
156 exit(1);
157 }
158 regerror(ret, &regex, errmsg, errmsgsz);
159 fprintf(stderr, "grep: %s\n", errmsg);
160 free(errmsg);
161 regfree(&regex);
162 exit(1); 150 exit(1);
163 }
164 151
165 /* argv[(optind+1)..(argc-1)] should be names of file to grep through. If 152 /* argv[(optind+1)..(argc-1)] should be names of file to grep through. If
166 * there is more than one file to grep, we will print the filenames */ 153 * there is more than one file to grep, we will print the filenames */