diff --git a/backport-Fix-oversight-in-adding-new-pcre2grep-test.patch b/backport-Fix-oversight-in-adding-new-pcre2grep-test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fdc62f2cb59ed609def0a7f59d9e48fdf89ebe3a --- /dev/null +++ b/backport-Fix-oversight-in-adding-new-pcre2grep-test.patch @@ -0,0 +1,49 @@ +From ace78dc460e7e80592d86216cfdd36a62b083bb3 Mon Sep 17 00:00:00 2001 +From: Philip Hazel +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 \ No newline at end of file diff --git a/backport-Mend-a-bug-in-pcre2grep-that-caused-separator-lines-.patch b/backport-Mend-a-bug-in-pcre2grep-that-caused-separator-lines-.patch new file mode 100644 index 0000000000000000000000000000000000000000..f74ea9b7a00fd2991aafac905969a7756bd455b1 --- /dev/null +++ b/backport-Mend-a-bug-in-pcre2grep-that-caused-separator-lines-.patch @@ -0,0 +1,220 @@ +From f34fc0a34ab18d7cb0ff27eacaea43912d797a27 Mon Sep 17 00:00:00 2001 +From: Philip Hazel +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 . 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 | 7 +++++++ + src/pcre2grep.c | 19 ++++++++++++++++-- + testdata/grepinput | 19 ++++++++++++++++++ + testdata/grepoutput | 48 ++++++++++++++++++++++++++++++++++++--------- + 4 files changed, 82 insertions(+), 11 deletions(-) + +diff --git a/RunGrepTest b/RunGrepTest +index 9682c5f..e8ab6e5 100755 +--- a/RunGrepTest ++++ b/RunGrepTest +@@ -685,6 +685,13 @@ echo "---------------------------- Test 134 -----------------------------" >>tes + (cd $srcdir; $valgrind $vjs $pcre2grep -m1 -O '=$x{41}$x423$o{103}$o1045=' 'fox') <$srcdir/testdata/grepinputv >>testtrygrep 2>&1 + echo "RC=$?" >>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. + + $cf $srcdir/testdata/grepoutput testtrygrep +diff --git a/src/pcre2grep.c b/src/pcre2grep.c +index 72c11bc..7f92f7d 100644 +--- a/src/pcre2grep.c ++++ b/src/pcre2grep.c +@@ -2934,12 +2934,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; +@@ -2964,6 +2967,7 @@ while (ptr < endptr) + + if (lastmatchnumber > 0 && p > lastmatchrestart && !hyphenprinted) + fprintf(stdout, "--" STDOUT_NL); ++ hyphenpending = FALSE; + + while (p < ptr) + { +@@ -2977,12 +2981,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:", printname); + 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 66af4cf..ca52d8b 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- +@@ -991,3 +992,32 @@ RC=0 + ---------------------------- Test 134 ----------------------------- + =AB3CD5= + RC=0 ++---------------------------- 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.23.0 diff --git a/pcre2.spec b/pcre2.spec index f4ff918c2d7b25d01bf2d11cb79cc4f4c6c43d63..dc6493b0e90d11dac9531c68a8dd933a36564ff7 100644 --- a/pcre2.spec +++ b/pcre2.spec @@ -1,6 +1,6 @@ Name: pcre2 Version: 10.39 -Release: 16 +Release: 17 Summary: Perl Compatible Regular Expressions License: BSD URL: http://www.pcre.org/ @@ -53,6 +53,8 @@ Patch6042: backport-Add-Perl-titlecasing-475.patch Patch6043: backport-Fix-incorrect-positive-error-code-from-pcre2_substitute.patch Patch6044: backport-pcre2_compile-avoid-1-byte-buffer-overread-parsing-V.patch Patch6045: backport-Improve-error-message-for-N-name-in-character-classes.patch +Patch6046: backport-Mend-a-bug-in-pcre2grep-that-caused-separator-lines-.patch +Patch6047: backport-Fix-oversight-in-adding-new-pcre2grep-test.patch BuildRequires: autoconf libtool automake coreutils gcc make readline-devel Obsoletes: pcre2-utf16 pcre2-utf32 pcre2-tools @@ -170,6 +172,9 @@ make check %{_pkgdocdir}/html/ %changelog +* Thu Mar 13 2025 Linux_zhang - 10.39-17 +- sync patches from upstream to fix a bug in pcre2grep + * Tue Nov 19 2024 yanglongkang - 10.39-16 - DESC:sync patches from upstream