!132 sync patches from upstream to fix a bug in pcre2grep
From: @Linux_zhang2024 Reviewed-by: @xujing99 Signed-off-by: @xujing99
This commit is contained in:
commit
c8eb1717e3
49
backport-Fix-oversight-in-adding-new-pcre2grep-test.patch
Normal file
49
backport-Fix-oversight-in-adding-new-pcre2grep-test.patch
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
From ace78dc460e7e80592d86216cfdd36a62b083bb3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Philip Hazel <Philip.Hazel@gmail.com>
|
||||||
|
Date: Wed, 27 Nov 2024 15:50:34 +0000
|
||||||
|
Subject: [PATCH] Fix oversight in adding new pcre2grep test
|
||||||
|
|
||||||
|
Conflict:NA
|
||||||
|
Reference:https://github.com/PCRE2Project/pcre2/commit/ace78dc460e7e80592d86216cfdd36a62b083bb3
|
||||||
|
|
||||||
|
---
|
||||||
|
testdata/grepinput | 2 +-
|
||||||
|
testdata/grepoutput | 3 +--
|
||||||
|
2 files changed, 2 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/testdata/grepinput b/testdata/grepinput
|
||||||
|
index 91d3db88..1a0a9c0f 100644
|
||||||
|
--- a/testdata/grepinput
|
||||||
|
+++ b/testdata/grepinput
|
||||||
|
@@ -630,7 +630,7 @@ asd
|
||||||
|
dfg
|
||||||
|
ghj
|
||||||
|
jkl
|
||||||
|
-abc
|
||||||
|
+abx
|
||||||
|
def
|
||||||
|
ghi
|
||||||
|
xyz
|
||||||
|
diff --git a/testdata/grepoutput b/testdata/grepoutput
|
||||||
|
index 58ea858d..abfabe15 100644
|
||||||
|
--- a/testdata/grepoutput
|
||||||
|
+++ b/testdata/grepoutput
|
||||||
|
@@ -104,7 +104,6 @@ pcre2grep: Error in command-line regex at offset 4: quantifier does not follow a
|
||||||
|
RC=2
|
||||||
|
---------------------------- Test 16 -----------------------------
|
||||||
|
pcre2grep: Failed to open ./testdata/nonexistfile: No such file or directory
|
||||||
|
-./testdata/grepinput:abc
|
||||||
|
RC=2
|
||||||
|
---------------------------- Test 17 -----------------------------
|
||||||
|
features should be added at the end, because some of the tests involve the
|
||||||
|
@@ -1306,7 +1305,7 @@ RC=0
|
||||||
|
630-dfg
|
||||||
|
631-ghj
|
||||||
|
632:jkl
|
||||||
|
-633-abc
|
||||||
|
+633-abx
|
||||||
|
634-def
|
||||||
|
635-ghi
|
||||||
|
RC=0
|
||||||
|
--
|
||||||
|
2.23.0
|
||||||
@ -0,0 +1,223 @@
|
|||||||
|
From f34fc0a34ab18d7cb0ff27eacaea43912d797a27 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Philip Hazel <Philip.Hazel@gmail.com>
|
||||||
|
Date: Wed, 27 Nov 2024 15:15:45 +0000
|
||||||
|
Subject: [PATCH] Mend a bug in pcre2grep that caused separator lines to
|
||||||
|
be
|
||||||
|
incorrectly inserted in some cases when above/below context lines are
|
||||||
|
contiguous. Reported by Alejandro Colomar <alx@kernel.org>. Fixes
|
||||||
|
GitHub
|
||||||
|
issue #577.
|
||||||
|
|
||||||
|
Conflict:adapt context; don't modify ChangeLog; don't use
|
||||||
|
group_separator because e179a4b8c is not merged
|
||||||
|
Reference:https://github.com/PCRE2Project/pcre2/commit/f34fc0a34ab18d7cb0ff27eacaea43912d797a27
|
||||||
|
|
||||||
|
---
|
||||||
|
RunGrepTest | 6 +++++-
|
||||||
|
src/pcre2grep.c | 19 ++++++++++++++++--
|
||||||
|
testdata/grepinput | 19 ++++++++++++++++++
|
||||||
|
testdata/grepoutput | 48 ++++++++++++++++++++++++++++++++++++---------
|
||||||
|
4 files changed, 80 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/RunGrepTest b/RunGrepTest
|
||||||
|
index 0a00e82..0d57707 100755
|
||||||
|
--- a/RunGrepTest
|
||||||
|
+++ b/RunGrepTest
|
||||||
|
@@ -853,7 +853,11 @@ fi
|
||||||
|
echo "---------------------------- Test 151 -----------------------------" >>testtrygrep
|
||||||
|
(cd $srcdir; $valgrind $vjs $pcre2grep --colour=always -e this -e The -e 'The wo' testdata/grepinputv) >>testtrygrep
|
||||||
|
|
||||||
|
-
|
||||||
|
+echo "---------------------------- Test 160 -----------------------------" >>testtrygrep
|
||||||
|
+(cd $srcdir; $valgrind $vjs $pcre2grep -nC3 '^(ert|jkl)' ./testdata/grepinput) >>testtrygrep
|
||||||
|
+echo "RC=$?" >>testtrygrep
|
||||||
|
+(cd $srcdir; $valgrind $vjs $pcre2grep -n -B4 -A2 '^(ert|dfg)' ./testdata/grepinput) >>testtrygrep
|
||||||
|
+echo "RC=$?" >>testtrygrep
|
||||||
|
|
||||||
|
|
||||||
|
# Now compare the results.
|
||||||
|
diff --git a/src/pcre2grep.c b/src/pcre2grep.c
|
||||||
|
index 6a5841c..3b79f26 100644
|
||||||
|
--- a/src/pcre2grep.c
|
||||||
|
+++ b/src/pcre2grep.c
|
||||||
|
@@ -2940,12 +2940,15 @@ while (ptr < endptr)
|
||||||
|
FWRITE_IGNORE(lastmatchrestart, 1, pp - lastmatchrestart, stdout);
|
||||||
|
lastmatchrestart = pp;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
if (lastmatchrestart != ptr) hyphenpending = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
- /* If there were non-contiguous lines printed above, insert hyphens. */
|
||||||
|
+ /* If hyphenpending is TRUE when there is no "after" context, it means we
|
||||||
|
+ are at the start of a new file, having output something from the previous
|
||||||
|
+ file. Output a separator if enabled.*/
|
||||||
|
|
||||||
|
- if (hyphenpending)
|
||||||
|
+ else if (hyphenpending)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "--" STDOUT_NL);
|
||||||
|
hyphenpending = FALSE;
|
||||||
|
@@ -2970,6 +2973,7 @@ while (ptr < endptr)
|
||||||
|
|
||||||
|
if (lastmatchnumber > 0 && p > lastmatchrestart && !hyphenprinted)
|
||||||
|
fprintf(stdout, "--" STDOUT_NL);
|
||||||
|
+ hyphenpending = FALSE;
|
||||||
|
|
||||||
|
while (p < ptr)
|
||||||
|
{
|
||||||
|
@@ -2984,12 +2988,23 @@ while (ptr < endptr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* If hyphenpending is TRUE here, it was set after outputting some
|
||||||
|
+ "after" lines (and there are no "before" lines). */
|
||||||
|
+
|
||||||
|
+ else if (hyphenpending)
|
||||||
|
+ {
|
||||||
|
+ fprintf(stdout, "--" STDOUT_NL);
|
||||||
|
+ hyphenpending = FALSE;
|
||||||
|
+ hyphenprinted = TRUE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/* Now print the matching line(s); ensure we set hyphenpending at the end
|
||||||
|
of the file if any context lines are being output. */
|
||||||
|
|
||||||
|
if (after_context > 0 || before_context > 0)
|
||||||
|
endhyphenpending = TRUE;
|
||||||
|
|
||||||
|
+
|
||||||
|
if (printname != NULL) fprintf(stdout, "%s%c", printname,
|
||||||
|
printname_colon);
|
||||||
|
if (number) fprintf(stdout, "%lu:", linenumber);
|
||||||
|
diff --git a/testdata/grepinput b/testdata/grepinput
|
||||||
|
index 1e2ceb4..91d3db8 100644
|
||||||
|
--- a/testdata/grepinput
|
||||||
|
+++ b/testdata/grepinput
|
||||||
|
@@ -617,6 +617,25 @@ match 5:
|
||||||
|
Rhubarb
|
||||||
|
Custard Tart
|
||||||
|
|
||||||
|
+zxc
|
||||||
|
+cvb
|
||||||
|
+bnm
|
||||||
|
+asd
|
||||||
|
+qwe
|
||||||
|
+ert
|
||||||
|
+tyu
|
||||||
|
+uio
|
||||||
|
+ggg
|
||||||
|
+asd
|
||||||
|
+dfg
|
||||||
|
+ghj
|
||||||
|
+jkl
|
||||||
|
+abc
|
||||||
|
+def
|
||||||
|
+ghi
|
||||||
|
+xyz
|
||||||
|
+
|
||||||
|
+
|
||||||
|
PUT NEW DATA ABOVE THIS LINE.
|
||||||
|
=============================
|
||||||
|
|
||||||
|
diff --git a/testdata/grepoutput b/testdata/grepoutput
|
||||||
|
index aa53aab..df658ed 100644
|
||||||
|
--- a/testdata/grepoutput
|
||||||
|
+++ b/testdata/grepoutput
|
||||||
|
@@ -10,7 +10,7 @@ RC=0
|
||||||
|
7:PATTERN at the start of a line.
|
||||||
|
8:In the middle of a line, PATTERN appears.
|
||||||
|
10:This pattern is in lower case.
|
||||||
|
-623:Check up on PATTERN near the end.
|
||||||
|
+642:Check up on PATTERN near the end.
|
||||||
|
RC=0
|
||||||
|
---------------------------- Test 4 ------------------------------
|
||||||
|
4
|
||||||
|
@@ -19,7 +19,7 @@ RC=0
|
||||||
|
./testdata/grepinput:7:PATTERN at the start of a line.
|
||||||
|
./testdata/grepinput:8:In the middle of a line, PATTERN appears.
|
||||||
|
./testdata/grepinput:10:This pattern is in lower case.
|
||||||
|
-./testdata/grepinput:623:Check up on PATTERN near the end.
|
||||||
|
+./testdata/grepinput:642:Check up on PATTERN near the end.
|
||||||
|
./testdata/grepinputx:3:Here is the pattern again.
|
||||||
|
./testdata/grepinputx:5:Pattern
|
||||||
|
./testdata/grepinputx:42:This line contains pattern not on a line by itself.
|
||||||
|
@@ -28,7 +28,7 @@ RC=0
|
||||||
|
7:PATTERN at the start of a line.
|
||||||
|
8:In the middle of a line, PATTERN appears.
|
||||||
|
10:This pattern is in lower case.
|
||||||
|
-623:Check up on PATTERN near the end.
|
||||||
|
+642:Check up on PATTERN near the end.
|
||||||
|
3:Here is the pattern again.
|
||||||
|
5:Pattern
|
||||||
|
42:This line contains pattern not on a line by itself.
|
||||||
|
@@ -104,6 +104,7 @@ pcre2grep: Error in command-line regex at offset 4: quantifier does not follow a
|
||||||
|
RC=2
|
||||||
|
---------------------------- Test 16 -----------------------------
|
||||||
|
pcre2grep: Failed to open ./testdata/nonexistfile: No such file or directory
|
||||||
|
+./testdata/grepinput:abc
|
||||||
|
RC=2
|
||||||
|
---------------------------- Test 17 -----------------------------
|
||||||
|
features should be added at the end, because some of the tests involve the
|
||||||
|
@@ -324,10 +325,10 @@ RC=0
|
||||||
|
./testdata/grepinput-9-
|
||||||
|
./testdata/grepinput:10:This pattern is in lower case.
|
||||||
|
--
|
||||||
|
-./testdata/grepinput-620-PUT NEW DATA ABOVE THIS LINE.
|
||||||
|
-./testdata/grepinput-621-=============================
|
||||||
|
-./testdata/grepinput-622-
|
||||||
|
-./testdata/grepinput:623:Check up on PATTERN near the end.
|
||||||
|
+./testdata/grepinput-639-PUT NEW DATA ABOVE THIS LINE.
|
||||||
|
+./testdata/grepinput-640-=============================
|
||||||
|
+./testdata/grepinput-641-
|
||||||
|
+./testdata/grepinput:642:Check up on PATTERN near the end.
|
||||||
|
--
|
||||||
|
./testdata/grepinputx-1-This is a second file of input for the pcregrep tests.
|
||||||
|
./testdata/grepinputx-2-
|
||||||
|
@@ -349,8 +350,8 @@ RC=0
|
||||||
|
./testdata/grepinput-12-Here follows a whole lot of stuff that makes the file over 24KiB long.
|
||||||
|
./testdata/grepinput-13-
|
||||||
|
--
|
||||||
|
-./testdata/grepinput:623:Check up on PATTERN near the end.
|
||||||
|
-./testdata/grepinput-624-This is the last line of this file.
|
||||||
|
+./testdata/grepinput:642:Check up on PATTERN near the end.
|
||||||
|
+./testdata/grepinput-643-This is the last line of this file.
|
||||||
|
--
|
||||||
|
./testdata/grepinputx:3:Here is the pattern again.
|
||||||
|
./testdata/grepinputx-4-
|
||||||
|
@@ -1232,3 +1233,32 @@ RC=2
|
||||||
|
[1;31mThe wo[0mrd is cat in [1;31mthis[0m line
|
||||||
|
[1;31mThe[0m caterpillar sat on the mat
|
||||||
|
[1;31mThe[0m snowcat is not an animal
|
||||||
|
+---------------------------- Test 160 -----------------------------
|
||||||
|
+622-bnm
|
||||||
|
+623-asd
|
||||||
|
+624-qwe
|
||||||
|
+625:ert
|
||||||
|
+626-tyu
|
||||||
|
+627-uio
|
||||||
|
+628-ggg
|
||||||
|
+629-asd
|
||||||
|
+630-dfg
|
||||||
|
+631-ghj
|
||||||
|
+632:jkl
|
||||||
|
+633-abc
|
||||||
|
+634-def
|
||||||
|
+635-ghi
|
||||||
|
+RC=0
|
||||||
|
+621-cvb
|
||||||
|
+622-bnm
|
||||||
|
+623-asd
|
||||||
|
+624-qwe
|
||||||
|
+625:ert
|
||||||
|
+626-tyu
|
||||||
|
+627-uio
|
||||||
|
+628-ggg
|
||||||
|
+629-asd
|
||||||
|
+630:dfg
|
||||||
|
+631-ghj
|
||||||
|
+632-jkl
|
||||||
|
+RC=0
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: pcre2
|
Name: pcre2
|
||||||
Version: 10.42
|
Version: 10.42
|
||||||
Release: 12
|
Release: 13
|
||||||
Summary: Perl Compatible Regular Expressions
|
Summary: Perl Compatible Regular Expressions
|
||||||
License: BSD
|
License: BSD
|
||||||
URL: http://www.pcre.org/
|
URL: http://www.pcre.org/
|
||||||
@ -44,6 +44,8 @@ Patch6032: backport-avoid-inconsistency-between-d-and-digit-when-using-a.pat
|
|||||||
Patch6033: backport-Fix-the-lookahead-after-d-or-posix-to-skip-whitespac.patch
|
Patch6033: backport-Fix-the-lookahead-after-d-or-posix-to-skip-whitespac.patch
|
||||||
Patch6034: backport-Improve-error-offsets-for-character-classes-548.patch
|
Patch6034: backport-Improve-error-offsets-for-character-classes-548.patch
|
||||||
Patch6035: backport-Non-recursive-scan-prefix-in-JIT-560.patch
|
Patch6035: backport-Non-recursive-scan-prefix-in-JIT-560.patch
|
||||||
|
Patch6036: backport-Mend-a-bug-in-pcre2grep-that-caused-separator-lines-.patch
|
||||||
|
Patch6037: backport-Fix-oversight-in-adding-new-pcre2grep-test.patch
|
||||||
|
|
||||||
BuildRequires: autoconf libtool automake coreutils gcc make readline-devel
|
BuildRequires: autoconf libtool automake coreutils gcc make readline-devel
|
||||||
Obsoletes: pcre2-utf16 pcre2-utf32 pcre2-tools
|
Obsoletes: pcre2-utf16 pcre2-utf32 pcre2-tools
|
||||||
@ -161,6 +163,9 @@ make check
|
|||||||
%{_pkgdocdir}/html/
|
%{_pkgdocdir}/html/
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
*Thu Mar 13 2025 Linux_zhang <zhangruifang@h-partners.com> - 10.42-13
|
||||||
|
- DESC:sync patches from upstream to fix a bug in pcre2grep
|
||||||
|
|
||||||
* Tue Dec 10 2024 hugel <gengqihu2@h-partners.com> - 10.42-12
|
* Tue Dec 10 2024 hugel <gengqihu2@h-partners.com> - 10.42-12
|
||||||
- DESC:sync patches from upstream
|
- DESC:sync patches from upstream
|
||||||
backport-Further-ASCII-tests-and-minor-bugfix-plus-ChangeLog-.patch
|
backport-Further-ASCII-tests-and-minor-bugfix-plus-ChangeLog-.patch
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user