Commit Graph

73 Commits

Author SHA1 Message Date
Nicholas Wilson
c98e5d5330 Remove use of 'head' Unix tool in pcre2grep test (#743)
It's not available on Windows, but we hadn't noticed this because it's
provided by the Git for Windows tools which I have installed. This is
not good practice to require these tools as a build dependency.

I have replaced "head -1" with "pcre2grep -m1 .*" which matches and
prints the first line. For consistency, I have made the same change on
Unix.
2025-04-02 20:00:42 +01:00
Nicholas Wilson
30320bb18d Add test and fix for buffer over-read in pcre2grep (#594)
Found by Clang-Analyze in #576

This test fails without the code fix, which required correcting the way
the pcre2grep tests are run with valgrind.

The new test passes with the code changes made.
2024-12-06 17:18:33 +00:00
Philip Hazel
f34fc0a34a 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. 2024-11-27 15:15:45 +00:00
Nicholas Wilson
29e51cfa53 Add RunGrepTest.bat to CMake (#581) 2024-11-27 13:56:50 +01:00
Nicholas Wilson
a67878318c Fix PCRE2_DEBUG for multi-configuration builds (#542)
* Add support for Ninja Multi-Config generator on all platforms
* Ensure one build job is using CMake 3.15
* Provide a build type (Debug or RelWithDebInfo) on all CMake builds
* Ensure PCRE2_DEBUG=ON is set for: dev.yml builds which use the
  Release configuration
2024-11-11 13:16:16 +01:00
Carlo Marcelo Arenas Belón
0d087cce82 pcre2grep: add $& as an alias for $0 (#519)
Perl does not use $0 anymore to refer to the text of the matched subject
and `pcre2_substitute()` was recently updated to also provide that value
using the variable Perl prefers: `$&`.

In a similar context, either as part of the formatted output from a match
or during the processing of a callback, teach pcre2grep to also populate
$&.

While at it, update the ChangeLog with recent changes.
2024-10-09 09:08:27 +01:00
Philip Hazel
c37958dc74 Fix oversight in RunGrepTest in 10.45/2 fix: broken in "make distcheck". 2024-08-31 15:42:52 +01:00
Carlo Marcelo Arenas Belón
7e141969b5 test: use a fully spec locale name in RunGrepTest (#429)
A locale contains an optional charmap that might be relevant in
determining if the setlocale() function considers it valid.

Change the bad locale used when testing to one that contains also
an invalid charmap and therefore fix this test in OpenBSD.
2024-06-18 15:46:41 +01:00
Carlo Marcelo Arenas Belón
c63d7c992e pcre2grep: add --posix-pattern-file for compatibility with other grep (#428)
Historically, pcre2grep has done minor processing of the patterns that
were read through the `-f` option.

The end result is that for some patterns there are different results
depending if they were provided through `-e`, `-f` or as a parameter
in the command line.

Add a flag that could be provided to skip that processing so that the
same pattern file used with other grep implementations could be used
directly for the same result.
2024-06-18 15:45:13 +01:00
Philip Hazel
e179a4b8cc Add --group-separator and --no-group-separator to pcre2grep. 2023-11-20 17:21:17 +00:00
Carlo Marcelo Arenas Belón
3bbdb6dd71 pcre2grep: avoid UCP mode for \d for compatibility with GNU grep (#222)
Matching multi-byte digits was released with GNU grep 3.9 and considered a
regression that required a couple more releases.

While implementations differ on their interpretation of `\d` under Unicode,
there is a recommendation[1] for a POSIX compatible mode that and a suggestion
that it will be better (safer and faster) to only consider ASCII digits for
that class (and [:digit]).

Use the recently introduced PCRE2_EXTRA_ASCII_BSD if `--posix-digit` is used
together with `-u` or `-U` for compatibility with GNU grep.

[1] https://unicode.org/reports/tr18/
2023-04-11 18:03:06 +01:00
Philip Hazel
8385df8c97 Made PCRE2_UCP the default in UTF mode in pcre2grep, and added new options --case-restrict and --no-ucp. 2023-02-08 15:09:18 +00:00
Carlo Marcelo Arenas Belón
d5986092ff test: avoid shell issues with Solaris 10 (#172)
avoiding export combined with assignment is also not valid POSIX sh
2022-12-11 15:11:36 +00:00
Philip Hazel
7c49b40e8a File and documentation tidies for 10.41 release 2022-12-06 15:53:25 +00:00
Carlo Marcelo Arenas Belón
106faa2389 test: avoid double $srcdir references in RunGrepTest (#169)
breaking out of tree runs
2022-12-05 16:16:44 +00:00
Philip Hazel
e653a04473 Update multiple-pattern handling in pcre2grep 2022-11-22 17:52:05 +00:00
Philip Hazel
b73b334767 Discard new Bash LC_TYPE warning in RunGrepTest 2022-10-31 16:25:38 +00:00
Philip Hazel
3a1ad41eca Remove the previous change to the GitHub action which tried running the
pcre2grep test under bash because this didn't fix what went wrong with the
locale test for Alpine Linux. Looks like Alpine doesn't have locale support, so
try skipping the test (well, in practice mocking up the output) when there is
no locale suport.
2022-08-11 18:13:18 +01:00
Philip Hazel
52fb7719ae Add -a to diff in RunGrepTest 2022-08-10 18:16:00 +01:00
Philip Hazel
b980fc60c5 Change hex byte values in printf commands in RunGrepTest to octal, because some
versions of printf don't like hex.
2022-08-10 17:20:38 +01:00
Philip Hazel
95e76968ca Improve LCOV coverage statistics and fix bugs that showed up in pcre2grep while doing this. 2022-08-10 16:08:34 +01:00
Philip Hazel
8b133fa0ba Implement -Z in pcre2grep and update documentation 2022-07-30 17:41:49 +01:00
Jessica Clarke
534b4760e3 RunGrepTest: Fix tests 132 and 133 when srcdir is relative (#71)
Notably, running the script directly from a build subdirectory will
infer srcdir as .. if not otherwise set, but doesn't work for these.
With this commit sh pcre2_grep_test.sh works as expected.
2022-01-04 16:59:03 +00:00
Carlo Marcelo Arenas Belón
7db8784296 pcre2grep: correctly handle multiple passes (#35)
* tests: use a explicit filehandle to share in testing -m

The way stdin is shared to all participants of a subshell varies
per shell, and at least the standard /bin/sh in Solaris seem to
create a new copy for each command, defeating the purpose of the
test.

Use instead exec to create a filehandle that could then be used
explicitly in the test to confirm that the stream is set.

* pcre2grep: correctly handle multiple passes

When the -m option is used, pcre2grep is meant to exit after enough
matches are found but while leaving the stream pinned to the next position
after the last match.

Unfortunately, it wasn't tracking correctly the beginning of the stream
on subsequent passes, and therefore it will fail to use the right seek
value.

Grab the position of the stream at the beginning and while at it, make
sure that the stream passed hasn't been consumed already.
2021-11-09 16:57:48 +00:00
Philip Hazel
31a46200fa Add --allow-lookaround-bsk to pcre2grep 2021-08-31 16:24:25 +01:00
Philip.Hazel
25029849c3 Fix RunGrepTest's handling of binary zeros on Solaris by using /usr/xpg4/bin/tr
instead of tr if /usr/xpg4/bin/tr exists.
2021-02-07 16:43:00 +00:00
Philip.Hazel
027c9375c0 Update RunGrepTest to use tr for handling binary zeros instead of sed, which it
is hoped with increase portability. Bugzilla #2681.
2021-01-04 17:17:48 +00:00
Philip.Hazel
7eb23f423e Final file tidies for 10.36 2020-12-04 14:30:03 +00:00
Philip.Hazel
000bbf2ea7 File tidies for 10.36-RC1 2020-11-06 17:27:35 +00:00
Philip.Hazel
92554d19aa Fix binary zero issue (Bugzilla #2628) in RunGrepTest. 2020-10-09 15:25:27 +00:00
Philip.Hazel
81da2b97e3 pcre2grep update: -m and $x{..}, $o{..} escapes. Also some doc updates. 2020-10-04 16:34:31 +00:00
Philip.Hazel
9e960f5465 Ensure a newline after the final line in a file is output by pcre2grep. 2020-01-25 15:50:44 +00:00
Philip.Hazel
ae9208ab7b Source tidies (trailing spaces) etc. for 10.34-RC1. 2019-10-17 16:39:38 +00:00
Philip.Hazel
90ae0ae01e Fix minor test issues and tidies/updates for 10.34-RC1 testing release. 2019-10-15 15:23:31 +00:00
Philip.Hazel
0d1ab8515f Fix pcre2grep -o bug when ovector overflows; add option to adjust the limit;
raise the default limit; give error if -o requests an uncaptured parens.
2019-06-15 15:51:07 +00:00
Philip.Hazel
4f31de2866 Add support for invalid UTF-8 matching to pcre2grep. 2019-05-28 14:14:22 +00:00
Philip.Hazel
7375089fa5 More file tidies for 10.33-RC1 2019-03-04 18:07:04 +00:00
Philip.Hazel
0448b486e9 Redirect stderr in RunGrepTest instead of appending to testtrygrep from two
different file descriptors, because the latter doesn't always work as expected.
2018-12-06 17:13:41 +00:00
Philip.Hazel
8f1727af98 Cut out test of NUL characters in RunGrepTest for all OS except Linux, as it
doesn't work for *BSD as well as for Solaris and MacOS (which were already cut 
out).
2018-12-06 17:05:06 +00:00
Philip.Hazel
0ad7ff1549 Add --disable-pcre2grep-callout-fork configuration setting. 2018-11-17 16:45:57 +00:00
Philip.Hazel
392974a0cb File tidies and documentation update for 10.32-RC1 Release Candidate. 2018-08-13 11:57:09 +00:00
Philip.Hazel
9d87fcb727 Patches for portability. 2018-06-20 17:05:31 +00:00
Philip.Hazel
fabea723cf Typos in documentation and comments noted by Jason Hood. 2018-06-17 14:13:28 +00:00
Philip.Hazel
04919e9d03 Add support to pcre2grep for binary zeros in -f files. 2018-02-24 17:09:19 +00:00
Philip.Hazel
911d43cd1e Fix \K issues in pcre2grep. 2017-12-26 15:10:04 +00:00
Philip.Hazel
76814d92c7 Fix multiple multiline matching issues in pcre2grep. 2017-11-13 16:52:39 +00:00
Philip.Hazel
72716c1f21 Fudge binary zero pcre2grep test for Darwin, similar to SunOS. 2017-08-18 15:21:08 +00:00
Philip.Hazel
e3052af6fd Cut out the binary zero pcre2grep test on Solaris (SunOS) as it isn't possible
to check the output because sed won't handle binary zeros on Solaris.
2017-07-18 17:22:39 +00:00
Philip.Hazel
76a57bd839 Convert pcre2grep to use new pcre2_compile() options, thereby fixing two minor
(?) bugs.
2017-06-17 11:32:06 +00:00
Philip.Hazel
3d80fa4fc2 Implement PCRE2_NEWLINE_NUL. 2017-05-26 17:14:36 +00:00