Fixed grep to be consistent in 'grep -Pc' and 'grep -P | wc -l'

Resolves: rhbz#1269014
This commit is contained in:
Jaroslav Škarvada 2015-12-01 15:51:29 +01:00
parent ba174f15d5
commit a403fe66ef
2 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,24 @@
diff --git a/src/grep.c b/src/grep.c
--- a/src/grep.c
+++ b/src/grep.c
@@ -1415,13 +1415,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;

View File

@ -3,7 +3,7 @@
Summary: Pattern matching utilities
Name: grep
Version: 2.22
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv3+
URL: http://www.gnu.org/software/grep/
Group: Applications/Text
@ -18,6 +18,8 @@ Patch0: grep-2.22-man-fix-gs.patch
# upstream ticket 39445
Patch1: grep-2.22-help-align.patch
Patch2: grep-2.22-disable-performance-related-tests.patch
# backported from upstream, upstream bug#22028
Patch3: grep-2.22-Pc-consistent-results.patch
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.
# to measured runtime, which doesn't work reliable on the builders with
# variable load.
%patch2 -p1 -b .disable-performance-related-tests
%patch3 -p1 -b .Pc-consistent-results
chmod 755 tests/kwset-abuse
@ -94,6 +97,10 @@ fi
%{_libexecdir}/grepconf.sh
%changelog
* Tue Dec 1 2015 Jaroslav Škarvada <jskarvad@redhat.com> - 2.22-3
- Fixed grep to be consistent in 'grep -Pc' and 'grep -P | wc -l'
Resolves: rhbz#1269014
* Thu Nov 5 2015 Jaroslav Škarvada <jskarvad@redhat.com> - 2.22-2
- Disabled performance related tests
(by disable-performance-related-tests patch), patch backported from upstream