From c7e5c9ff072d7a3113633025734614bb30018360 Mon Sep 17 00:00:00 2001 From: Jaroslav Škarvada Date: Dec 02 2015 09:39:54 +0000 Subject: Fixed grep to be consistent in 'grep -Pc' and 'grep -P | wc -l' Resolves: rhbz#1269014 --- diff --git a/grep-2.21-Pc-consistent-results.patch b/grep-2.21-Pc-consistent-results.patch new file mode 100644 index 0000000..dd2fd36 --- /dev/null +++ b/grep-2.21-Pc-consistent-results.patch @@ -0,0 +1,25 @@ +diff --git a/src/grep.c b/src/grep.c +index 50a9868..e2c4daa 100644 +--- a/src/grep.c ++++ b/src/grep.c +@@ -1368,13 +1368,13 @@ grep (int fd, struct stat const *st) + } + + /* Detect whether leading context is adjacent to previous output. */ +- if (lastout) +- { +- if (textbin == TEXTBIN_UNKNOWN) +- textbin = TEXTBIN_TEXT; +- if (beg != lastout) +- lastout = 0; +- } ++ if (beg != lastout) ++ lastout = 0; ++ ++ /* If the file's textbin has not been determined yet, assume ++ it's text if has found any matched line already. */ ++ if (textbin == TEXTBIN_UNKNOWN && nlines) ++ textbin = TEXTBIN_TEXT; + + /* Handle some details and read more data to scan. */ + save = residue + lim - beg; diff --git a/grep.spec b/grep.spec index 998fa1d..f6962bc 100644 --- a/grep.spec +++ b/grep.spec @@ -3,7 +3,7 @@ Summary: Pattern matching utilities Name: grep Version: 2.21 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv3+ Group: Applications/Text Source: ftp://ftp.gnu.org/pub/gnu/grep/grep-%{version}.tar.xz @@ -20,6 +20,8 @@ Patch2: grep-2.21-buf-overrun-fix.patch # backported from upstream # http://git.savannah.gnu.org/cgit/grep.git/commit/?id=c8b9364d5900a40809827aee6cc53705073278f6 Patch3: grep-2.21-recurse-behaviour-change-doc.patch +# backported from upstream, upstream bug#22028 +Patch4: grep-2.21-Pc-consistent-results.patch URL: http://www.gnu.org/software/grep/ Requires(post): /sbin/install-info Requires(preun): /sbin/install-info @@ -42,6 +44,7 @@ GNU grep is needed by many scripts, so it shall be installed on every system. %patch1 -p1 -b .help-align %patch2 -p1 -b .buf-overrun-fix %patch3 -p1 -b .recurse-behaviour-change-doc +%patch4 -p1 -b .Pc-consistent-results chmod 755 tests/kwset-abuse @@ -99,6 +102,10 @@ fi %{_libexecdir}/grepconf.sh %changelog +* Wed Dec 2 2015 Jaroslav Škarvada - 2.21-6 +- Fixed grep to be consistent in 'grep -Pc' and 'grep -P | wc -l' + Resolves: rhbz#1269014 + * Tue Apr 7 2015 Jaroslav Škarvada - 2.21-5 - Documented change in behaviour of recurse option Resolves: rhbz#1178305