Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
134b1f6c62 |
2 changed files with 183 additions and 1 deletions
173
grep-3.4-rss-regression-fix.patch
Normal file
173
grep-3.4-rss-regression-fix.patch
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
diff --git a/lib/dfa.c b/lib/dfa.c
|
||||
index 96ae560..3cb64bc 100644
|
||||
--- a/lib/dfa.c
|
||||
+++ b/lib/dfa.c
|
||||
@@ -3597,7 +3597,7 @@ free_mbdata (struct dfa *d)
|
||||
}
|
||||
|
||||
/* Return true if every construct in D is supported by this DFA matcher. */
|
||||
-static bool _GL_ATTRIBUTE_PURE
|
||||
+bool
|
||||
dfa_supported (struct dfa const *d)
|
||||
{
|
||||
for (idx_t i = 0; i < d->tindex; i++)
|
||||
diff --git a/lib/dfa.h b/lib/dfa.h
|
||||
index c5bff89..fddce39 100644
|
||||
--- a/lib/dfa.h
|
||||
+++ b/lib/dfa.h
|
||||
@@ -113,6 +113,9 @@ extern struct dfa *dfasuperset (struct dfa const *d) _GL_ATTRIBUTE_PURE;
|
||||
/* The DFA is likely to be fast. */
|
||||
extern bool dfaisfast (struct dfa const *) _GL_ATTRIBUTE_PURE;
|
||||
|
||||
+/* Return true if every construct in D is supported by this DFA matcher. */
|
||||
+extern bool dfa_supported (struct dfa const *) _GL_ATTRIBUTE_PURE;
|
||||
+
|
||||
/* Free the storage held by the components of a struct dfa. */
|
||||
extern void dfafree (struct dfa *);
|
||||
|
||||
diff --git a/src/dfasearch.c b/src/dfasearch.c
|
||||
index 337345f..ff7d7ad 100644
|
||||
--- a/src/dfasearch.c
|
||||
+++ b/src/dfasearch.c
|
||||
@@ -175,7 +175,7 @@ regex_compile (struct dfa_comp *dc, char const *p, ptrdiff_t len,
|
||||
}
|
||||
|
||||
void *
|
||||
-GEAcompile (char *pattern, size_t size, reg_syntax_t syntax_bits)
|
||||
+GEAcompile (char *pattern, size_t size, reg_syntax_t syntax_bits, bool exact)
|
||||
{
|
||||
char *motif;
|
||||
struct dfa_comp *dc = xcalloc (1, sizeof (*dc));
|
||||
@@ -277,18 +277,6 @@ GEAcompile (char *pattern, size_t size, reg_syntax_t syntax_bits)
|
||||
}
|
||||
}
|
||||
|
||||
- if (buf != NULL)
|
||||
- {
|
||||
- dc->patterns--;
|
||||
- dc->pcount++;
|
||||
-
|
||||
- if (!regex_compile (dc, buf, buflen, 0, -1, false))
|
||||
- abort ();
|
||||
-
|
||||
- if (buf != pattern)
|
||||
- free (buf);
|
||||
- }
|
||||
-
|
||||
/* In the match_words and match_lines cases, we use a different pattern
|
||||
for the DFA matcher that will quickly throw out cases that won't work.
|
||||
Then if DFA succeeds we do some hairy stuff using the regex matcher
|
||||
@@ -324,6 +312,21 @@ GEAcompile (char *pattern, size_t size, reg_syntax_t syntax_bits)
|
||||
kwsmusts (dc);
|
||||
dfacomp (NULL, 0, dc->dfa, 1);
|
||||
|
||||
+ if (buf != NULL)
|
||||
+ {
|
||||
+ if (exact || !dfa_supported (dc->dfa))
|
||||
+ {
|
||||
+ dc->patterns--;
|
||||
+ dc->pcount++;
|
||||
+
|
||||
+ if (!regex_compile (dc, buf, buflen, 0, -1, false))
|
||||
+ abort ();
|
||||
+ }
|
||||
+
|
||||
+ if (buf != pattern)
|
||||
+ free (buf);
|
||||
+ }
|
||||
+
|
||||
free (motif);
|
||||
|
||||
return dc;
|
||||
diff --git a/src/grep.c b/src/grep.c
|
||||
index 929a37c..a96a869 100644
|
||||
--- a/src/grep.c
|
||||
+++ b/src/grep.c
|
||||
@@ -571,7 +571,7 @@ static bool seek_failed;
|
||||
static bool seek_data_failed;
|
||||
|
||||
/* Functions we'll use to search. */
|
||||
-typedef void *(*compile_fp_t) (char *, size_t, reg_syntax_t);
|
||||
+typedef void *(*compile_fp_t) (char *, size_t, reg_syntax_t, bool);
|
||||
typedef size_t (*execute_fp_t) (void *, char const *, size_t, size_t *,
|
||||
char const *);
|
||||
static execute_fp_t execute;
|
||||
@@ -2900,8 +2900,9 @@ main (int argc, char **argv)
|
||||
matcher = try_fgrep_pattern (matcher, keys, &keycc);
|
||||
|
||||
execute = matchers[matcher].execute;
|
||||
- compiled_pattern = matchers[matcher].compile (keys, keycc,
|
||||
- matchers[matcher].syntax);
|
||||
+ compiled_pattern =
|
||||
+ matchers[matcher].compile (keys, keycc, matchers[matcher].syntax,
|
||||
+ only_matching | color_option);
|
||||
/* We need one byte prior and one after. */
|
||||
char eolbytes[3] = { 0, eolbyte, 0 };
|
||||
size_t match_size;
|
||||
diff --git a/src/kwsearch.c b/src/kwsearch.c
|
||||
index 6f6d4d0..808d3b6 100644
|
||||
--- a/src/kwsearch.c
|
||||
+++ b/src/kwsearch.c
|
||||
@@ -47,7 +47,7 @@ struct kwsearch
|
||||
description of the compiled pattern. */
|
||||
|
||||
void *
|
||||
-Fcompile (char *pattern, size_t size, reg_syntax_t ignored)
|
||||
+Fcompile (char *pattern, size_t size, reg_syntax_t ignored, bool exact)
|
||||
{
|
||||
kwset_t kwset;
|
||||
ptrdiff_t total = size;
|
||||
@@ -190,7 +190,7 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t *match_size,
|
||||
{
|
||||
fgrep_to_grep_pattern (&kwsearch->pattern, &kwsearch->size);
|
||||
kwsearch->re = GEAcompile (kwsearch->pattern, kwsearch->size,
|
||||
- RE_SYNTAX_GREP);
|
||||
+ RE_SYNTAX_GREP, !!start_ptr);
|
||||
}
|
||||
return EGexecute (kwsearch->re, buf, size, match_size, start_ptr);
|
||||
}
|
||||
@@ -257,7 +257,7 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t *match_size,
|
||||
fgrep_to_grep_pattern (&kwsearch->pattern, &kwsearch->size);
|
||||
kwsearch->re = GEAcompile (kwsearch->pattern,
|
||||
kwsearch->size,
|
||||
- RE_SYNTAX_GREP);
|
||||
+ RE_SYNTAX_GREP, !!start_ptr);
|
||||
}
|
||||
end = memchr (beg + len, eol, (buf + size) - (beg + len));
|
||||
end = end ? end + 1 : buf + size;
|
||||
diff --git a/src/pcresearch.c b/src/pcresearch.c
|
||||
index 15a6a59..0e2d4e4 100644
|
||||
--- a/src/pcresearch.c
|
||||
+++ b/src/pcresearch.c
|
||||
@@ -108,7 +108,7 @@ jit_exec (struct pcre_comp *pc, char const *subject, int search_bytes,
|
||||
}
|
||||
|
||||
void *
|
||||
-Pcompile (char *pattern, size_t size, reg_syntax_t ignored)
|
||||
+Pcompile (char *pattern, size_t size, reg_syntax_t ignored, bool exact)
|
||||
{
|
||||
int e;
|
||||
char const *ep;
|
||||
diff --git a/src/search.h b/src/search.h
|
||||
index 1d85a7e..af81dcb 100644
|
||||
--- a/src/search.h
|
||||
+++ b/src/search.h
|
||||
@@ -56,15 +56,15 @@ extern ptrdiff_t mb_goback (char const **, size_t *, char const *,
|
||||
char const *);
|
||||
|
||||
/* dfasearch.c */
|
||||
-extern void *GEAcompile (char *, size_t, reg_syntax_t);
|
||||
+extern void *GEAcompile (char *, size_t, reg_syntax_t, bool);
|
||||
extern size_t EGexecute (void *, char const *, size_t, size_t *, char const *);
|
||||
|
||||
/* kwsearch.c */
|
||||
-extern void *Fcompile (char *, size_t, reg_syntax_t);
|
||||
+extern void *Fcompile (char *, size_t, reg_syntax_t, bool);
|
||||
extern size_t Fexecute (void *, char const *, size_t, size_t *, char const *);
|
||||
|
||||
/* pcresearch.c */
|
||||
-extern void *Pcompile (char *, size_t, reg_syntax_t);
|
||||
+extern void *Pcompile (char *, size_t, reg_syntax_t, bool);
|
||||
extern size_t Pexecute (void *, char const *, size_t, size_t *, char const *);
|
||||
|
||||
/* grep.c */
|
||||
11
grep.spec
11
grep.spec
|
|
@ -1,7 +1,7 @@
|
|||
Summary: Pattern matching utilities
|
||||
Name: grep
|
||||
Version: 3.4
|
||||
Release: 5%{?dist}
|
||||
Release: 6%{?dist}
|
||||
License: GPLv3+
|
||||
URL: http://www.gnu.org/software/grep/
|
||||
|
||||
|
|
@ -21,6 +21,9 @@ Patch2: 0001-Revert-L-exit-status-change-introduced-in-grep-3.2.patch
|
|||
# removes some tests that fail on armv7hl, by Paul Eggert
|
||||
# re-diffed to apply to 3.4
|
||||
Patch3: 0001-perror-strerror_r-remove-unportable-tests.patch
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1967370
|
||||
# https://git.savannah.gnu.org/cgit/grep.git/patch/?id=ae65513edc80a1b65f19264b9bed95d870602967
|
||||
Patch4: grep-3.4-rss-regression-fix.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: pcre-devel >= 3.9-10, texinfo, gettext
|
||||
|
|
@ -46,6 +49,7 @@ GNU grep is needed by many scripts, so it shall be installed on every system.
|
|||
%patch1 -p1 -b .help-align
|
||||
%patch2 -p1 -b .zgrep-fix
|
||||
%patch3 -p1 -b .remove-broken-tests
|
||||
%patch4 -p1 -b .rss-regression-fix
|
||||
|
||||
%build
|
||||
%global BUILD_FLAGS $RPM_OPT_FLAGS
|
||||
|
|
@ -88,6 +92,11 @@ make check
|
|||
%{_libexecdir}/grepconf.sh
|
||||
|
||||
%changelog
|
||||
* Tue Jun 15 2021 Jaroslav Škarvada <jskarvad@redhat.com> - 3.4-6
|
||||
- Backported upstream fix for many-regexp N^2 RSS regression
|
||||
by rss-regression-fix patch (without test)
|
||||
Resolves: rhbz#1967370
|
||||
|
||||
* Wed Aug 26 2020 Adam Williamson <awilliam@redhat.com> - 3.4-5
|
||||
- Backport fix for upstream #28105 to fix zgrep
|
||||
Resolves: rhbz#1872913
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue