diff options
author | Mark Whitley <markw@lineo.com> | 2000-07-10 15:50:26 +0000 |
---|---|---|
committer | Mark Whitley <markw@lineo.com> | 2000-07-10 15:50:26 +0000 |
commit | 44735f874437ee4b570a6780c1f879de80e80fdc (patch) | |
tree | 468f03558df985a32c0631338c7a64c5919da92b | |
parent | 999bf72f49a501e47448010c4ddb06dc03ed1612 (diff) | |
download | busybox-w32-44735f874437ee4b570a6780c1f879de80e80fdc.tar.gz busybox-w32-44735f874437ee4b570a6780c1f879de80e80fdc.tar.bz2 busybox-w32-44735f874437ee4b570a6780c1f879de80e80fdc.zip |
Applied patch from Matt Kraai as per his email:
However, the case of
grep foo$ file
didn't work, due to a problem with the flags used in regular expression
compilation. The attached patch fixes this problem.
---patch-------
Index: grep.c
===================================================================
RCS file: /var/cvs/busybox/grep.c,v
retrieving revision 1.30
diff -u -r1.30 grep.c
--- grep.c 2000/07/04 22:17:01 1.30
+++ grep.c 2000/07/10 08:57:04
@@ -141,8 +141,10 @@
if (argv[optind] == NULL)
usage(grep_usage);
- /* compile the regular expression */
- reflags = REG_NOSUB; /* we're not going to mess with sub-expressions
*/
+ /* compile the regular expression
+ * we're not going to mess with sub-expressions, and we need to
+ * treat newlines right. */
+ reflags = REG_NOSUB | REG_NEWLINE;
if (ignore_case)
reflags |= REG_ICASE;
if ((ret = regcomp(®ex, argv[optind], reflags)) != 0) {
---patch-------
Thanks, Matt, it works great.
-rw-r--r-- | findutils/grep.c | 6 | ||||
-rw-r--r-- | grep.c | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/findutils/grep.c b/findutils/grep.c index 05bf8b8cf..8d2c915be 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -141,8 +141,10 @@ extern int grep_main(int argc, char **argv) | |||
141 | if (argv[optind] == NULL) | 141 | if (argv[optind] == NULL) |
142 | usage(grep_usage); | 142 | usage(grep_usage); |
143 | 143 | ||
144 | /* compile the regular expression */ | 144 | /* compile the regular expression |
145 | reflags = REG_NOSUB; /* we're not going to mess with sub-expressions */ | 145 | * we're not going to mess with sub-expressions, and we need to |
146 | * treat newlines right. */ | ||
147 | reflags = REG_NOSUB | REG_NEWLINE; | ||
146 | if (ignore_case) | 148 | if (ignore_case) |
147 | reflags |= REG_ICASE; | 149 | reflags |= REG_ICASE; |
148 | if ((ret = regcomp(®ex, argv[optind], reflags)) != 0) { | 150 | if ((ret = regcomp(®ex, argv[optind], reflags)) != 0) { |
@@ -141,8 +141,10 @@ extern int grep_main(int argc, char **argv) | |||
141 | if (argv[optind] == NULL) | 141 | if (argv[optind] == NULL) |
142 | usage(grep_usage); | 142 | usage(grep_usage); |
143 | 143 | ||
144 | /* compile the regular expression */ | 144 | /* compile the regular expression |
145 | reflags = REG_NOSUB; /* we're not going to mess with sub-expressions */ | 145 | * we're not going to mess with sub-expressions, and we need to |
146 | * treat newlines right. */ | ||
147 | reflags = REG_NOSUB | REG_NEWLINE; | ||
146 | if (ignore_case) | 148 | if (ignore_case) |
147 | reflags |= REG_ICASE; | 149 | reflags |= REG_ICASE; |
148 | if ((ret = regcomp(®ex, argv[optind], reflags)) != 0) { | 150 | if ((ret = regcomp(®ex, argv[optind], reflags)) != 0) { |