Compare commits

...
Sign in to create a new pull request.

65 commits

Author SHA1 Message Date
Fedora Release Engineering
c2b244d3c0 Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild 2025-07-24 16:36:19 +00:00
Jaroslav Škarvada
011251225e New version
Resolves: rhbz#2358901
2025-04-14 15:18:50 +02:00
Fedora Release Engineering
1954ef093a Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild 2025-01-17 05:09:04 +00:00
Fedora Release Engineering
cde76d400c Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild 2024-07-18 08:34:10 +00:00
Lukáš Zaoral
ac5028cd3a
remove redundant dependency on libsigsegv
Resolves: RHEL-34664
2024-04-29 09:45:41 +02:00
Fedora Release Engineering
f8e0174a60 Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-24 21:00:22 +00:00
Fedora Release Engineering
22c850bbbc Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-20 21:29:14 +00:00
Jaroslav Škarvada
37218d9a1c Updated SPDX license expression 2023-08-10 15:29:12 +02:00
Jaroslav Škarvada
1a6403d1ac Converted license to SPDX 2023-08-09 21:32:31 +02:00
Fedora Release Engineering
0499c5d10b Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-07-20 05:33:04 +00:00
Jaroslav Škarvada
d31abab5f7 Fixed egrep/fgrep aliases
Resolves: rhbz#2215713
2023-07-13 17:36:06 +02:00
Jaroslav Škarvada
799f88f953 Temporally dropped y2038-vs-32-bit test
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2023-06-09 09:06:25 +02:00
Jaroslav Škarvada
366db98e1c Workaround for FTBFS with glibc-2.37.9000
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2023-06-09 01:52:04 +02:00
Jaroslav Škarvada
29a85be178 New version
Resolves: rhbz#2181063
2023-06-09 00:49:21 +02:00
Jaroslav Škarvada
d59a190ef2 New version
Resolves: rhbz#2181063

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2023-03-23 15:55:07 +01:00
Jaroslav Škarvada
1d8b4cd378 New version
Resolves: rhbz#2175526
Added sources verification
2023-03-07 16:33:37 +01:00
Fedora Release Engineering
090a9ef808 Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-01-19 11:30:27 +00:00
Florian Weimer
e9c80f0c51 Fix C99 compatibility issue in the configure script
Related to:

  <https://fedoraproject.org/wiki/Changes/PortingToModernC>
  <https://fedoraproject.org/wiki/Toolchain/PortingToModernC>
2023-01-03 15:52:33 +01:00
Jaroslav Škarvada
d45159f404 New version
Resolves: rhbz#2123935
Switchd to pcre2
  Resolves: rhbz#1755491
2022-09-05 21:03:43 +02:00
Fedora Release Engineering
627ec9a8a0 Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-07-21 13:00:49 +00:00
Davide Cavalca
862175cb6e Gate perl-FileHandle dependency to f33 onwards 2022-04-11 11:48:38 -07:00
Frantisek Hrdina
6b4e0363ea Adding fmf plan + gating.yaml 2022-04-08 09:11:44 +02:00
Fedora Release Engineering
8ea095f9f4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-01-20 11:45:32 +00:00
Jaroslav Škarvada
6340b1ed95 New version
Resolves: rhbz#1993631
Temporarily switch to the included regex until glibc bug (glibc#11053)
  is fixed
2021-08-16 22:10:32 +02:00
Fedora Release Engineering
817c2146f6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2021-07-22 07:04:53 +00:00
Jaroslav Škarvada
993a74637b Fixed stack overflow detection 2021-06-23 20:15:24 +02:00
Fedora Release Engineering
75261469b1 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2021-01-26 12:56:32 +00:00
Robert Scheck
cbb1010aa0 Spec file cleanup 2021-01-18 00:56:44 +00:00
Tom Stellard
261a1f8c57 Add BuildRequires: make
https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot
2020-12-19 00:04:59 +00:00
Jaroslav Škarvada
69bf7800ad Added sources
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2020-11-09 19:55:56 +01:00
Jaroslav Škarvada
9b15985878 New version
Resolves: rhbz#1895797
2020-11-09 19:49:28 +01:00
Jaroslav Škarvada
15ff98af0f New version
Resolves: rhbz#1883086
2020-09-30 11:16:12 +02:00
Adam Williamson
509816512b Remove some non-portable tests that fail on armv7hl (Paul Eggert) 2020-08-28 11:00:47 -07:00
Adam Williamson
28284b81d5 Backport fix for upstream #28105 to fix zgrep (#1872913) 2020-08-26 16:28:20 -07:00
Fedora Release Engineering
e2669b9096 - Second attempt - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-08-01 03:22:11 +00:00
Fedora Release Engineering
6d293fcd02 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-07-28 00:19:51 +00:00
Tom Stellard
d8e43283bf Use make macros
https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
2020-07-13 19:57:22 +00:00
Jaroslav Škarvada
02c652ed71 New version
Resolves: rhbz#1818417
Added all glibc langpacks to allow more locale sensitive tests to run
Added perl-FileHandle requirement for the filename-lineno.pl test
2020-04-01 23:32:31 +02:00
Fedora Release Engineering
a1aae7177d - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-01-29 03:30:32 +00:00
Fedora Release Engineering
25e281cfda - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-07-25 07:43:16 +00:00
Björn Esser
04da6a4ea9
Remove hardcoded gzip suffix from GNU info pages 2019-04-24 14:56:33 +02:00
Jaroslav Škarvada
8cacf1c7ad New version
Resolves: rhbz#1698044
Updated patches
Dropped glibc-2.28-fix patch (not needed)
2019-04-10 11:13:55 +02:00
Fedora Release Engineering
c7109643eb - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-02-01 01:32:06 +00:00
Jaroslav Škarvada
78e9cd1f16 Fixed FTBFS with glibc-2.28
Resolves: rhbz#1604263
2018-08-09 16:44:48 +02:00
Peter Robinson
3ada89752b drop group# 2018-07-17 17:19:58 +01:00
Fedora Release Engineering
5e51d319e6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-07-13 04:30:14 +00:00
Igor Gnatenko
f46bfb5048 add BuildRequires: gcc
Reference: https://fedoraproject.org/wiki/Changes/Remove_GCC_from_BuildRoot
2018-07-09 19:06:45 +02:00
Jaroslav Škarvada
67e410dbfb Dropped install-info 2018-06-19 23:27:33 +02:00
Fedora Release Engineering
d21284058e - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-02-07 15:24:36 +00:00
Jaroslav Škarvada
40e1f55e50 Moved binaries to /usr/bin
Resolves: rhbz#1540485
2018-02-02 16:38:51 +01:00
Fedora Release Engineering
eccebfff98 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild 2017-08-02 23:02:30 +00:00
Fedora Release Engineering
7001f43fc9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild 2017-07-26 12:01:34 +00:00
Jaroslav Škarvada
501f9e6d87 New version
Related: rhbz#1421129
Updated patches
2017-07-03 11:40:34 +02:00
Jaroslav Škarvada
c232695f40 New version
Resolves: rhbz#1421129
2017-02-10 14:23:23 +01:00
Jaroslav Škarvada
f347452d64 New version
Resolves: rhbz#1419921
De-fuzzified patches
2017-02-08 10:58:15 +01:00
Jaroslav Škarvada
ef9d479716 New version
Resolves: rhbz#1402379
- De-fuzzified patches
2016-12-07 14:47:11 +01:00
Jaroslav Škarvada
98c2bb4a4e Re-enabled 'make check', glibc seems fixed 2016-10-05 14:08:35 +02:00
Jaroslav Škarvada
580b49d7de New version
Resolves: rhbz#1381203
- Disabled 'make check' due to glibc bug rhbz#1381582
2016-10-04 16:19:57 +02:00
Jaroslav Škarvada
94556aeb63 New version
Resolves: rhbz#1381203
2016-10-03 23:21:46 +02:00
Jaroslav Škarvada
35d524dfdb Added sources
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2016-04-22 14:36:43 +02:00
Jaroslav Škarvada
57d1bb00e2 New version
Resolves: rhbz#1329627
- De-fuzzified patches
2016-04-22 14:34:07 +02:00
Jaroslav Škarvada
7f4c49be53 New version
Resolves: rhbz#1316890
2016-03-11 14:23:28 +01:00
Jaroslav Škarvada
b6f43d343c Renamed patches to match grep version they are based on
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2016-02-05 16:08:12 +01:00
Jaroslav Škarvada
08a2c56622 New version
Resolves: rhbz#1305035
- Dropped disable-performance-related-tests, better-encoding-errors-handling,
  Pc-consistent-results, and test-pcre-count-fix patches (all upstreamed)
- De-fuzzified man-fx-gs, and help-align patches
2016-02-05 16:01:05 +01:00
Dennis Gilmore
9cc608b66b - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild 2016-02-03 23:17:58 +00:00
17 changed files with 3972 additions and 1017 deletions

1
.fmf/version Normal file
View file

@ -0,0 +1 @@
1

3
.gitignore vendored
View file

@ -1 +1,2 @@
grep-*.tar.xz
/grep-*.tar.xz
/grep-*.tar.xz.sig

View file

@ -7,5 +7,5 @@ if ( $status == 1 ) then
endif
alias grep 'grep --color=auto'
alias egrep 'egrep --color=auto'
alias fgrep 'fgrep --color=auto'
alias egrep 'grep -E --color=auto'
alias fgrep 'grep -F --color=auto'

View file

@ -3,5 +3,5 @@
/usr/libexec/grepconf.sh -c || return
alias grep='grep --color=auto' 2>/dev/null
alias egrep='egrep --color=auto' 2>/dev/null
alias fgrep='fgrep --color=auto' 2>/dev/null
alias egrep='grep -E --color=auto' 2>/dev/null
alias fgrep='grep -F --color=auto' 2>/dev/null

16
gating.yaml Normal file
View file

@ -0,0 +1,16 @@
--- !Policy
product_versions:
- fedora-*
decision_contexts: [bodhi_update_push_testing]
subject_type: koji_build
rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}
#gating rawhide
--- !Policy
product_versions:
- fedora-*
decision_contexts: [bodhi_update_push_stable]
subject_type: koji_build
rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}

View file

@ -1,81 +0,0 @@
diff --git a/src/grep.c b/src/grep.c
index eac540a..9fabeb8 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1386,7 +1386,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 2ade5be..2079ae5 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-input \
pcre-jitstack \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index b5bd7b5..ee516da 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1442,6 +1442,7 @@ TESTS = \
pcre \
pcre-abort \
pcre-context \
+ pcre-count \
pcre-infloop \
pcre-invalid-utf8-input \
pcre-jitstack \
@@ -2250,6 +2251,13 @@ pcre-context.log: pcre-context
--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.
+
+. "${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

View file

@ -1,703 +0,0 @@
diff --git a/doc/grep.texi b/doc/grep.texi
index e3495bb..41f4fa5 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -596,13 +596,13 @@ If a file's allocation metadata,
or if its data read before a line is selected for output,
indicate that the file contains binary data,
assume that the file is of type @var{type}.
-Non-text bytes indicate binary data; these are either data bytes
-improperly encoded for the current locale, or null bytes when the
+Non-text bytes indicate binary data; these are either output bytes that are
+improperly encoded for the current locale, or null input bytes when the
@option{-z} (@option{--null-data}) option is not given (@pxref{Other
Options}).
-By default, @var{type} is @samp{binary},
-and @command{grep} normally outputs either
+By default, @var{type} is @samp{binary}, and when @command{grep}
+discovers that a file is binary it normally outputs either
a one-line message saying that a binary file matches,
or no message if there is no match.
When processing binary data, @command{grep} may treat non-text bytes
@@ -611,7 +611,8 @@ not match a null byte, as the null byte might be treated as a line
terminator even without the @option{-z} (@option{--null-data}) option.
If @var{type} is @samp{without-match},
-@command{grep} assumes that a binary file does not match;
+when @command{grep} discovers that a file is binary
+it assumes that the rest of the file does not match;
this is equivalent to the @option{-I} option.
If @var{type} is @samp{text},
diff --git a/src/grep.c b/src/grep.c
index 2748fd3..eac540a 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -377,7 +377,6 @@ bool match_icase;
bool match_words;
bool match_lines;
char eolbyte;
-enum textbin input_textbin;
static char const *matcher;
@@ -389,6 +388,10 @@ static bool omit_dot_slash;
static bool errseen;
static bool write_error_seen;
+/* True if output from the current input file has been suppressed
+ because an output line had an encoding error. */
+static bool encoding_error_output;
+
enum directories_type
{
READ_DIRECTORIES = 2,
@@ -481,12 +484,6 @@ clean_up_stdout (void)
close_stdout ();
}
-static bool
-textbin_is_binary (enum textbin textbin)
-{
- return textbin < TEXTBIN_UNKNOWN;
-}
-
/* The high-order bit of a byte. */
enum { HIBYTE = 0x80 };
@@ -551,58 +548,60 @@ skip_easy_bytes (char const *buf)
return p;
}
-/* Return the text type of data in BUF, of size SIZE.
+/* Return true if BUF, of size SIZE, has an encoding error.
BUF must be followed by at least sizeof (uword) bytes,
- which may be arbitrarily written to or read from. */
-static enum textbin
-buffer_textbin (char *buf, size_t size)
+ the first of which may be modified. */
+static bool
+buf_has_encoding_errors (char *buf, size_t size)
{
- if (eolbyte && memchr (buf, '\0', size))
- return TEXTBIN_BINARY;
+ if (MB_CUR_MAX <= 1)
+ return false;
- if (1 < MB_CUR_MAX)
- {
- mbstate_t mbs = { 0 };
- size_t clen;
- char const *p;
+ mbstate_t mbs = { 0 };
+ size_t clen;
- buf[size] = -1;
- for (p = buf; (p = skip_easy_bytes (p)) < buf + size; p += clen)
- {
- clen = mbrlen (p, buf + size - p, &mbs);
- if ((size_t) -2 <= clen)
- return clen == (size_t) -2 ? TEXTBIN_UNKNOWN : TEXTBIN_BINARY;
- }
+ buf[size] = -1;
+ for (char const *p = buf; (p = skip_easy_bytes (p)) < buf + size; p += clen)
+ {
+ clen = mbrlen (p, buf + size - p, &mbs);
+ if ((size_t) -2 <= clen)
+ return true;
}
- return TEXTBIN_TEXT;
+ return false;
}
-/* Return the text type of a file. BUF, of size SIZE, is the initial
- buffer read from the file with descriptor FD and status ST.
- BUF must be followed by at least sizeof (uword) bytes,
+
+/* Return true if BUF, of size SIZE, has a null byte.
+ BUF must be followed by at least one byte,
which may be arbitrarily written to or read from. */
-static enum textbin
-file_textbin (char *buf, size_t size, int fd, struct stat const *st)
+static bool
+buf_has_nulls (char *buf, size_t size)
{
- enum textbin textbin = buffer_textbin (buf, size);
- if (textbin_is_binary (textbin))
- return textbin;
+ buf[size] = 0;
+ return strlen (buf) != size;
+}
+/* Return true if a file is known to contain null bytes.
+ SIZE bytes have already been read from the file
+ with descriptor FD and status ST. */
+static bool
+file_must_have_nulls (size_t size, int fd, struct stat const *st)
+{
if (usable_st_size (st))
{
if (st->st_size <= size)
- return textbin == TEXTBIN_UNKNOWN ? TEXTBIN_BINARY : textbin;
+ return false;
/* If the file has holes, it must contain a null byte somewhere. */
- if (SEEK_HOLE != SEEK_SET && eolbyte)
+ if (SEEK_HOLE != SEEK_SET)
{
off_t cur = size;
if (O_BINARY || fd == STDIN_FILENO)
{
cur = lseek (fd, 0, SEEK_CUR);
if (cur < 0)
- return TEXTBIN_UNKNOWN;
+ return false;
}
/* Look for a hole after the current location. */
@@ -612,12 +611,12 @@ file_textbin (char *buf, size_t size, int fd, struct stat const *st)
if (lseek (fd, cur, SEEK_SET) < 0)
suppressible_error (filename, errno);
if (hole_start < st->st_size)
- return TEXTBIN_BINARY;
+ return true;
}
}
}
- return TEXTBIN_UNKNOWN;
+ return false;
}
/* Convert STR to a nonnegative integer, storing the result in *OUT.
@@ -888,7 +887,7 @@ static char *label = NULL; /* Fake filename for stdin */
/* Internal variables to keep track of byte count, context, etc. */
static uintmax_t totalcc; /* Total character count before bufbeg. */
static char const *lastnl; /* Pointer after last newline counted. */
-static char const *lastout; /* Pointer after last character output;
+static char *lastout; /* Pointer after last character output;
NULL if no character has been output
or if it's conceptually before bufbeg. */
static intmax_t outleft; /* Maximum number of lines to be output. */
@@ -960,10 +959,31 @@ print_offset (uintmax_t pos, int min_width, const char *color)
pr_sgr_end_if (color);
}
-/* Print a whole line head (filename, line, byte). */
-static void
-print_line_head (char const *beg, char const *lim, char sep)
+/* Print a whole line head (filename, line, byte). The output data
+ starts at BEG and contains LEN bytes; it is followed by at least
+ sizeof (uword) bytes, the first of which may be temporarily modified.
+ The output data comes from what is perhaps a larger input line that
+ goes until LIM, where LIM[-1] is an end-of-line byte. Use SEP as
+ the separator on output.
+
+ Return true unless the line was suppressed due to an encoding error. */
+
+static bool
+print_line_head (char *beg, size_t len, char const *lim, char sep)
{
+ bool encoding_errors = false;
+ if (binary_files != TEXT_BINARY_FILES)
+ {
+ char ch = beg[len];
+ encoding_errors = buf_has_encoding_errors (beg, len);
+ beg[len] = ch;
+ }
+ if (encoding_errors)
+ {
+ encoding_error_output = done_on_match = out_quiet = true;
+ return false;
+ }
+
bool pending_sep = false;
if (out_file)
@@ -1010,22 +1030,27 @@ print_line_head (char const *beg, char const *lim, char sep)
print_sep (sep);
}
+
+ return true;
}
-static const char *
-print_line_middle (const char *beg, const char *lim,
+static char *
+print_line_middle (char *beg, char *lim,
const char *line_color, const char *match_color)
{
size_t match_size;
size_t match_offset;
- const char *cur = beg;
- const char *mid = NULL;
-
- while (cur < lim
- && ((match_offset = execute (beg, lim - beg, &match_size, cur))
- != (size_t) -1))
+ char *cur = beg;
+ char *mid = NULL;
+ char *b;
+
+ for (cur = beg;
+ (cur < lim
+ && ((match_offset = execute (beg, lim - beg, &match_size, cur))
+ != (size_t) -1));
+ cur = b + match_size)
{
- char const *b = beg + match_offset;
+ b = beg + match_offset;
/* Avoid matching the empty line at the end of the buffer. */
if (b == lim)
@@ -1045,8 +1070,11 @@ print_line_middle (const char *beg, const char *lim,
/* This function is called on a matching line only,
but is it selected or rejected/context? */
if (only_matching)
- print_line_head (b, lim, (out_invert ? SEP_CHAR_REJECTED
- : SEP_CHAR_SELECTED));
+ {
+ char sep = out_invert ? SEP_CHAR_REJECTED : SEP_CHAR_SELECTED;
+ if (! print_line_head (b, match_size, lim, sep))
+ return NULL;
+ }
else
{
pr_sgr_start (line_color);
@@ -1064,7 +1092,6 @@ print_line_middle (const char *beg, const char *lim,
if (only_matching)
fputs ("\n", stdout);
}
- cur = b + match_size;
}
if (only_matching)
@@ -1075,8 +1102,8 @@ print_line_middle (const char *beg, const char *lim,
return cur;
}
-static const char *
-print_line_tail (const char *beg, const char *lim, const char *line_color)
+static char *
+print_line_tail (char *beg, const char *lim, const char *line_color)
{
size_t eol_size;
size_t tail_size;
@@ -1097,14 +1124,15 @@ print_line_tail (const char *beg, const char *lim, const char *line_color)
}
static void
-prline (char const *beg, char const *lim, char sep)
+prline (char *beg, char *lim, char sep)
{
bool matching;
const char *line_color;
const char *match_color;
if (!only_matching)
- print_line_head (beg, lim, sep);
+ if (! print_line_head (beg, lim - beg - 1, lim, sep))
+ return;
matching = (sep == SEP_CHAR_SELECTED) ^ out_invert;
@@ -1124,7 +1152,11 @@ prline (char const *beg, char const *lim, char sep)
{
/* We already know that non-matching lines have no match (to colorize). */
if (matching && (only_matching || *match_color))
- beg = print_line_middle (beg, lim, line_color, match_color);
+ {
+ beg = print_line_middle (beg, lim, line_color, match_color);
+ if (! beg)
+ return;
+ }
if (!only_matching && *line_color)
{
@@ -1158,7 +1190,7 @@ prpending (char const *lim)
lastout = bufbeg;
while (pending > 0 && lastout < lim)
{
- char const *nl = memchr (lastout, eolbyte, lim - lastout);
+ char *nl = memchr (lastout, eolbyte, lim - lastout);
size_t match_size;
--pending;
if (outleft
@@ -1173,7 +1205,7 @@ prpending (char const *lim)
/* Output the lines between BEG and LIM. Deal with context. */
static void
-prtext (char const *beg, char const *lim)
+prtext (char *beg, char *lim)
{
static bool used; /* Avoid printing SEP_STR_GROUP before any output. */
char eol = eolbyte;
@@ -1181,7 +1213,7 @@ prtext (char const *beg, char const *lim)
if (!out_quiet && pending > 0)
prpending (beg);
- char const *p = beg;
+ char *p = beg;
if (!out_quiet)
{
@@ -1207,7 +1239,7 @@ prtext (char const *beg, char const *lim)
while (p < beg)
{
- char const *nl = memchr (p, eol, beg - p);
+ char *nl = memchr (p, eol, beg - p);
nl++;
prline (p, nl, SEP_CHAR_REJECTED);
p = nl;
@@ -1220,7 +1252,7 @@ prtext (char const *beg, char const *lim)
/* One or more lines are output. */
for (n = 0; p < lim && n < outleft; n++)
{
- char const *nl = memchr (p, eol, lim - p);
+ char *nl = memchr (p, eol, lim - p);
nl++;
if (!out_quiet)
prline (p, nl, SEP_CHAR_SELECTED);
@@ -1267,13 +1299,12 @@ zap_nuls (char *p, char *lim, char eol)
between matching lines if OUT_INVERT is true). Return a count of
lines printed. Replace all NUL bytes with NUL_ZAPPER as we go. */
static intmax_t
-grepbuf (char const *beg, char const *lim)
+grepbuf (char *beg, char const *lim)
{
intmax_t outleft0 = outleft;
- char const *p;
- char const *endp;
+ char *endp;
- for (p = beg; p < lim; p = endp)
+ for (char *p = beg; p < lim; p = endp)
{
size_t match_size;
size_t match_offset = execute (p, lim - p, &match_size, NULL);
@@ -1284,15 +1315,15 @@ grepbuf (char const *beg, char const *lim)
match_offset = lim - p;
match_size = 0;
}
- char const *b = p + match_offset;
+ char *b = p + match_offset;
endp = b + match_size;
/* Avoid matching the empty line at the end of the buffer. */
if (!out_invert && b == lim)
break;
if (!out_invert || p < b)
{
- char const *prbeg = out_invert ? p : b;
- char const *prend = out_invert ? b : endp;
+ char *prbeg = out_invert ? p : b;
+ char *prend = out_invert ? b : endp;
prtext (prbeg, prend);
if (!outleft || done_on_match)
{
@@ -1313,7 +1344,6 @@ static intmax_t
grep (int fd, struct stat const *st)
{
intmax_t nlines, i;
- enum textbin textbin;
size_t residue, save;
char oldc;
char *beg;
@@ -1322,6 +1352,7 @@ grep (int fd, struct stat const *st)
char nul_zapper = '\0';
bool done_on_match_0 = done_on_match;
bool out_quiet_0 = out_quiet;
+ bool has_nulls = false;
if (! reset (fd, st))
return 0;
@@ -1333,6 +1364,7 @@ grep (int fd, struct stat const *st)
after_last_match = 0;
pending = 0;
skip_nuls = skip_empty_lines && !eol;
+ encoding_error_output = false;
seek_data_failed = false;
nlines = 0;
@@ -1345,26 +1377,20 @@ grep (int fd, struct stat const *st)
return 0;
}
- if (binary_files == TEXT_BINARY_FILES)
- textbin = TEXTBIN_TEXT;
- else
+ for (bool firsttime = true; ; firsttime = false)
{
- textbin = file_textbin (bufbeg, buflim - bufbeg, fd, st);
- if (textbin_is_binary (textbin))
+ if (!has_nulls && eol && binary_files != TEXT_BINARY_FILES
+ && (buf_has_nulls (bufbeg, buflim - bufbeg)
+ || (firsttime && file_must_have_nulls (buflim - bufbeg, fd, st))))
{
+ has_nulls = true;
if (binary_files == WITHOUT_MATCH_BINARY_FILES)
return 0;
done_on_match = out_quiet = true;
nul_zapper = eol;
skip_nuls = skip_empty_lines;
}
- else if (execute != Pexecute)
- textbin = TEXTBIN_TEXT;
- }
- for (;;)
- {
- input_textbin = textbin;
lastnl = bufbeg;
if (lastout)
lastout = bufbeg;
@@ -1415,13 +1441,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;
/* Handle some details and read more data to scan. */
save = residue + lim - beg;
@@ -1434,22 +1455,6 @@ grep (int fd, struct stat const *st)
suppressible_error (filename, errno);
goto finish_grep;
}
-
- /* If the file's textbin has not been determined yet, assume
- it's binary if the next input buffer suggests so. */
- if (textbin == TEXTBIN_UNKNOWN)
- {
- enum textbin tb = buffer_textbin (bufbeg, buflim - bufbeg);
- if (textbin_is_binary (tb))
- {
- if (binary_files == WITHOUT_MATCH_BINARY_FILES)
- return 0;
- textbin = tb;
- done_on_match = out_quiet = true;
- nul_zapper = eol;
- skip_nuls = skip_empty_lines;
- }
- }
}
if (residue)
{
@@ -1463,7 +1468,7 @@ grep (int fd, struct stat const *st)
finish_grep:
done_on_match = done_on_match_0;
out_quiet = out_quiet_0;
- if (textbin_is_binary (textbin) && !out_quiet && nlines != 0)
+ if ((has_nulls || encoding_error_output) && !out_quiet && nlines != 0)
printf (_("Binary file %s matches\n"), filename);
return nlines;
}
diff --git a/src/grep.h b/src/grep.h
index 580eb11..2e4527c 100644
--- a/src/grep.h
+++ b/src/grep.h
@@ -29,22 +29,4 @@ extern bool match_words; /* -w */
extern bool match_lines; /* -x */
extern char eolbyte; /* -z */
-/* An enum textbin describes the file's type, inferred from data read
- before the first line is selected for output. */
-enum textbin
- {
- /* Binary, as it contains null bytes and the -z option is not in effect,
- or it contains encoding errors. */
- TEXTBIN_BINARY = -1,
-
- /* Not known yet. Only text has been seen so far. */
- TEXTBIN_UNKNOWN = 0,
-
- /* Text. */
- TEXTBIN_TEXT = 1
- };
-
-/* Input file type. */
-extern enum textbin input_textbin;
-
#endif
diff --git a/src/pcresearch.c b/src/pcresearch.c
index b1f8310..a446b2c 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -194,32 +194,13 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
error. */
char const *subject = buf;
- /* If the input type is unknown, the caller is still testing the
- input, which means the current buffer cannot contain encoding
- errors and a multiline search is typically more efficient.
- Otherwise, a single-line search is typically faster, so that
- pcre_exec doesn't waste time validating the entire input
- buffer. */
- bool multiline = input_textbin == TEXTBIN_UNKNOWN;
-
for (; p < buf + size; p = line_start = line_end + 1)
{
- bool too_big;
-
- if (multiline)
- {
- size_t pcre_size_max = MIN (INT_MAX, SIZE_MAX - 1);
- size_t scan_size = MIN (pcre_size_max + 1, buf + size - p);
- line_end = memrchr (p, eolbyte, scan_size);
- too_big = ! line_end;
- }
- else
- {
- line_end = memchr (p, eolbyte, buf + size - p);
- too_big = INT_MAX < line_end - p;
- }
-
- if (too_big)
+ /* A single-line search is typically faster, so that
+ pcre_exec doesn't waste time validating the entire input
+ buffer. */
+ line_end = memchr (p, eolbyte, buf + size - p);
+ if (INT_MAX < line_end - p)
error (EXIT_TROUBLE, 0, _("exceeded PCRE's line length limit"));
for (;;)
@@ -247,27 +228,11 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
int options = 0;
if (!bol)
options |= PCRE_NOTBOL;
- if (multiline)
- options |= PCRE_NO_UTF8_CHECK;
e = jit_exec (subject, line_end - subject, search_offset,
options, sub);
if (e != PCRE_ERROR_BADUTF8)
- {
- if (0 < e && multiline && sub[1] - sub[0] != 0)
- {
- char const *nl = memchr (subject + sub[0], eolbyte,
- sub[1] - sub[0]);
- if (nl)
- {
- /* This match crosses a line boundary; reject it. */
- p = subject + sub[0];
- line_end = nl;
- continue;
- }
- }
- break;
- }
+ break;
int valid_bytes = sub[0];
/* Try to match the string before the encoding error. */
@@ -337,15 +302,6 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
beg = matchbeg;
end = matchend;
}
- else if (multiline)
- {
- char const *prev_nl = memrchr (line_start - 1, eolbyte,
- matchbeg - (line_start - 1));
- char const *next_nl = memchr (matchend, eolbyte,
- line_end + 1 - matchend);
- beg = prev_nl + 1;
- end = next_nl + 1;
- }
else
{
beg = line_start;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d379821..2ade5be 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -70,6 +70,7 @@ TESTS = \
empty \
empty-line \
empty-line-mb \
+ encoding-error \
epipe \
equiv-classes \
ere \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 6de6f49..b5bd7b5 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1406,6 +1406,7 @@ TESTS = \
empty \
empty-line \
empty-line-mb \
+ encoding-error \
epipe \
equiv-classes \
ere \
@@ -1997,6 +1998,13 @@ empty-line-mb.log: empty-line-mb
--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)
+encoding-error.log: encoding-error
+ @p='encoding-error'; \
+ b='encoding-error'; \
+ $(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)
epipe.log: epipe
@p='epipe'; \
b='epipe'; \
diff --git a/tests/encoding-error b/tests/encoding-error
new file mode 100755
index 0000000..fe52de2
--- a/dev/null
+++ b/tests/encoding-error
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Test grep's behavior on encoding errors.
+#
+# Copyright 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_en_utf8_locale_
+
+LC_ALL=en_US.UTF-8
+export LC_ALL
+
+printf 'Alfred Jones\n' > a || framework_failure_
+printf 'John Smith\n' >j || framework_failure_
+printf 'Pedro P\xe9rez\n' >p || framework_failure_
+cat a p j >in || framework_failure_
+
+fail=0
+
+grep '^A' in >out || fail=1
+compare a out || fail=1
+
+grep '^P' in >out || fail=1
+printf 'Binary file in matches\n' >exp || framework_failure_
+compare exp out || fail=1
+
+grep '^J' in >out || fail=1
+compare j out || fail=1
+
+grep '^X' in >out
+test $? = 1 || fail=1
+compare /dev/null out || fail=1
+
+grep -a . in >out || fail=1
+compare in out
+
+Exit $fail

View file

@ -1,54 +0,0 @@
From e938d22e2131972a6e9eaddbf850c6a04a4f750c Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Wed, 4 Nov 2015 10:57:07 -0800
Subject: [PATCH] tests: mark performance-related tests as expensive
These performance-related tests are slightly failure prone due to
varying system load during the two runs.
Marking these tests as "expensive" makes it so they are no longer run
via "make check". You can still run them via make "check-expensive".
This makes them less likely to be run by regular users.
* tests/long-pattern-perf: Use expensive_.
* tests/mb-non-UTF8-performance: Likewise.
Reported by Jaroslav Skarvada in http://debbugs.gnu.org/21826
and by Andreas Schwab in http://debbugs.gnu.org/21812.
---
tests/long-pattern-perf | 5 +++++
tests/mb-non-UTF8-performance | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/tests/long-pattern-perf b/tests/long-pattern-perf
index c222c02..2c9d080 100755
--- a/tests/long-pattern-perf
+++ b/tests/long-pattern-perf
@@ -20,6 +20,11 @@
fail=0
+# This test is susceptible to failure due to differences in
+# system load during the two test runs, so we'll mark it as
+# "expensive", making it less likely to be run by regular users.
+expensive_
+
echo x > in || framework_failure_
# We could use seq -s '' (avoiding the tr filter), but I
# suspect some version of seq does not honor that option.
diff --git a/tests/mb-non-UTF8-performance b/tests/mb-non-UTF8-performance
index 228361d..9bd5d39 100755
--- a/tests/mb-non-UTF8-performance
+++ b/tests/mb-non-UTF8-performance
@@ -22,6 +22,11 @@
fail=0
+# This test is susceptible to failure due to differences in
+# system load during the two test runs, so we'll mark it as
+# "expensive", making it less likely to be run by regular users.
+expensive_
+
# Make this large enough so that even on high-end systems
# it incurs at least 5-10ms of user time.
yes $(printf '%078d' 0) | head -400000 > in || framework_failure_
--
2.6.0

View file

@ -1,30 +0,0 @@
diff --git a/src/grep.c b/src/grep.c
index 7315bd0..2748fd3 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1813,17 +1813,20 @@ Output control:\n\
-D, --devices=ACTION how to handle devices, FIFOs and sockets;\n\
ACTION is 'read' or 'skip'\n\
-r, --recursive like --directories=recurse\n\
- -R, --dereference-recursive likewise, but follow all symlinks\n\
+ -R, --dereference-recursive\n\
+ likewise, but follow all symlinks\n\
"));
printf (_("\
- --include=FILE_PATTERN search only files that match FILE_PATTERN\n\
- --exclude=FILE_PATTERN skip files and directories matching\
+ --include=FILE_PATTERN\n\
+ search only files that match FILE_PATTERN\n\
+ --exclude=FILE_PATTERN\n\
+ skip files and directories matching\
FILE_PATTERN\n\
--exclude-from=FILE skip files matching any file pattern from FILE\n\
- --exclude-dir=PATTERN directories that match PATTERN will be skipped.\n\
+ --exclude-dir=PATTERN directories that match PATTERN will be skipped.\n\
"));
printf (_("\
- -L, --files-without-match print only names of FILEs containing no match\n\
+ -L, --files-without-match print only names of FILEs containing no match\n\
-l, --files-with-matches print only names of FILEs containing matches\n\
-c, --count print only a count of matching lines per FILE\n\
-T, --initial-tab make tabs line up (if needed)\n\

View file

@ -1,61 +0,0 @@
diff --git a/doc/grep.in.1 b/doc/grep.in.1
index 2b513a8..40ac40d 100644
--- a/doc/grep.in.1
+++ b/doc/grep.in.1
@@ -314,7 +314,7 @@ Print
.I NUM
lines of trailing context after matching lines.
Places a line containing a group separator
-.RB ( \-\^\- )
+.RB "(described under " \-\^\-group\-separator )
between contiguous groups of matches.
With the
.B \-o
@@ -327,7 +327,7 @@ Print
.I NUM
lines of leading context before matching lines.
Places a line containing a group separator
-.RB ( \-\^\- )
+.RB "(described under " \-\^\-group\-separator )
between contiguous groups of matches.
With the
.B \-o
@@ -340,13 +340,24 @@ Print
.I NUM
lines of output context.
Places a line containing a group separator
-.RB ( \-\^\- )
+.RB "(described under " \-\^\-group\-separator )
between contiguous groups of matches.
With the
.B \-o
or
.B \-\^\-only\-matching
option, this has no effect and a warning is given.
+.TP
+.BI \-\^\-group\-separator= SEP
+Use
+.I SEP
+as a group separator. By default
+.I SEP
+is double hyphen
+.RB ( \-\^\- ).
+.TP
+.B \-\^\-no\-group-separator
+Use empty string as a group separator.
.SS "File and Directory Selection"
.TP
.BR \-a ", " \-\^\-text
diff --git a/src/grep.c b/src/grep.c
index 2c5e09a..7315bd0 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1837,6 +1837,8 @@ Context control:\n\
"));
printf (_("\
-NUM same as --context=NUM\n\
+ --group-separator=SEP use SEP as a group separator\n\
+ --no-group-separator use empty string as a group separator\n\
--color[=WHEN],\n\
--colour[=WHEN] use markers to highlight the matching strings;\n\
WHEN is 'always', 'never', or 'auto'\n\

View file

@ -1,26 +0,0 @@
diff --git a/tests/pcre-count b/tests/pcre-count
--- a/tests/pcre-count
+++ b/tests/pcre-count
@@ -13,11 +13,17 @@ require_pcre_
fail=0
-printf 'a\n%032768d\nb\x0\n%032768d\na\n' 0 0 > in
+printf 'a\n%032768d\nb\0\n%032768d\na\n' 0 0 > in || framework_failure_
-LC_ALL=C grep -P 'a' in | wc -l > exp
+# grep will discover that the input is a binary file sooner if the
+# page size is larger, so allow for either possible output.
+printf 'a\nBinary file in matches\n' >exp1a || framework_failure_
+printf 'Binary file in matches\n' >exp1b || framework_failure_
+LC_ALL=C grep -P 'a' in >out || fail=1
+compare exp1a out || compare exp1b out || fail=1
-LC_ALL=C grep -Pc 'a' in > out || fail=1
-compare exp out || fail=1
+printf '2\n' >exp2 || framework_failure_
+LC_ALL=C grep -Pc 'a' in >out || fail=1
+compare exp2 out || fail=1
Exit $fail

View file

@ -0,0 +1,38 @@
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 223088f..315ced7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -195,7 +195,6 @@ TESTS = \
word-delim-multibyte \
word-multi-file \
word-multibyte \
- write-error-msg \
y2038-vs-32-bit \
yesno \
z-anchor-newline
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 3270d30..33dcd8a 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -2729,7 +2729,6 @@ TESTS = \
word-delim-multibyte \
word-multi-file \
word-multibyte \
- write-error-msg \
y2038-vs-32-bit \
yesno \
z-anchor-newline
@@ -3970,13 +3969,6 @@ word-multibyte.log: word-multibyte
--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)
-write-error-msg.log: write-error-msg
- @p='write-error-msg'; \
- b='write-error-msg'; \
- $(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)
y2038-vs-32-bit.log: y2038-vs-32-bit
@p='y2038-vs-32-bit'; \
b='y2038-vs-32-bit'; \

23
grep-3.5-help-align.patch Normal file
View file

@ -0,0 +1,23 @@
diff --git a/src/grep.c b/src/grep.c
index a530988..b6f6ee3 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2023,7 +2023,8 @@ Output control:\n\
-D, --devices=ACTION how to handle devices, FIFOs and sockets;\n\
ACTION is 'read' or 'skip'\n\
-r, --recursive like --directories=recurse\n\
- -R, --dereference-recursive likewise, but follow all symlinks\n\
+ -R, --dereference-recursive\n\
+ likewise, but follow all symlinks\n\
"));
printf (_("\
--include=GLOB search only files that match GLOB (a file pattern)"
@@ -2033,7 +2034,7 @@ Output control:\n\
--exclude-dir=GLOB skip directories that match GLOB\n\
"));
printf (_("\
- -L, --files-without-match print only names of FILEs with no selected lines\n\
+ -L, --files-without-match print only names of FILEs with no selected lines\n\
-l, --files-with-matches print only names of FILEs with selected lines\n\
-c, --count print only a count of selected lines per FILE\n\
-T, --initial-tab make tabs line up (if needed)\n\

3637
grep-keyring.gpg Normal file

File diff suppressed because it is too large Load diff

299
grep.spec
View file

@ -1,40 +1,43 @@
%define _bindir /bin
Summary: Pattern matching utilities
Name: grep
Version: 2.22
Release: 6%{?dist}
License: GPLv3+
URL: http://www.gnu.org/software/grep/
Group: Applications/Text
Version: 3.12
Release: 2%{?dist}
License: GPL-3.0-or-later AND LGPL-3.0-or-later AND LGPL-2.1-or-later AND GPL-2.0-or-later AND LGPL-2.0-or-later AND GFDL-1.3-no-invariants-or-later
URL: https://www.gnu.org/software/grep/
Source0: https://ftp.gnu.org/pub/gnu/%{name}/%{name}-%{version}.tar.xz
Source1: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz.sig
Source2: https://savannah.gnu.org/project/release-gpgkeys.php?group=grep&download=1'#/grep-keyring.gpg
Source3: colorgrep.sh
Source4: colorgrep.csh
Source5: GREP_COLORS
Source6: grepconf.sh
Source: ftp://ftp.gnu.org/pub/gnu/grep/grep-%{version}.tar.xz
Source1: colorgrep.sh
Source2: colorgrep.csh
Source3: GREP_COLORS
Source4: grepconf.sh
# upstream ticket 39444
Patch0: grep-2.22-man-fix-gs.patch
# upstream ticket 39445
Patch1: grep-2.22-help-align.patch
# backported from upstream, mb-non-UTF8-performance and long-pattern-perf tests
# marked as expensive and not run by default. The result is decided according
# to measured runtime, which doesn't work reliable on the builders with
# variable load.
Patch2: grep-2.22-disable-performance-related-tests.patch
# backported from upstream
Patch3: grep-2.22-better-encoding-errors-handling.patch
# backported from upstream, upstream bug#22028
Patch4: grep-2.22-Pc-consistent-results.patch
# backported from upstream, upstream bug#22350
Patch5: grep-2.22-test-pcre-count-fix.patch
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
Patch: grep-3.5-help-align.patch
# upstream ticket 77800
Patch: grep-3.12-test-write-error-msg-drop.patch
BuildRequires: pcre-devel >= 3.9-10, texinfo, gettext
BuildRequires: autoconf automake
BuildRequires: gcc
BuildRequires: pcre2-devel
BuildRequires: texinfo
BuildRequires: gettext
BuildRequires: autoconf
BuildRequires: automake
# temporal for the gnulib patch
BuildRequires: gettext-devel
Buildrequires: glibc-all-langpacks
BuildRequires: perl(FileHandle)
BuildRequires: make
BuildRequires: gnupg2
# https://fedorahosted.org/fpc/ticket/174
Provides: bundled(gnulib)
# for backward compatibility (rhbz#1540485)
Provides: /bin/grep
Provides: /bin/fgrep
Provides: /bin/egrep
%description
The GNU versions of commonly used grep utilities. Grep searches through
@ -44,16 +47,8 @@ prints the matching lines. GNU's grep utilities include grep, egrep and fgrep.
GNU grep is needed by many scripts, so it shall be installed on every system.
%prep
%setup -q
%patch0 -p1 -b .man-fix-gs
%patch1 -p1 -b .help-align
%patch2 -p1 -b .disable-performance-related-tests
%patch3 -p1 -b .better-encoding-errors-handling
%patch4 -p1 -b .Pc-consistent-results
%patch5 -p1 -b .test-pcre-count-fix
chmod 755 tests/encoding-error
chmod 755 tests/pcre-count
%{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}'
%autosetup -p1
%build
%global BUILD_FLAGS $RPM_OPT_FLAGS
@ -65,35 +60,25 @@ chmod 755 tests/pcre-count
%global BUILD_FLAGS %{BUILD_FLAGS} -mlong-double-64
%endif
%configure --without-included-regex --disable-silent-rules \
CPPFLAGS="-I%{_includedir}/pcre" CFLAGS="%{BUILD_FLAGS}"
make %{?_smp_mflags}
%configure --without-included-regex --disable-silent-rules CFLAGS="%{BUILD_FLAGS}"
%make_build
%install
make %{?_smp_mflags} DESTDIR=$RPM_BUILD_ROOT install
%make_install
gzip $RPM_BUILD_ROOT%{_infodir}/grep*
rm -f $RPM_BUILD_ROOT%{_infodir}/dir
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
install -pm 644 %{SOURCE1} %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
install -pm 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}
install -Dpm 755 %{SOURCE4} $RPM_BUILD_ROOT%{_libexecdir}/grepconf.sh
install -pm 644 %{SOURCE3} %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
install -pm 644 %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}
install -Dpm 755 %{SOURCE6} $RPM_BUILD_ROOT%{_libexecdir}/grepconf.sh
%find_lang %name
%check
make check
%post
/sbin/install-info --quiet --info-dir=%{_infodir} %{_infodir}/grep.info.gz || :
%preun
if [ $1 = 0 ]; then
/sbin/install-info --quiet --info-dir=%{_infodir} --delete %{_infodir}/grep.info.gz || :
fi
%files -f %{name}.lang
%doc AUTHORS THANKS TODO NEWS README
%{!?_licensedir:%global license %%doc}
%license COPYING
%{_bindir}/*
@ -104,6 +89,208 @@ fi
%{_libexecdir}/grepconf.sh
%changelog
* Thu Jul 24 2025 Fedora Release Engineering <releng@fedoraproject.org> - 3.12-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
* Mon Apr 14 2025 Jaroslav Škarvada <jskarvad@redhat.com> - 3.12-1
- New version
Resolves: rhbz#2358901
* Fri Jan 17 2025 Fedora Release Engineering <releng@fedoraproject.org> - 3.11-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
* Thu Jul 18 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.11-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
* Mon Apr 29 2024 Lukáš Zaoral <lzaoral@redhat.com> - 3.11-8
- remove redundant dependency on libsigsegv (RHEL-34664)
* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.11-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Sat Jan 20 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.11-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Thu Aug 10 2023 Jaroslav Škarvada <jskarvad@redhat.com> - 3.11-5
- Updated SPDX license expression
* Wed Aug 9 2023 Jaroslav Škarvada <jskarvad@redhat.com> - 3.11-4
- Converted license to SPDX
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.11-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Thu Jul 13 2023 Jaroslav Škarvada <jskarvad@redhat.com> - 3.11-2
- Fixed egrep/fgrep aliases
Resolves: rhbz#2215713
* Tue Jun 6 2023 Jaroslav Škarvada <jskarvad@redhat.com> - 3.11-1
- New version
Resolves: rhbz#2181063
* Thu Mar 23 2023 Jaroslav Škarvada <jskarvad@redhat.com> - 3.10-1
- New version
Resolves: rhbz#2181063
* Tue Mar 7 2023 Jaroslav Škarvada <jskarvad@redhat.com> - 3.9-1
- New version
Resolves: rhbz#2175526
- Added sources verification
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.8-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Tue Jan 3 2023 Florian Weimer <fweimer@redhat.com> - 3.8-2
- Fix C99 compatibility issue in the configure script
* Mon Sep 5 2022 Jaroslav Škarvada <jskarvad@redhat.com> - 3.8-1
- New version
Resolves: rhbz#2123935
- Switchd to pcre2
Resolves: rhbz#1755491
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.7-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Fri Apr 8 2022 Davide Cavalca <dcavalca@fedoraproject.org> - 3.7-3
- Gate perl-FileHandle dependency to f33 onwards
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Mon Aug 16 2021 Jaroslav Škarvada <jskarvad@redhat.com> - 3.7-1
- New version
Resolves: rhbz#1993631
- Temporarily switch to the included regex until glibc bug (glibc#11053)
is fixed
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.6-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Wed Jun 23 2021 Jaroslav Škarvada <jskarvad@redhat.com> - 3.6-3
- Fixed stack overflow detection
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Mon Nov 9 2020 Jaroslav Škarvada <jskarvad@redhat.com> - 3.6-1
- New version
Resolves: rhbz#1895797
* Wed Sep 30 2020 Jaroslav Škarvada <jskarvad@redhat.com> - 3.5-1
- New version
Resolves: rhbz#1883086
* Wed Aug 26 2020 Adam Williamson <awilliam@redhat.com> - 3.4-5
- Backport fix for upstream #28105 to fix zgrep
Resolves: rhbz#1872913
- Remove some non-portable tests that fail on armv7hl (Paul Eggert)
Resolves: rhbz#1863830
* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.4-4
- Second attempt - Rebuilt for
https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Mon Jul 13 2020 Tom Stellard <tstellar@redhat.com> - 3.4-2
- Use make macros
- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
* Wed Apr 1 2020 Jaroslav Škarvada <jskarvad@redhat.com> - 3.4-1
- New version
Resolves: rhbz#1818417
- Added all glibc langpacks to allow more locale sensitive tests to run
- Added perl-FileHandle requirement for the filename-lineno.pl test
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Wed Apr 24 2019 Björn Esser <besser82@fedoraproject.org> - 3.3-2
- Remove hardcoded gzip suffix from GNU info pages
* Wed Apr 10 2019 Jaroslav Škarvada <jskarvad@redhat.com> - 3.3-1
- New version
Resolves: rhbz#1698044
- Updated patches
- Dropped glibc-2.28-fix patch (not needed)
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Thu Aug 9 2018 Jaroslav Škarvada <jskarvad@redhat.com> - 3.1-8
- Fixed FTBFS with glibc-2.28
Resolves: rhbz#1604263
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Jun 19 2018 Jaroslav Škarvada <jskarvad@redhat.com> - 3.1-6
- Dropped install-info
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Fri Feb 2 2018 Jaroslav Škarvada <jskarvad@redhat.com> - 3.1-4
- Moved binaries to /usr/bin
Resolves: rhbz#1540485
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Mon Jul 3 2017 Jaroslav Škarvada <jskarvad@redhat.com> - 3.1-1
- New version
Related: rhbz#1421129
- Updated patches
* Fri Feb 10 2017 Jaroslav Škarvada <jskarvad@redhat.com> - 3.0-1
- New version
Resolves: rhbz#1421129
* Wed Feb 8 2017 Jaroslav Škarvada <jskarvad@redhat.com> - 2.28-1
- New version
Resolves: rhbz#1419921
- De-fuzzified patches
* Wed Dec 7 2016 Jaroslav Škarvada <jskarvad@redhat.com> - 2.27-1
- New version
Resolves: rhbz#1402379
- De-fuzzified patches
* Wed Oct 5 2016 Jaroslav Škarvada <jskarvad@redhat.com> - 2.26-2
- Re-enabled 'make check', glibc seems fixed
* Mon Oct 3 2016 Jaroslav Škarvada <jskarvad@redhat.com> - 2.26-1
- New version
Resolves: rhbz#1381203
- Disabled 'make check' due to glibc bug rhbz#1381582
* Fri Apr 22 2016 Jaroslav Škarvada <jskarvad@redhat.com> - 2.25-1
- New version
Resolves: rhbz#1329627
- De-fuzzified patches
* Fri Mar 11 2016 Jaroslav Škarvada <jskarvad@redhat.com> - 2.24-1
- New version
Resolves: rhbz#1316890
* Fri Feb 5 2016 Jaroslav Škarvada <jskarvad@redhat.com> - 2.23-1
- New version
Resolves: rhbz#1305035
- Dropped disable-performance-related-tests, better-encoding-errors-handling,
Pc-consistent-results, and test-pcre-count-fix patches (all upstreamed)
- De-fuzzified man-fx-gs, and help-align patches
* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.22-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Tue Jan 12 2016 Jaroslav Škarvada <jskarvad@redhat.com> - 2.22-6
- Fixed pcre-count test on secondary architectures
(byt test-pcre-count-fix patch)

6
plans/all.fmf Normal file
View file

@ -0,0 +1,6 @@
summary: Test plan with all Fedora tests
discover:
how: fmf
url: https://src.fedoraproject.org/tests/grep.git
execute:
how: tmt

View file

@ -1 +1,2 @@
e1015e951a49a82b02e38891026ef5df grep-2.22.tar.xz
SHA512 (grep-3.12.tar.xz) = c54b4db5a8b9afe098c088decd94977746305284d716666a60bac82b4edc0fae4acf828970b5b6fc7d58ecd549f638e17e6958f33a71fedcc7d7415b9228b161
SHA512 (grep-3.12.tar.xz.sig) = 333755fd9e5879436789a19e9593667d6fb96c2d1b876a1c391eb9cd75d10bb7fbc10215db9838280e6006790c818ef4583b1ae22318a833a5b69264ca15dbf1