grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.22-8-g413fe0e


From: Paul Eggert
Subject: grep branch, master, updated. v2.22-8-g413fe0e
Date: Thu, 31 Dec 2015 07:23:40 +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  413fe0e603740b9cdeb49d61aa789f7254e13d18 (commit)
      from  5827733ce621bb169afc4f9220cc4624124fc7ba (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=413fe0e603740b9cdeb49d61aa789f7254e13d18


commit 413fe0e603740b9cdeb49d61aa789f7254e13d18
Author: Paul Eggert <address@hidden>
Date:   Wed Dec 30 23:22:36 2015 -0800

    grep: -c should keep counting after binary data
    
    Problem and fix reported by Jaroslav Å karvada, and test case
    reported by Norihiro Tanaka, in: http://bugs.gnu.org/22028
    * NEWS: Document this.
    * src/grep.c (grep): Don't stop counting merely because nulls seen.
    * tests/pcre-count: New file.
    * tests/Makefile.am (TESTS): Add it.

diff --git a/NEWS b/NEWS
index a14597f..4bf408c 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,9 @@ GNU grep NEWS                                    -*- outline 
-*-
   an encoding error in FOO before generating output for FOO.
   [bug introduced in grep-2.21]
 
+  grep -c no longer stops counting when finding binary data.
+  [bug introduced in grep-2.21]
+
   grep -oP is no longer susceptible to an infinite loop when processing
   invalid UTF8 just before a match.
   [bug introduced in grep-2.22]
diff --git a/src/grep.c b/src/grep.c
index e059a46..06f315d 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1397,7 +1397,8 @@ grep (int fd, struct stat const *st)
           has_nulls = true;
           if (binary_files == WITHOUT_MATCH_BINARY_FILES)
             return 0;
-          done_on_match = out_quiet = true;
+          if (!count_matches)
+            done_on_match = out_quiet = true;
           nul_zapper = eol;
           skip_nuls = skip_empty_lines;
         }
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f1b8c43..e8b11b5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -106,6 +106,7 @@ TESTS =                                             \
   pcre                                         \
   pcre-abort                                   \
   pcre-context                                 \
+  pcre-count                                   \
   pcre-infloop                                 \
   pcre-invalid-utf8-infloop                    \
   pcre-invalid-utf8-input                      \
diff --git a/tests/pcre-count b/tests/pcre-count
new file mode 100755
index 0000000..78e1c7c
--- /dev/null
+++ b/tests/pcre-count
@@ -0,0 +1,23 @@
+#! /bin/sh
+# grep -P / grep -Pc are inconsistent results
+# This bug affected grep versions 2.21 through 2.22.
+#
+# Copyright (C) 2015 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+require_pcre_
+
+fail=0
+
+printf 'a\n%032768d\nb\x0\n%032768d\na\n' 0 0 > in
+
+LC_ALL=C grep -P 'a' in | wc -l > exp
+
+LC_ALL=C grep -Pc 'a' in > out ||  fail=1
+compare exp out || fail=1
+
+Exit $fail

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

Summary of changes:
 NEWS              |    3 +++
 src/grep.c        |    3 ++-
 tests/Makefile.am |    1 +
 tests/pcre-count  |   23 +++++++++++++++++++++++
 4 files changed, 29 insertions(+), 1 deletions(-)
 create mode 100755 tests/pcre-count


hooks/post-receive
-- 
grep



reply via email to

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