diff --git a/grep-2.21-Pc-consistent-results.patch b/grep-2.21-Pc-consistent-results.patch index dd2fd36..eab6d5b 100644 --- a/grep-2.21-Pc-consistent-results.patch +++ b/grep-2.21-Pc-consistent-results.patch @@ -1,25 +1,81 @@ diff --git a/src/grep.c b/src/grep.c -index 50a9868..e2c4daa 100644 +index 6f18c1b..859ec27 100644 --- a/src/grep.c +++ b/src/grep.c -@@ -1368,13 +1368,13 @@ grep (int fd, struct stat const *st) +@@ -1339,7 +1339,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; } - - /* 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; +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 47b9883..1b2281d 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -91,6 +91,7 @@ TESTS = \ + options \ + pcre \ + pcre-abort \ ++ pcre-count \ + pcre-infloop \ + pcre-invalid-utf8-input \ + pcre-o \ +diff --git a/tests/Makefile.in b/tests/Makefile.in +index 4aaebdf..0f40547 100644 +--- a/tests/Makefile.in ++++ b/tests/Makefile.in +@@ -1395,6 +1395,7 @@ TESTS = \ + options \ + pcre \ + pcre-abort \ ++ pcre-count \ + pcre-infloop \ + pcre-invalid-utf8-input \ + pcre-o \ +@@ -2166,6 +2167,13 @@ pcre-abort.log: pcre-abort + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) ++pcre-count.log: pcre-count ++ @p='pcre-count'; \ ++ b='pcre-count'; \ ++ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ ++ --log-file $$b.log --trs-file $$b.trs \ ++ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ ++ "$$tst" $(AM_TESTS_FD_REDIRECT) + pcre-infloop.log: pcre-infloop + @p='pcre-infloop'; \ + b='pcre-infloop'; \ +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. + -+ /* 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; ++. "${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 diff --git a/grep-2.21-better-encoding-errors-handling.patch b/grep-2.21-better-encoding-errors-handling.patch index d53cfe6..953a92e 100644 --- a/grep-2.21-better-encoding-errors-handling.patch +++ b/grep-2.21-better-encoding-errors-handling.patch @@ -1,5 +1,5 @@ diff --git a/src/grep.c b/src/grep.c -index e2c4daa..6f18c1b 100644 +index 50a9868..6f18c1b 100644 --- a/src/grep.c +++ b/src/grep.c @@ -351,7 +351,6 @@ bool match_icase; @@ -422,18 +422,22 @@ index e2c4daa..6f18c1b 100644 lastnl = bufbeg; if (lastout) lastout = bufbeg; -@@ -1371,11 +1397,6 @@ grep (int fd, struct stat const *st) - if (beg != lastout) - lastout = 0; +@@ -1368,13 +1394,8 @@ 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; - if (out_byte) @@ -1387,22 +1408,6 @@ grep (int fd, struct stat const *st) suppressible_error (filename, errno); goto finish_grep; @@ -581,30 +585,30 @@ index 5451029..ef2f241 100644 { beg = line_start; diff --git a/tests/Makefile.am b/tests/Makefile.am -index 2f69835..15587aa 100644 +index 2f69835..47b9883 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am -@@ -84,6 +84,7 @@ TESTS = \ - multiple-begin-or-end-line \ - null-byte \ - empty-line-mb \ +@@ -55,6 +55,7 @@ TESTS = \ + dfaexec-multibyte \ + empty \ + empty-line \ + encoding-error \ - unibyte-bracket-expr \ - unibyte-negated-circumflex \ - high-bit-range \ + epipe \ + equiv-classes \ + ere \ diff --git a/tests/Makefile.in b/tests/Makefile.in -index 4e843bf..64f3cd6 100644 +index 4e843bf..4aaebdf 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in -@@ -1388,6 +1388,7 @@ TESTS = \ - multiple-begin-or-end-line \ - null-byte \ - empty-line-mb \ +@@ -1359,6 +1359,7 @@ TESTS = \ + dfaexec-multibyte \ + empty \ + empty-line \ + encoding-error \ - unibyte-bracket-expr \ - unibyte-negated-circumflex \ - high-bit-range \ -@@ -2116,6 +2117,13 @@ empty-line-mb.log: empty-line-mb + epipe \ + equiv-classes \ + ere \ +@@ -1913,6 +1914,13 @@ empty-line.log: empty-line --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @@ -615,9 +619,9 @@ index 4e843bf..64f3cd6 100644 + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) - unibyte-bracket-expr.log: unibyte-bracket-expr - @p='unibyte-bracket-expr'; \ - b='unibyte-bracket-expr'; \ + epipe.log: epipe + @p='epipe'; \ + b='epipe'; \ diff --git a/tests/encoding-error b/tests/encoding-error new file mode 100755 index 0000000..fe52de2 diff --git a/grep.spec b/grep.spec index 3524a1c..39305de 100644 --- a/grep.spec +++ b/grep.spec @@ -3,7 +3,7 @@ Summary: Pattern matching utilities Name: grep Version: 2.21 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv3+ Group: Applications/Text Source: ftp://ftp.gnu.org/pub/gnu/grep/grep-%{version}.tar.xz @@ -20,10 +20,10 @@ 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 # backported from upstream -Patch5: grep-2.21-better-encoding-errors-handling.patch +Patch4: grep-2.21-better-encoding-errors-handling.patch +# backported from upstream, upstream bug#22028 +Patch5: grep-2.21-Pc-consistent-results.patch URL: http://www.gnu.org/software/grep/ Requires(post): /sbin/install-info Requires(preun): /sbin/install-info @@ -46,11 +46,12 @@ 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 -%patch5 -p1 -b .better-encoding-errors-handling +%patch4 -p1 -b .better-encoding-errors-handling +%patch5 -p1 -b .Pc-consistent-results chmod 755 tests/kwset-abuse chmod 755 tests/encoding-error +chmod 755 tests/pcre-count %build %global BUILD_FLAGS $RPM_OPT_FLAGS @@ -106,6 +107,11 @@ fi %{_libexecdir}/grepconf.sh %changelog +* Wed Jan 6 2016 Jaroslav Škarvada - 2.21-8 +- Used latest upstream patch for bug 1269014 to fix regression, + fixed order of patches + Resolves: rhbz#1269014 + * Tue Jan 5 2016 Jaroslav Škarvada - 2.21-7 - Improved encoding errors handling (by better-encoding-errors-handling patch) Resolves: rhbz#1219141