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.
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.
* 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
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.
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.
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.
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/
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.
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.
* 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.