grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.19-13-gecf3677


From: Jim Meyering
Subject: grep branch, master, updated. v2.19-13-gecf3677
Date: Fri, 30 May 2014 21:43:17 +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  ecf3677de8175689eaad770a8bc849f69576a481 (commit)
      from  96bd3104b76fb157555b60d22eeb71782572ceb0 (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 -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=ecf3677de8175689eaad770a8bc849f69576a481


commit ecf3677de8175689eaad770a8bc849f69576a481
Author: Jim Meyering <address@hidden>
Date:   Fri May 30 09:19:33 2014 -0700

    grep: fix --max-count=N (-m N) to stop reading after Nth match
    
    With --max-count=N (-m N), grep is supposed to stop reading input
    after it has found the Nth match.  However, a recent context-
    related change made it so grep would always read to end of file.
    * src/grep.c (prtext): Don't let a negative "out_after" value
    make "pending" line count negative.
    * tests/max-count-overread: New test, for this.
    * tests/Makefile.am (TESTS): Add it.
    * NEWS (Bug fixes): Mention it.
    * THANKS: Add names of two recent bug reporters.
    This bug was introduced by commit v2.18-139-g5122195.
    Reported by Marc Aldorasi in http://bugs.gnu.org/17640.

diff --git a/NEWS b/NEWS
index 0caad22..6988c9d 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,11 @@ GNU grep NEWS                                    -*- outline 
-*-
 
 ** Bug fixes
 
+  grep --max-count=N FILE would no longer stop reading after the Nth match.
+  I.e., while grep would still print the correct output, it would continue
+  reading until end of input, and hence, potentially forever.
+  [bug introduced in grep-2.19]
+
   A command like echo aa|grep -E 'a(b$|c$)' would mistakenly
   report the input as a matched line.
   [bug introduced in grep-2.19]
diff --git a/THANKS b/THANKS
index 35d22b5..6abd647 100644
--- a/THANKS
+++ b/THANKS
@@ -61,6 +61,7 @@ Keith Bostic               <address@hidden>
 Krishna Sethuraman         <address@hidden>
 Kurt D Schwehr             <address@hidden>
 Ludovic Courtès            <address@hidden>
+Marc Aldorasi              <address@hidden>
 Mark Waite                 <address@hidden>
 Martin P.J. Zinser         <address@hidden>
 Martin Rex                 <address@hidden>
@@ -73,6 +74,7 @@ Olaf Kirch                 <address@hidden>
 Paolo Bonzini              <address@hidden>
 Paul Eggert                <address@hidden>
 Paul Kimoto                <address@hidden>
+Péter Radics               <address@hidden>
 Phillip C. Brisco          <address@hidden>
 Philipp Kohlbecher         <address@hidden>
 Philippe Defert            <address@hidden>
diff --git a/src/grep.c b/src/grep.c
index acc08c7..7c0f8a8 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1043,7 +1043,7 @@ prtext (char const *beg, char const *lim)
     }
 
   after_last_match = bufoffset - (buflim - p);
-  pending = out_quiet ? 0 : out_after;
+  pending = out_quiet ? 0 : MAX (0, out_after);
   used = true;
   outleft -= n;
 }
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a38f074..31e2a81 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -73,6 +73,7 @@ TESTS =                                               \
   invalid-multibyte-infloop                    \
   khadafy                                      \
   long-line-vs-2GiB-read                       \
+  max-count-overread                           \
   max-count-vs-context                         \
   mb-non-UTF8-performance                      \
   multibyte-white-space                                \
diff --git a/tests/max-count-overread b/tests/max-count-overread
new file mode 100755
index 0000000..d7aafd6
--- /dev/null
+++ b/tests/max-count-overread
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Ensure that -m1 stops reading after the first match.
+# In grep-2.19, yes x|grep -m1 x would infloop.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+require_timeout_
+
+fail=0
+
+echo x > exp || framework_failure_
+
+yes x | timeout 3 grep -m1 x > out || fail=1
+compare exp out || fail=1
+
+Exit $fail

-----------------------------------------------------------------------

Summary of changes:
 NEWS                     |    5 +++++
 THANKS                   |    2 ++
 src/grep.c               |    2 +-
 tests/Makefile.am        |    1 +
 tests/max-count-overread |   15 +++++++++++++++
 5 files changed, 24 insertions(+), 1 deletions(-)
 create mode 100755 tests/max-count-overread


hooks/post-receive
-- 
grep



reply via email to

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