aboutsummaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-03-23 12:12:03 +0000
committerRon Yorston <rmy@pobox.com>2012-03-23 12:12:03 +0000
commitb0f54743e36af163ae2530c381c485bb29df13dc (patch)
treecda4cfeaae6e47fe4f14c1b566092be4da9affc4 /findutils
parent40514a0309939f2446f0d4ed9600cad5de396e7f (diff)
parentba88826c66411affc1da3614742b454654f7298a (diff)
downloadbusybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.tar.gz
busybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.tar.bz2
busybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.zip
Merge branch 'busybox' into merge
Conflicts: Makefile.flags
Diffstat (limited to 'findutils')
-rw-r--r--findutils/grep.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index f3463f94e..5b8ae3bff 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -85,6 +85,7 @@
85//usage: "\n -r Recurse" 85//usage: "\n -r Recurse"
86//usage: "\n -i Ignore case" 86//usage: "\n -i Ignore case"
87//usage: "\n -w Match whole words only" 87//usage: "\n -w Match whole words only"
88//usage: "\n -x Match whole lines only"
88//usage: "\n -F PATTERN is a literal (not regexp)" 89//usage: "\n -F PATTERN is a literal (not regexp)"
89//usage: IF_FEATURE_GREP_EGREP_ALIAS( 90//usage: IF_FEATURE_GREP_EGREP_ALIAS(
90//usage: "\n -E PATTERN is an extended regexp" 91//usage: "\n -E PATTERN is an extended regexp"
@@ -113,7 +114,7 @@
113//usage:#define fgrep_full_usage "" 114//usage:#define fgrep_full_usage ""
114 115
115#define OPTSTR_GREP \ 116#define OPTSTR_GREP \
116 "lnqvscFiHhe:f:Lorm:w" \ 117 "lnqvscFiHhe:f:Lorm:wx" \
117 IF_FEATURE_GREP_CONTEXT("A:B:C:") \ 118 IF_FEATURE_GREP_CONTEXT("A:B:C:") \
118 IF_FEATURE_GREP_EGREP_ALIAS("E") \ 119 IF_FEATURE_GREP_EGREP_ALIAS("E") \
119 IF_EXTRA_COMPAT("z") \ 120 IF_EXTRA_COMPAT("z") \
@@ -138,6 +139,7 @@ enum {
138 OPTBIT_r, /* recurse dirs */ 139 OPTBIT_r, /* recurse dirs */
139 OPTBIT_m, /* -m MAX_MATCHES */ 140 OPTBIT_m, /* -m MAX_MATCHES */
140 OPTBIT_w, /* -w whole word match */ 141 OPTBIT_w, /* -w whole word match */
142 OPTBIT_x, /* -x whole line match */
141 IF_FEATURE_GREP_CONTEXT( OPTBIT_A ,) /* -A NUM: after-match context */ 143 IF_FEATURE_GREP_CONTEXT( OPTBIT_A ,) /* -A NUM: after-match context */
142 IF_FEATURE_GREP_CONTEXT( OPTBIT_B ,) /* -B NUM: before-match context */ 144 IF_FEATURE_GREP_CONTEXT( OPTBIT_B ,) /* -B NUM: before-match context */
143 IF_FEATURE_GREP_CONTEXT( OPTBIT_C ,) /* -C NUM: -A and -B combined */ 145 IF_FEATURE_GREP_CONTEXT( OPTBIT_C ,) /* -C NUM: -A and -B combined */
@@ -160,6 +162,7 @@ enum {
160 OPT_r = 1 << OPTBIT_r, 162 OPT_r = 1 << OPTBIT_r,
161 OPT_m = 1 << OPTBIT_m, 163 OPT_m = 1 << OPTBIT_m,
162 OPT_w = 1 << OPTBIT_w, 164 OPT_w = 1 << OPTBIT_w,
165 OPT_x = 1 << OPTBIT_x,
163 OPT_A = IF_FEATURE_GREP_CONTEXT( (1 << OPTBIT_A)) + 0, 166 OPT_A = IF_FEATURE_GREP_CONTEXT( (1 << OPTBIT_A)) + 0,
164 OPT_B = IF_FEATURE_GREP_CONTEXT( (1 << OPTBIT_B)) + 0, 167 OPT_B = IF_FEATURE_GREP_CONTEXT( (1 << OPTBIT_B)) + 0,
165 OPT_C = IF_FEATURE_GREP_CONTEXT( (1 << OPTBIT_C)) + 0, 168 OPT_C = IF_FEATURE_GREP_CONTEXT( (1 << OPTBIT_C)) + 0,
@@ -378,9 +381,12 @@ static int grep_file(FILE *file)
378 &gl->matched_range) >= 0 381 &gl->matched_range) >= 0
379#endif 382#endif
380 ) { 383 ) {
381 if (!(option_mask32 & OPT_w)) 384 if (option_mask32 & OPT_x) {
385 found = (gl->matched_range.rm_so == 0
386 && line[gl->matched_range.rm_eo] == '\0');
387 } else if (!(option_mask32 & OPT_w)) {
382 found = 1; 388 found = 1;
383 else { 389 } else {
384 char c = ' '; 390 char c = ' ';
385 if (gl->matched_range.rm_so) 391 if (gl->matched_range.rm_so)
386 c = line[gl->matched_range.rm_so - 1]; 392 c = line[gl->matched_range.rm_so - 1];