[Top][All Lists]

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

grep branch, master, updated. v2.18-139-g5122195

From: Paul Eggert
Subject: grep branch, master, updated. v2.18-139-g5122195
Date: Sat, 10 May 2014 08:21:56 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  51221951e4878b57e098db231014ce29ecfc7100 (commit)
      from  a474c789e9dcc4fc21c89311140017b0826abfad (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------

commit 51221951e4878b57e098db231014ce29ecfc7100
Author: Paul Eggert <address@hidden>
Date:   Sat May 10 01:21:15 2014 -0700

    grep: -A 0, -B 0, -C 0 now output a separator
    Problem reported by Dan Jacobson in:
    * NEWS:
    * doc/grep.texi (Context Line Control): Document this.
    * src/grep.c (prtext): Output a separator even if context is zero.
    (main): Default context is now -1, not 0.

diff --git a/NEWS b/NEWS
index 3a20096..685ce9b 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,10 @@ GNU grep NEWS                                    -*- outline 
   grep no longer mishandles an empty pattern at the end of a pattern list.
   [bug introduced in grep-2.5]
+  grep -C NUM now outputs separators consistently even when NUM is zero,
+  and similarly for grep -A NUM and grep -B NUM.
+  [bug present since "the beginning"]
   grep -f no longer mishandles patterns containing NUL bytes.
   [bug introduced in grep-2.11]
diff --git a/doc/grep.texi b/doc/grep.texi
index 59d0d3c..feee0d8 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -532,14 +532,13 @@ Print @var{num} lines of leading and trailing output 
 @opindex --group-separator
 @cindex group separator
 When @option{-A}, @option{-B} or @option{-C} are in use,
-print @var{string} instead of @option{--} around disjoint groups
-of lines.
+print @var{string} instead of @option{--} between groups of lines.
 @item --no-group-separator
 @opindex --group-separator
 @cindex group separator
 When @option{-A}, @option{-B} or @option{-C} are in use,
-print disjoint groups of lines adjacent to each other.
+do not print a separator between groups of lines.
 @end table
@@ -555,26 +554,25 @@ between prefix fields and actual line content.
 Context (i.e., non-matching) lines use @samp{-} instead.
-When no context is specified,
+When context is not specified,
 matching lines are simply output one right after another.
-When nonzero context is specified,
+When context is specified,
 lines that are adjacent in the input form a group
 and are output one right after another, while
-a separator appears by default between disjoint groups on a line
-of its own and without any prefix.
+by default a separator appears between non-adjacent groups.
 The default separator
-is @samp{--}, however whether to include it and its appearance
+is a @samp{--} line; its presence and appearance
 can be changed with the options above.
 Each group may contain
 several matching lines when they are close enough to each other
-that two otherwise adjacent but divided groups connect
-and can just merge into a single contiguous one.
+that two adjacent groups connect and can merge into a single
+contiguous one.
 @end itemize
 @node File and Directory Selection
diff --git a/src/grep.c b/src/grep.c
index 1e3fc28..ec955d8 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1002,7 +1002,8 @@ prtext (char const *beg, char const *lim)
       /* Print the group separator unless the output is adjacent to
          the previous output in the file.  */
-      if ((out_before || out_after) && used && p != lastout && group_separator)
+      if ((0 <= out_before || 0 <= out_after) && used
+          && p != lastout && group_separator)
           pr_sgr_start_if (sep_color);
           fputs (group_separator, stdout);
@@ -1961,7 +1962,7 @@ main (int argc, char **argv)
   /* The value -1 means to use DEFAULT_CONTEXT. */
   out_after = out_before = -1;
   /* Default before/after context: changed by -C/-NUM options */
-  default_context = 0;
+  default_context = -1;
   /* Changed by -o option */
   only_matching = 0;


Summary of changes:
 NEWS          |    4 ++++
 doc/grep.texi |   18 ++++++++----------
 src/grep.c    |    5 +++--
 3 files changed, 15 insertions(+), 12 deletions(-)


reply via email to

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