bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch: non-empty matches following empty ones


From: Charles Levert
Subject: Re: Patch: non-empty matches following empty ones
Date: Tue, 23 Aug 2005 11:53:00 -0400
User-agent: Mutt/1.4.1i

* On Tuesday 2005-08-23 at 11:22:08 -0400, Charles Levert wrote:
> * On Tuesday 2005-08-23 at 16:24:05 +0200, Stepan Kasal wrote:
> > 
> > OK, I no longer object to it.  But please change the decumentation
> > (info and manpage) so that it states this clearly.
> 
> Ok.  I will put this under --only-matching and --color.

Here's what I intend to commit for the
documentation (the code and tests are unchanged
from my last posted patch).


Index: grep/ChangeLog
===================================================================
RCS file: /cvsroot/grep/grep/ChangeLog,v
retrieving revision 1.270
diff -u -r1.270 ChangeLog
--- grep/ChangeLog      27 Jul 2005 02:44:53 -0000      1.270
+++ grep/ChangeLog      23 Aug 2005 15:40:20 -0000
@@ -1,3 +1,15 @@
+2005-08-23  Charles Levert  <address@hidden>
+
+       * src/grep.c (print_line_middle): In case of an empty match,
+         make minimal progress and continue instead of aborting process
+         of the remainder of the line, in case there's still an upcoming
+         non-empty match.
+       * tests/foad1.sh: Add two tests for this.
+       * doc/grep.texi, doc/grep.1: Document this behavior, since
+         --only-matching and --color are GNU extensions which are
+         otherwise unspecified by POSIX or other standards.  Warn users
+         against using patterns that produce zero-length matches.
+
 2005-07-26  Charles Levert  <address@hidden>
 
        * tests/pcre.sh: New file.  Add test 1.
Index: grep/doc/grep.texi
===================================================================
RCS file: /cvsroot/grep/grep/doc/grep.texi,v
retrieving revision 1.55
diff -u -r1.55 grep.texi
--- grep/doc/grep.texi  5 Jul 2005 01:03:32 -0000       1.55
+++ grep/doc/grep.texi  23 Aug 2005 15:40:41 -0000
@@ -191,6 +191,11 @@
 @opindex --only-matching
 @cindex only matching
 Print only the part of matching lines that actually matches @var{pattern}.
+Note that zero-length matches will be ignored,
+even though patterns such as @samp{a*}
+or the empty pattern @samp{}
+normally cause every line to match;
+such patterns should generally be avoided anyway.
 
 @item -q
 @itemx --quiet
@@ -279,6 +284,11 @@
 but its setting does not have priority; it defaults to `01;31' (bold red)
 which only covers the color for matched text.
 @var{WHEN} is `never', `always', or `auto'.
+Note that zero-length matches will not be colorized as matching strings,
+even though patterns such as @samp{a*}
+or the empty pattern @samp{}
+will cause every line to match;
+such patterns should generally be avoided anyway.
 
 @item address@hidden
 @opindex -NUM
Index: grep/doc/grep.1
===================================================================
RCS file: /cvsroot/grep/grep/doc/grep.1,v
retrieving revision 1.32
diff -u -r1.32 grep.1
--- grep/doc/grep.1     5 Jul 2005 01:03:33 -0000       1.32
+++ grep/doc/grep.1     23 Aug 2005 15:40:48 -0000
@@ -138,6 +138,13 @@
 is still supported, but its setting does not have priority.
 .I WHEN
 is `never', `always', or `auto'.
+Note that zero-length matches will not be colorized as matching strings,
+even though patterns such as
+.B 'a*'
+or the empty pattern
+.B ''
+will cause every line to match;
+such patterns should generally be avoided anyway.
 .TP
 .BR \-c ", " \-\^\-count
 Suppress normal output; instead print a count of
@@ -316,6 +323,13 @@
 .BR \-o ", " \-\^\-only-matching
 Show only the part of a matching line that matches
 .IR PATTERN .
+Note that zero-length matches will be ignored,
+even though patterns such as
+.B 'a*'
+or the empty pattern
+.B ''
+normally cause every line to match;
+such patterns should generally be avoided anyway.
 .TP
 .BR \-P ", " \-\^\-perl-regexp
 .RI "Interpret " PATTERN " as a Perl regular expression."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]