diff --git a/.editorconfig b/.editorconfig
index 0a13c4f90..46e84e7e8 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -19,5 +19,5 @@ end_of_line = crlf
insert_final_newline = false
trim_trailing_whitespace = false
-[testdata/test{input,output}{1,2,3,3A,3B,3C,6,28,29}]
+[testdata/test{input,output}{1,2,3,3A,3B,3C,3D,3E,3F,6,28,29}]
charset = latin1
diff --git a/.gitattributes b/.gitattributes
index 363547eee..665fc8ff7 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,8 +1,14 @@
+# Rather than forcing everything to check out with 'correct' (LF) line-endings
+# on Windows, we currently take the approach of forcing only the files which
+# are binary-like and positively do not work if incorrectly converted.
+
testdata/* -text
maint/manifest-* -text
maint/ucptestdata -text
+*.patch -text
*.sh text eol=lf
-*.patch text eol=lf
+*.py text eol=lf
+*.bat text eol=crlf
pcre2-config.in text eol=lf
RunTest text eol=lf
RunGrepTest text eol=lf
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5e87296d6..2e7c7ebbe 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -31,6 +31,8 @@ env:
CFLAGS_GCC_STYLE: '-Wall -Wextra -pedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings -Wimplicit-fallthrough'
CFLAGS_MSVC: '/W3'
CFLAGS_SOLARIS_CC: '-errtags=yes -erroff=E_STATEMENT_NOT_REACHED'
+ # For CMake 4.4 we could use (stronger): -Werror=author -Werror=uninitialized -Werror=unused-cli
+ # It's not available in the CI runners yet.
CMAKE_FLAGS: '-Wdev -Werror=dev -Wdeprecated -Werror=deprecated --warn-uninitialized'
jobs:
@@ -70,6 +72,12 @@ jobs:
- name: Test (pcre2posix program)
run: ./pcre2posix_test -v
+ - name: Test (Python main test script)
+ run: python3 ./RunTest.py
+
+ - name: Test (Python pcre2grep test script)
+ run: python3 ./RunGrepTest.py
+
- name: Install
run: |
make install "DESTDIR=`pwd`/install-dir"
@@ -83,7 +91,7 @@ jobs:
if: github.event_name != 'workflow_dispatch' || (inputs.job_id == 'all' || inputs.job_id == 'alpine')
steps:
- name: Setup
- run: apk add --no-cache automake autoconf gcc libtool make musl-dev git zlib zlib-dev bzip2 bzip2-dev
+ run: apk add --no-cache automake autoconf gcc libtool make musl-dev git zlib zlib-dev bzip2 bzip2-dev python3
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -111,6 +119,12 @@ jobs:
- name: Test (pcre2posix program)
run: ./pcre2posix_test -v
+ - name: Test (Python main test script)
+ run: python3 ./RunTest.py
+
+ - name: Test (Python pcre2grep test script)
+ run: python3 ./RunGrepTest.py
+
- name: Install
run: |
make install "DESTDIR=`pwd`/install-dir"
@@ -136,6 +150,12 @@ jobs:
- name: Test
run: cd build && ctest -j$(sysctl -n hw.ncpu) --output-on-failure && (cat ./Testing/Temporary/LastTest.log || true)
+ - name: Test (shell scripts)
+ run: |
+ cd build
+ ../RunTest --srcdir .. --pcre2test "`pwd`/pcre2test"
+ ../RunGrepTest --srcdir .. --pcre2test "`pwd`/pcre2test" --pcre2grep "`pwd`/pcre2grep"
+
- name: Install
run: |
cd build
diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml
index 4e3840a4c..3a419edba 100644
--- a/.github/workflows/dev.yml
+++ b/.github/workflows/dev.yml
@@ -746,7 +746,7 @@ jobs:
- name: Test
run: |
- srcdir=`pwd` pcre2test=`pwd`/zig-out/bin/pcre2test ./RunTest -bigstack
+ ./RunTest --bigstack --srcdir "`pwd`" --pcre2test "`pwd`/zig-out/bin/pcre2test"
bee:
# Tests with: Bazel build system. A bee goes "buzz buzz buzz(el)".
@@ -764,7 +764,7 @@ jobs:
submodules: true
- name: Build
- run: bazelisk build //... --enable_runfiles --incompatible_strict_action_env
+ run: bazelisk build //...
- name: Test
- run: bazelisk test //... --enable_runfiles --incompatible_strict_action_env --test_output=all
+ run: bazelisk test //... --test_output=all
diff --git a/.gitignore b/.gitignore
index 3b29a7e4f..5eab90f85 100644
--- a/.gitignore
+++ b/.gitignore
@@ -66,6 +66,10 @@ test3input
test3output
test3outputA
test3outputB
+test3outputC
+test3outputD
+test3outputE
+test3outputF
testNinput
testNinputgrep
teststderr
diff --git a/BUILD.bazel b/BUILD.bazel
index ec1b0b9b8..ab34d211d 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -1,6 +1,11 @@
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
-load("@bazel_skylib//rules:native_binary.bzl", "native_test")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
+load("@rules_python//python:defs.bzl", "py_test")
+load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
+
+# We use `buildifier` for auto-formatting our Bazel files.
+# Applied to all Bazel files using:
+# > buildifier --lint=warn *.bazel
copy_file(
name = "config_h_generic",
@@ -94,15 +99,15 @@ cc_library(
":pcre2_chartables_c",
],
hdrs = [":pcre2_h_generic"],
- implementation_deps = [":pcre2_internal_headers"],
defines = [
"PCRE2_STATIC",
],
+ implementation_deps = [":pcre2_internal_headers"],
+ linkstatic = True,
local_defines = LOCAL_DEFINES + [
"PCRE2_CODE_UNIT_WIDTH=8",
],
strip_include_prefix = "src",
- linkstatic = True,
visibility = ["//visibility:public"],
)
@@ -126,11 +131,11 @@ cc_library(
":pcre2_internal_headers",
":pcre2posix_dotc_headers",
],
+ linkstatic = True,
local_defines = LOCAL_DEFINES + [
"PCRE2_CODE_UNIT_WIDTH=8",
],
strip_include_prefix = "src",
- linkstatic = True,
visibility = ["//visibility:public"],
deps = [
":pcre2",
@@ -150,7 +155,6 @@ cc_library(
cc_library(
name = "pcre2test_dotc_headers",
hdrs = [
- "src/pcre2_chkdint.c",
"src/pcre2_tables.c",
"src/pcre2_ucd.c",
"src/pcre2_valid_utf.c",
@@ -176,24 +180,27 @@ cc_binary(
],
)
-filegroup(
- name = "testdata",
+pkg_tar(
+ name = "testdata_tar",
srcs = glob(["testdata/*"]),
+ strip_prefix = ".",
)
-native_test(
+py_test(
name = "pcre2_test",
size = "small",
- src = select({
- "@platforms//os:windows": "RunTest.bat",
- "//conditions:default": "RunTest",
- }),
- out = select({
- "@platforms//os:windows": "RunTest.bat",
- "//conditions:default": "RunTest",
- }),
+ srcs = ["RunTest.py"],
+ args = [
+ "--bazel-runfiles",
+ "--testdatatar",
+ "$(rlocationpath :testdata_tar)",
+ "--pcre2test",
+ "$(rlocationpath :pcre2test)",
+ ],
data = [
":pcre2test",
- ":testdata",
+ ":testdata_tar",
],
+ deps = ["@bazel_tools//tools/python/runfiles"],
+ main = "RunTest.py",
)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 433cc465f..74b8565fa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -106,7 +106,7 @@
# targets.
################################################################################
-# We have used `gersemi` for auto-formatting our CMake files.
+# We use `gersemi` for auto-formatting our CMake files.
# Applied to all CMake files using:
# > pip3 install gersemi
# > gersemi --in-place --line-length 120 --indent 2 \
@@ -405,14 +405,17 @@ if(PCRE2_SUPPORT_JIT STREQUAL "AUTO")
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_INCLUDES "${PROJECT_SOURCE_DIR}/deps/sljit")
- set(_jit_test_source "
+ set(
+ _jit_test_source
+ "
#define SLJIT_CONFIG_AUTO 1
#include \"./sljit_src/sljitConfigCPU.h\"
#if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
#error unsupported
#endif
int main(void) { return 0; }
- ")
+ "
+ )
check_c_source_compiles("${_jit_test_source}" SLJIT_SUPPORTS_THIS_CPU)
cmake_pop_check_state()
@@ -769,11 +772,9 @@ file(REMOVE ${PROJECT_SOURCE_DIR}/src/pcre2.h)
# Parse version numbers and date out of configure.ac
file(
- STRINGS
- ${PROJECT_SOURCE_DIR}/configure.ac
+ STRINGS ${PROJECT_SOURCE_DIR}/configure.ac
configure_lines
- LIMIT_COUNT
- 50 # Read only the first 50 lines of the file
+ LIMIT_COUNT 50 # Read only the first 50 lines of the file
)
set(
@@ -1372,8 +1373,7 @@ if(PCRE2_BUILD_TESTS)
# Write out a CTest configuration file
#
file(
- WRITE
- ${PROJECT_BINARY_DIR}/CTestCustom.ctest
+ WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest
"# This is a generated file.
MESSAGE(\"When testing is complete, review test output in the
\\\"${PROJECT_BINARY_DIR}/Testing/Temporary\\\" folder.\")
@@ -1381,119 +1381,56 @@ MESSAGE(\" \")
"
)
- file(
- WRITE
- ${PROJECT_BINARY_DIR}/pcre2_test.sh
- "#! /bin/sh
-# This is a generated file.
-srcdir=${PROJECT_SOURCE_DIR}
-pcre2test=${PROJECT_BINARY_DIR}/pcre2test
-test -z \"$CMAKE_CONFIG_TYPE\" || pcre2test=${PROJECT_BINARY_DIR}/$CMAKE_CONFIG_TYPE/pcre2test
-. ${PROJECT_SOURCE_DIR}/RunTest
-if test \"$?\" != \"0\"; then exit 1; fi
-# End
-"
- )
-
- if(UNIX)
- add_test(pcre2_test sh ${PROJECT_BINARY_DIR}/pcre2_test.sh)
- endif()
+ find_package(Python3 3.7 COMPONENTS Interpreter)
- if(PCRE2_BUILD_PCRE2GREP)
- file(
- WRITE
- ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh
- "#! /bin/sh
-# This is a generated file.
-srcdir=${PROJECT_SOURCE_DIR}
-pcre2grep=${PROJECT_BINARY_DIR}/pcre2grep
-test -z \"$CMAKE_CONFIG_TYPE\" || pcre2grep=${PROJECT_BINARY_DIR}/$CMAKE_CONFIG_TYPE/pcre2grep
-pcre2test=${PROJECT_BINARY_DIR}/pcre2test
-test -z \"$CMAKE_CONFIG_TYPE\" || pcre2test=${PROJECT_BINARY_DIR}/$CMAKE_CONFIG_TYPE/pcre2test
-. ${PROJECT_SOURCE_DIR}/RunGrepTest
-if test \"$?\" != \"0\"; then exit 1; fi
-# End
-"
+ if(Python3_FOUND)
+ add_test(
+ NAME pcre2_test
+ COMMAND
+ Python3::Interpreter "${PROJECT_SOURCE_DIR}/RunTest.py" --srcdir "${PROJECT_SOURCE_DIR}" --pcre2test
+ "$"
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
)
-
- if(UNIX)
- add_test(pcre2_grep_test sh ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh)
-
- if(PCRE2_EBCDIC)
- # The grep tests currently fail in EBCDIC mode because the test data
- # files are in ASCII. This could be fixed properly, but for now, we
- # have very few EBCDIC users and the pcre2grep utility is hardly even
- # part of the official project artifacts.
- set_property(TEST pcre2_grep_test PROPERTY WILL_FAIL TRUE)
- endif()
- endif()
- endif()
-
- if(WIN32)
- # Provide environment for executing the bat file version of RunTest
- file(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} winsrc)
- file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} winbin)
-
- file(
- WRITE
- ${PROJECT_BINARY_DIR}/pcre2_test.bat
- "\@REM This is a generated file.
-\@echo off
-setlocal
-SET srcdir=\"${winsrc}\"
-SET pcre2test=\"${winbin}\\pcre2test.exe\"
-if not [%CMAKE_CONFIG_TYPE%]==[] SET pcre2test=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcre2test.exe\"
-call %srcdir%\\RunTest.bat
-if errorlevel 1 exit /b 1
-echo RunTest.bat tests successfully completed
-"
+ elseif(UNIX)
+ add_test(
+ NAME pcre2_test
+ COMMAND sh "${PROJECT_SOURCE_DIR}/RunTest" --srcdir "${PROJECT_SOURCE_DIR}" --pcre2test "$"
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
)
+ else()
+ message(FATAL_ERROR "Neither Python nor shell support found for pcre2_test")
+ endif()
- add_test(NAME pcre2_test_bat COMMAND pcre2_test.bat)
- set_tests_properties(pcre2_test_bat PROPERTIES PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed")
-
- if(PCRE2_BUILD_PCRE2GREP)
- file(
- WRITE
- ${PROJECT_BINARY_DIR}/pcre2_grep_test.bat
- "\@REM This is a generated file.
-\@echo off
-setlocal
-SET srcdir=\"${winsrc}\"
-SET pcre2test=\"${winbin}\\pcre2test.exe\"
-if not [%CMAKE_CONFIG_TYPE%]==[] SET pcre2test=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcre2test.exe\"
-SET pcre2grep=\"${winbin}\\pcre2grep.exe\"
-if not [%CMAKE_CONFIG_TYPE%]==[] SET pcre2grep=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcre2grep.exe\"
-call %srcdir%\\RunGrepTest.bat
-if errorlevel 1 exit /b 1
-echo RunGrepTest.bat tests successfully completed
-"
+ if(PCRE2_BUILD_PCRE2GREP)
+ if(Python3_FOUND)
+ add_test(
+ NAME pcre2_grep_test
+ COMMAND
+ Python3::Interpreter "${PROJECT_SOURCE_DIR}/RunGrepTest.py" --srcdir "${PROJECT_SOURCE_DIR}" --pcre2test
+ "$" --pcre2grep "$"
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
)
-
- add_test(NAME pcre2_grep_test_bat COMMAND pcre2_grep_test.bat)
- set_tests_properties(
- pcre2_grep_test_bat
- PROPERTIES PASS_REGULAR_EXPRESSION "RunGrepTest\\.bat tests successfully completed"
+ elseif(UNIX)
+ add_test(
+ NAME pcre2_grep_test
+ COMMAND
+ sh "${PROJECT_SOURCE_DIR}/RunGrepTest" --srcdir "${PROJECT_SOURCE_DIR}" --pcre2test "$"
+ --pcre2grep "$"
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
)
+ else()
+ message(FATAL_ERROR "Neither Python nor shell support found for pcre2_grep_test")
endif()
- if(DEFINED ENV{OSTYPE})
- if("$ENV{OSTYPE}" STREQUAL "msys")
- set(MSYS2 TRUE)
- endif()
- endif()
- if(MSYS2)
- # Both the sh and bat file versions of RunTest are run if make test is used
- # in msys
- add_test(pcre2_test_sh sh.exe ${PROJECT_BINARY_DIR}/pcre2_test.sh)
- if(PCRE2_BUILD_PCRE2GREP)
- add_test(pcre2_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh)
- endif()
+ if(PCRE2_EBCDIC)
+ # The grep tests currently fail in EBCDIC mode because the test data
+ # files are in ASCII. This could be fixed properly, but for now, we
+ # have very few EBCDIC users and the pcre2grep utility is hardly even
+ # part of the official project artifacts.
+ set_property(TEST pcre2_grep_test PROPERTY WILL_FAIL TRUE)
endif()
endif()
- # Changed to accommodate testing whichever location was just built
-
if(PCRE2_SUPPORT_JIT_DETECTED)
add_test(pcre2_jit_test pcre2_jit_test)
endif()
@@ -1589,11 +1526,7 @@ install(FILES ${txts} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/pcre2)
install(FILES ${html} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/pcre2/html)
if(MSVC AND INSTALL_MSVC_PDB)
- install(
- FILES ${DLL_PDB_FILES}
- DESTINATION ${CMAKE_INSTALL_BINDIR}
- CONFIGURATIONS Debug RelWithDebInfo
- )
+ install(FILES ${DLL_PDB_FILES} DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS Debug RelWithDebInfo)
endif()
# Help, only for nice output
@@ -1648,7 +1581,10 @@ if(PCRE2_SHOW_REPORT)
message(STATUS " Build 32 bit pcre2 library ........ : ${PCRE2_BUILD_PCRE2_32}")
message(STATUS " Include debugging code ............ : ${PCRE2_DEBUG}")
if(PCRE2_SUPPORT_JIT STREQUAL "AUTO")
- message(STATUS " Enable JIT compiling support ...... : ${PCRE2_SUPPORT_JIT} (detected: ${PCRE2_SUPPORT_JIT_DETECTED})")
+ message(
+ STATUS
+ " Enable JIT compiling support ...... : ${PCRE2_SUPPORT_JIT} (detected: ${PCRE2_SUPPORT_JIT_DETECTED})"
+ )
else()
message(STATUS " Enable JIT compiling support ...... : ${PCRE2_SUPPORT_JIT}")
endif()
diff --git a/MODULE.bazel b/MODULE.bazel
index 67f75af1a..a3f6e7e18 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,9 +1,17 @@
module(
name = "pcre2",
version = "10.49-DEV",
+ # Newer versions of Bazel complain about this setting. The change to ignore
+ # compatibility_level was backported to Bazel 8.6 and Bazel 9.1, but not
+ # Bazel 7. Removing it would therefore be equivalent to changing the
+ # level to zero on older Bazel versions, which is a breaking change.
+ # Please don't remove this just to silence a warning, until all the old
+ # versions have dropped out of use.
compatibility_level = 1,
)
-bazel_dep(name = "rules_cc", version = "0.2.8")
-bazel_dep(name = "bazel_skylib", version = "1.8.1")
+bazel_dep(name = "rules_cc", version = "0.2.18")
+bazel_dep(name = "rules_python", version = "1.7.0")
+bazel_dep(name = "rules_pkg", version = "1.3.0")
+bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "platforms", version = "1.0.0")
diff --git a/Makefile.am b/Makefile.am
index 4580a2da9..41a939acf 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -406,16 +406,16 @@ if WITH_EBCDIC
if WITH_EBCDIC_NL25
src/pcre2_chartables.c: $(srcdir)/src/pcre2_chartables.c.ebcdic-1047-nl25
rm -f $@
- $(LN_S) $(abs_srcdir)/src/pcre2_chartables.c.ebcdic-1047-nl25 $(abs_builddir)/src/pcre2_chartables.c
+ $(LN_S) "$(abs_srcdir)/src/pcre2_chartables.c.ebcdic-1047-nl25" "$(abs_builddir)/src/pcre2_chartables.c"
else # WITH_EBCDIC_NL25
src/pcre2_chartables.c: $(srcdir)/src/pcre2_chartables.c.ebcdic-1047-nl15
rm -f $@
- $(LN_S) $(abs_srcdir)/src/pcre2_chartables.c.ebcdic-1047-nl15 $(abs_builddir)/src/pcre2_chartables.c
+ $(LN_S) "$(abs_srcdir)/src/pcre2_chartables.c.ebcdic-1047-nl15" "$(abs_builddir)/src/pcre2_chartables.c"
endif # WITH_EBCDIC_NL25
else # WITH_EBCDIC
src/pcre2_chartables.c: $(srcdir)/src/pcre2_chartables.c.dist
rm -f $@
- $(LN_S) $(abs_srcdir)/src/pcre2_chartables.c.dist $(abs_builddir)/src/pcre2_chartables.c
+ $(LN_S) "$(abs_srcdir)/src/pcre2_chartables.c.dist" "$(abs_builddir)/src/pcre2_chartables.c"
endif # WITH_EBCDIC
endif # WITH_REBUILD_CHARTABLES
@@ -744,18 +744,16 @@ endif # WITH_GCOV
## The main library tests. Each test is a binary plus a script that runs that
## binary in various ways. We install these test binaries in case folks find it
-## helpful. The two .bat files are for running the tests under Windows.
+## helpful.
TESTS += RunTest
-EXTRA_DIST += RunTest.bat
-dist_noinst_SCRIPTS += RunTest
+dist_noinst_SCRIPTS += RunTest RunTest.py
## When the 8-bit library is configured, pcre2grep will have been built.
if WITH_PCRE2_8
TESTS += RunGrepTest
-EXTRA_DIST += RunGrepTest.bat
-dist_noinst_SCRIPTS += RunGrepTest
+dist_noinst_SCRIPTS += RunGrepTest RunGrepTest.py
if WITH_EBCDIC
XFAIL_TESTS += RunGrepTest
endif # WITH_EBCDIC
@@ -826,7 +824,10 @@ EXTRA_DIST += \
testdata/testoutput3 \
testdata/testoutput3A \
testdata/testoutput3B \
+ testdata/testoutput3C \
testdata/testoutput3D \
+ testdata/testoutput3E \
+ testdata/testoutput3F \
testdata/testoutput4 \
testdata/testoutput5 \
testdata/testoutput6 \
@@ -868,8 +869,6 @@ EXTRA_DIST += \
testdata/testoutputheap-32 \
testdata/testoutputheap-8 \
testdata/valgrind-jit.supp \
- testdata/wintestinput3 \
- testdata/wintestoutput3 \
perltest.sh
# RunTest and RunGrepTest should clean up after themselves, but just in case
@@ -882,6 +881,10 @@ CLEANFILES += \
test3output \
test3outputA \
test3outputB \
+ test3outputC \
+ test3outputD \
+ test3outputE \
+ test3outputF \
testtry \
teststdout \
teststderr \
diff --git a/NON-AUTOTOOLS-BUILD b/NON-AUTOTOOLS-BUILD
index 45c8bad39..43a10a152 100644
--- a/NON-AUTOTOOLS-BUILD
+++ b/NON-AUTOTOOLS-BUILD
@@ -11,7 +11,7 @@ This document contains the following sections:
Comments about Win32 builds
Building PCRE2 on Windows with CMake
Building PCRE2 on Windows with Visual Studio
- Testing with RunTest.bat
+ Testing with Python
Building PCRE2 on z/OS and z/VM
Building PCRE2 under VMS
@@ -183,18 +183,18 @@ example.
Some tests are relevant only when certain build-time options are selected.
For example, test 4 is for Unicode support, and will not run if you have
built PCRE2 without it. See the comments at the start of each testinput
- file. If you have a suitable Unix-like shell, the RunTest script will run
- the appropriate tests for you. The command "RunTest list" will output a
- list of all the tests.
+ file. The Python script RunTest.py will run the appropriate tests on
+ Unix-like systems and Windows. A Unix shell version is also available
+ as RunTest. The command "python3 RunTest.py list" (or "RunTest list" for
+ the shell version) will output a list of all the tests.
Note that the supplied files are in Unix format, with just LF characters
- as line terminators. You may need to edit them to change this if your
- system uses a different convention.
+ as line terminators.
(10) If you have built PCRE2 with SUPPORT_JIT, the JIT features can be tested
by running pcre2test with the -jit option. This is done automatically by
- the RunTest script. You might also like to build and run the freestanding
- JIT test program, src/pcre2_jit_test.c.
+ RunTest.py and RunTest. You might also like to build and run the
+ freestanding JIT test program, src/pcre2_jit_test.c.
(11) The pcre2test program tests the POSIX wrapper library, but there is also a
freestanding test program in src/pcre2posix_test.c. It must be linked with
@@ -371,52 +371,48 @@ be deleted.
Regardless of build system used, `ctest` will run the tests.
-Building PCRE2 on Windows with Visual Studio
---------------------------------------------
+Testing with Python
+-------------------
-The code currently cannot be compiled without an inttypes.h header, which is
-available only with Visual Studio 2013 or newer. However, this portable and
-permissively-licensed implementation of the stdint.h header could be used as an
-alternative:
+The autotools build uses `make check` to run the test suites using the `RunTest`
+and `RunGrepTest` shell (bash) scripts. The test suite is also available for
+non-Unix platforms using the equivalent `RunTest.py` and `RunGrepTest.py` Python
+scripts instead.
- http://www.azillionmonkeys.com/qed/pstdint.h
+These Python scripts can be used with any build system, and should work on
+supported PCRE2 platforms.
-Just rename it and drop it into the top level of the build tree.
+The autotools build only uses the shell scripts.
+The CMake build tests for a Python 3 installation, and defaults to registering
+the Python scripts with CTest. If Python 3 is not found, CMake registers the
+shell scripts on Unix, or fails otherwise.
-Testing with RunTest.bat
-------------------------
-
-If configured with CMake, building the test project ("make test" or building
-ALL_TESTS in Visual Studio) creates (and runs) pcre2_test.bat (and depending
-on your configuration options, possibly other test programs) in the build
-directory. The pcre2_test.bat script runs RunTest.bat with correct source and
-exe paths.
-
-For manual testing with RunTest.bat, provided the build dir is a subdirectory
-of the source directory: Open command shell window. Chdir to the location
-of your pcre2test.exe and pcre2grep.exe programs. Call RunTest.bat with
-"..\RunTest.Bat" or "..\..\RunTest.bat" as appropriate.
-
-To run only a particular test with RunTest.Bat provide a test number argument.
-
-Otherwise:
-
-1. Copy RunTest.bat into the directory where pcre2test.exe and pcre2grep.exe
- have been created.
+On Windows, the requirement for a Python installation to run the test suite can
+be avoided by passing `-DPCRE2_BUILD_TESTS=OFF`, although releasing untested
+builds is not recommended.
-2. Edit RunTest.bat to identify the full or relative location of
- the pcre2 source (wherein which the testdata folder resides), e.g.:
+After building, run CTest in the usual way, specifying the configuration for a
+multi-configuration generator. For example:
- set srcdir=C:\pcre2\pcre2-10.00
+ cmake --build build --config Release
+ ctest --test-dir build -C Release --output-on-failure
-3. In a Windows command environment, chdir to the location of your bat and
- exe programs.
+The scripts can also be run directly from the build directory. If the source
+and executable paths cannot be inferred from that directory, pass them
+explicitly. For example:
-4. Run RunTest.bat. Test outputs will automatically be compared to expected
- results, and discrepancies will be identified in the console output.
+ python3 ../RunTest.py --srcdir .. --pcre2test ./Release/pcre2test.exe
+ python3 ../RunGrepTest.py --srcdir .. ^
+ --pcre2test ./Release/pcre2test.exe ^
+ --pcre2grep ./Release/pcre2grep.exe
-To independently test the just-in-time compiler, run pcre2_jit_test.exe.
+The runner scripts (shell and Python) support out-of-tree builds by accepting
+commandline arguments specifying the location of the srcdir (the directory
+containing the `testdata/` directory); of `pcre2test[.exe]`; and for
+`RunGrepTest` and `RunGrepTest.py`, `pcre2grep[.exe]`. Alternatively,
+environment variables can be used to pass the paths; and if none are provided
+the working directory is used.
Building PCRE2 on z/OS and z/VM
diff --git a/README b/README
index 3adf495a9..f07ada8fc 100644
--- a/README
+++ b/README
@@ -632,18 +632,24 @@ pages.
Testing PCRE2
-------------
-To test the basic PCRE2 library on a Unix-like system, run the RunTest script.
-There is another script called RunGrepTest that tests the pcre2grep command.
+To test the basic PCRE2 library on a Unix-like system, run the RunTest shell
+script. A portable Python version is available as RunTest.py. There are
+corresponding RunGrepTest and RunGrepTest.py scripts that test the pcre2grep
+command. Run the scripts from the build directory; for example:
+
+ python3 ../RunTest.py
+ python3 ../RunGrepTest.py
+
When the 8-bit library is built, a test program for the POSIX wrapper, called
pcre2posix_test, is compiled, and when JIT support is enabled, a test program
called pcre2_jit_test is built. The scripts and the program tests are all run
-when you obey "make check". For other environments, see the instructions in
+when you run "make check". For other environments, see the instructions in
NON-AUTOTOOLS-BUILD.
-The RunTest script runs the pcre2test test program (which is documented in its
-own man page) on each of the relevant testinput files in the testdata
-directory, and compares the output with the contents of the corresponding
-testoutput files. RunTest places its output in directories
+The RunTest (and RunTest.py) scripts run the pcre2test test program (which is
+documented in its own man page) on each of the relevant testinput files in the
+testdata directory, and compare the output with the contents of the
+corresponding testoutput files. The output is placed in directories
testoutput{8,16,32}{,-jit,-dfa}. Other files whose names begin with "test" are
used as working files in some tests.
@@ -930,9 +936,9 @@ The distribution should contain the files listed below.
NON-AUTOTOOLS-BUILD notes on building PCRE2 without using autotools
README this file
RunTest a Unix shell script for running tests
+ RunTest.py a portable Python script for running tests
RunGrepTest a Unix shell script for pcre2grep tests
- RunTest.bat a Windows batch file for running tests
- RunGrepTest.bat a Windows batch file for pcre2grep tests
+ RunGrepTest.py a portable Python script for pcre2grep tests
aclocal.m4 m4 macros (generated by "aclocal")
m4/* m4 macros (used by autoconf)
configure a configuring shell script (built by autoconf)
diff --git a/RunGrepTest b/RunGrepTest
index eaed73f7f..70c11998a 100755
--- a/RunGrepTest
+++ b/RunGrepTest
@@ -10,7 +10,7 @@
# * Use \0 for binary zero in printf, not \x0, for the benefit of older
# versions (and use octal for other special values).
-# Set the C locale, so that sort(1) behaves predictably.
+# Set the C locale, so that sort(1) and pcre2grep itself behave predictably.
LC_ALL=C
export LC_ALL
@@ -25,29 +25,49 @@ unset cp ls mv rm
# valgrind settings when requested.
builddir=`pwd`
-: ${pcre2grep:=$builddir/pcre2grep}
-: ${pcre2test:=$builddir/pcre2test}
+: ${pcre2grep:=./pcre2grep}
+: ${pcre2test:=./pcre2test}
+pcre2grep_opts=
-if [ ! -x $pcre2grep ] ; then
+valgrind=
+while [ $# -gt 0 ] ; do
+ case $1 in
+ valgrind|-valgrind|--valgrind) valgrind="valgrind -q --leak-check=no --smc-check=all-non-file --error-exitcode=70";;
+ srcdir|-srcdir|--srcdir) if [ $# -lt 2 ]; then echo "Missing argument after '$1'"; exit 1; fi; shift; srcdir="$1";;
+ pcre2test|-pcre2test|--pcre2test) if [ $# -lt 2 ]; then echo "Missing argument after '$1'"; exit 1; fi; shift; pcre2test="$1";;
+ pcre2grep|-pcre2grep|--pcre2grep) if [ $# -lt 2 ]; then echo "Missing argument after '$1'"; exit 1; fi; shift; pcre2grep="$1";;
+ *) echo "RunGrepTest: Unknown argument $1"; exit 1;;
+ esac
+ shift
+done
+
+# Validate paths after argument processing
+
+if [ ! -x "$pcre2grep" ] ; then
echo "** $pcre2grep does not exist or is not executable."
exit 1
fi
-if [ ! -x $pcre2test ] ; then
+if [ ! -x "$pcre2test" ] ; then
echo "** $pcre2test does not exist or is not executable."
exit 1
fi
-valgrind=
-while [ $# -gt 0 ] ; do
- case $1 in
- valgrind|-valgrind) valgrind="valgrind -q --leak-check=no --smc-check=all-non-file --error-exitcode=70";;
- *) echo "RunGrepTest: Unknown argument $1"; exit 1;;
- esac
- shift
-done
+# Support relative paths for pcre2test and pcre2grep; these are referenced after
+# changing directory to srcdir.
-pcre2grep_version=`$pcre2grep -V`
+case "$pcre2grep" in
+ /*) ;;
+ *) pcre2grep="$builddir/$pcre2grep";;
+esac
+case "$pcre2test" in
+ /*) ;;
+ *) pcre2test="$builddir/$pcre2test";;
+esac
+
+# Print the version header
+
+pcre2grep_version=`"$pcre2grep" -V`
if [ "$valgrind" = "" ] ; then
echo "Testing $pcre2grep_version"
else
@@ -55,13 +75,10 @@ else
fi
# Set up a suitable "diff" command for comparison. Some systems have a diff
-# that lacks a -u option. Try to deal with this; better do the test for the -b
-# option as well.
+# that lacks a -u option.
cf="diff"
-diff -b /dev/null /dev/null 2>/dev/null && cf="diff -b"
-diff -u /dev/null /dev/null 2>/dev/null && cf="diff -u"
-diff -ub /dev/null /dev/null 2>/dev/null && cf="diff -ub"
+diff -u /dev/null /dev/null 2>/dev/null && cf="diff -u"
# Add a -a (always treat as text) if available. This was added in an attempt
# to get more detail from an Alpine Linux test failure on GitHub.
@@ -89,7 +106,12 @@ fi
# Subsequently, we run most of the pcre2grep tests in the source directory so
# that the file names in the output are always the same.
-if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then
+if [ -n "$srcdir" ] ; then
+ if [ ! -d "$srcdir/testdata" ] ; then
+ echo "The specified srcdir '$srcdir' does not contain a testdata directory"
+ exit 1
+ fi
+else
if [ -d "./testdata" ] ; then
srcdir=.
elif [ -d "../testdata" ] ; then
@@ -104,7 +126,7 @@ fi
vjs=
if [ "$valgrind" != "" ] ; then
- $pcre2test -C jit >/dev/null
+ "$pcre2test" -C jit >/dev/null
if [ $? -ne 0 ]; then
vjs="--suppressions=`realpath "$srcdir"`/testdata/valgrind-jit.supp"
fi
@@ -112,14 +134,14 @@ fi
# Check for the availability of UTF-8 support
-$pcre2test -C unicode >/dev/null
+"$pcre2test" -C unicode >/dev/null
utf8=$?
# Check default newline convention. If it does not include LF, force LF.
-nl=`$pcre2test -C newline`
+nl=`"$pcre2test" -C newline`
if [ "$nl" != "LF" -a "$nl" != "ANY" -a "$nl" != "ANYCRLF" ]; then
- pcre2grep="$pcre2grep -N LF"
+ pcre2grep_opts="-N LF"
echo "Default newline setting forced to LF"
fi
@@ -127,734 +149,755 @@ fi
checkspecial()
{
- $valgrind $pcre2grep $1 >>testtrygrep 2>&1
- if [ $? -ne $2 ] ; then
- echo "** pcre2grep $1 failed - check testtrygrep"
+ expect=$1
+ shift
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts "$@" >>testtrygrep 2>&1
+ if [ $? -ne "$expect" ] ; then
+ echo "** pcre2grep $* failed - check testtrygrep"
exit 1
fi
}
+# ------ Functions to run with piped output -------
+
+run_sorted()
+ {
+ "$@" >"$builddir/teststdout"
+ grep_rc=$?
+ sort "$builddir/teststdout"
+ # Technique to pipe output to `sort`, while returning the exit code of the
+ # first process in the pipe. Use a file instead.
+ return $grep_rc
+ }
+
+run_null_translated()
+ {
+ "$@" >"$builddir/teststdout"
+ grep_rc=$?
+ $tr '\000' '@' <"$builddir/teststdout"
+ return $grep_rc
+ }
+
# ------ Normal tests ------
echo "Testing pcre2grep main features"
-echo "---------------------------- Test 1 ------------------------------" >testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep PATTERN ./testdata/grepinput) >>testtrygrep
+rm -f testtrygrep
+echo "---------------------------- Test 1 -----------------------------" >testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts PATTERN ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 2 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep '^PATTERN' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 2 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts '^PATTERN' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 3 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -in PATTERN ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 3 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -in PATTERN ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 4 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -ic PATTERN ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 4 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -ic PATTERN ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 5 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -in PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
+echo "---------------------------- Test 5 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -in PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 6 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -inh PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
+echo "---------------------------- Test 6 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -inh PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 7 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -il PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
+echo "---------------------------- Test 7 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -il PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 8 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -l PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
+echo "---------------------------- Test 8 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -l PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 9 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -q PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
+echo "---------------------------- Test 9 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -q PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 10 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 11 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -vn pattern ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -vn pattern ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 12 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -ix pattern ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -ix pattern ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 13 -----------------------------" >>testtrygrep
echo seventeen >testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep -f./testdata/greplist -f $builddir/testtemp1grep ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -f./testdata/greplist -f "$builddir/testtemp1grep" ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 14 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -w pat ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -w pat ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 15 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep 'abc^*' ./testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts 'abc^*' ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 16 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep abc ./testdata/grepinput ./testdata/nonexistfile) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts abc ./testdata/grepinput ./testdata/nonexistfile) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 17 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -M 'the\noutput' ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -M 'the\noutput' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 18 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -Mn '(the\noutput|dog\.\n--)' ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -Mn '(the\noutput|dog\.\n--)' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 19 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -Mix 'Pattern' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -Mix 'Pattern' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 20 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -Mixn 'complete pair\nof lines' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -Mixn 'complete pair\nof lines' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 21 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -nA3 'four' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -nA3 'four' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 22 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -nB3 'four' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -nB3 'four' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 23 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -C3 'four' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -C3 'four' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 24 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -A9 'four' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -A9 'four' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 25 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -nB9 'four' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -nB9 'four' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 26 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -A9 -B9 'four' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -A9 -B9 'four' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 27 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -A10 'four' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -A10 'four' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 28 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -nB10 'four' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -nB10 'four' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 29 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -C12 -B10 'four' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -C12 -B10 'four' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 30 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -inB3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -inB3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 31 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -inA3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -inA3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 32 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -L 'fox' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -L 'fox' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 33 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 34 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -s 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -s 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 35 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinputx --include grepinput8 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
+(cd "$srcdir"; run_sorted $valgrind $vjs "$pcre2grep" $pcre2grep_opts -L -r --include=grepinputx --include grepinput8 --exclude-dir='^\.' 'fox' ./testdata) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 36 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include='grepinput[^C]' --exclude 'grepinput$' --exclude='grepinput(Bad)?8' --exclude=grepinputM --exclude=grepinputUN --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
+(cd "$srcdir"; run_sorted $valgrind $vjs "$pcre2grep" $pcre2grep_opts -L -r --include='grepinput[^C]' --exclude 'grepinput$' --exclude='grepinput(Bad)?8' --exclude=grepinputM --exclude=grepinputUN --exclude-dir='^\.' 'fox' ./testdata) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 37 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep '^(a+)*\d' ./testdata/grepinput) >>testtrygrep 2>teststderrgrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts '^(a+)*\d' ./testdata/grepinput) >>testtrygrep 2>teststderrgrep
echo "RC=$?" >>testtrygrep
echo "======== STDERR ========" >>testtrygrep
cat teststderrgrep >>testtrygrep
-echo "---------------------------- Test 38 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep '>\x00<' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 38 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts '>\x00<' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 39 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -A1 'before the binary zero' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 39 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -A1 'before the binary zero' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 40 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -B1 'after the binary zero' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 40 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -B1 'after the binary zero' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 41 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -B1 -o '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 41 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -B1 -o '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 42 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -B1 -onH '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 42 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -B1 -onH '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 43 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -on 'before|zero|after' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 43 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -on 'before|zero|after' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 44 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -on -e before -ezero -e after ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 44 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -on -e before -ezero -e after ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 45 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -on -f ./testdata/greplist -e binary ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 45 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -on -f ./testdata/greplist -e binary ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 46 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -e 'unopened)' -e abc ./testdata/grepinput) >>testtrygrep 2>&1
+echo "---------------------------- Test 46 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -e 'unopened)' -e abc ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -eabc -e '(unclosed' ./testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -eabc -e '(unclosed' ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -eabc -e xyz -e '[unclosed' ./testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -eabc -e xyz -e '[unclosed' ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --regex=123 -eabc -e xyz -e '[unclosed' ./testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --regex=123 -eabc -e xyz -e '[unclosed' ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 47 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -Fx "AB.VE
+echo "---------------------------- Test 47 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -Fx "AB.VE
elephant" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 48 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -F "AB.VE
+echo "---------------------------- Test 48 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -F "AB.VE
elephant" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 49 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -F -e DATA -e "AB.VE
+echo "---------------------------- Test 49 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -F -e DATA -e "AB.VE
elephant" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 50 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtrygrep
+echo "---------------------------- Test 50 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 51 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -Mv "brown\sfox" ./testdata/grepinputv) >>testtrygrep
+echo "---------------------------- Test 51 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -Mv "brown\sfox" ./testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 52 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --colour=always jumps ./testdata/grepinputv) >>testtrygrep
+echo "---------------------------- Test 52 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --colour=always jumps ./testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 53 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --file-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 53 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --file-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 54 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 54 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --line-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 55 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -f./testdata/greplist --color=always ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -f./testdata/greplist --color=always ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 56 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -c --exclude=grepinputC lazy ./testdata/grepinput*) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -c --exclude=grepinputC lazy ./testdata/grepinput*) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 57 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -c -l --exclude=grepinputC lazy ./testdata/grepinput*) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -c -l --exclude=grepinputC lazy ./testdata/grepinput*) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 58 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --regex=PATTERN ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --regex=PATTERN ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 59 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --regexp=PATTERN ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --regexp=PATTERN ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 60 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --regex PATTERN ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --regex PATTERN ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 61 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --regexp PATTERN ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --regexp PATTERN ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 62 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $pcre2grep --match-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind "$pcre2grep" $pcre2grep_opts --match-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 63 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $pcre2grep --recursion-limit=1K --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind "$pcre2grep" $pcre2grep_opts --recursion-limit=1K --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 64 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o1 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 64 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o1 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 65 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 65 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 66 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o3 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 66 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o3 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 67 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o12 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 67 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o12 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 68 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --only-matching=2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 68 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --only-matching=2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 69 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -vn --colour=always pattern ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -vn --colour=always pattern ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 70 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --color=always -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --color=always -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --color=always -M -n "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --color=always -M -n "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -M -n "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -M -n "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 71 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 72 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --color=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --color=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 73 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o --colour=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 74 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o "^01|02|^03" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o "^01|02|^03" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 75 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --color=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --color=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 76 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o --colour=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 77 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o "^01|^02|03" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o "^01|^02|03" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 78 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --color=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --color=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 79 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o --colour=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 80 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o "\b01|\b02" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o "\b01|\b02" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 81 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --color=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --color=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 82 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o --colour=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 83 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --buffer-size=10 --max-buffer-size=100 "^a" ./testdata/grepinput3) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --buffer-size=10 --max-buffer-size=100 "^a" ./testdata/grepinput3) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 84 -----------------------------" >>testtrygrep
echo testdata/grepinput3 >testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep --file-list ./testdata/grepfilelist --file-list $builddir/testtemp1grep "fox|complete|t7") >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --file-list ./testdata/grepfilelist --file-list "$builddir/testtemp1grep" "fox|complete|t7") >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 85 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --file-list=./testdata/grepfilelist "dolor" ./testdata/grepinput3) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --file-list=./testdata/grepfilelist "dolor" ./testdata/grepinput3) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 86 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 87 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep "cat" ./testdata/grepbinary) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts "cat" ./testdata/grepbinary) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 88 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -v "cat" ./testdata/grepbinary) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -v "cat" ./testdata/grepbinary) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 89 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -I "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -I "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 90 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --binary-files=without-match "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --binary-files=without-match "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 91 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -a "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -a "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 92 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --binary-files=text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --binary-files=text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 93 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 94 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinputx --include grepinput8 'fox' ./testdata/grepinput* | sort) >>testtrygrep
+(cd "$srcdir"; run_sorted $valgrind $vjs "$pcre2grep" $pcre2grep_opts -L -r --include=grepinputx --include grepinput8 'fox' ./testdata/grepinput*) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 95 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --file-list ./testdata/grepfilelist --exclude grepinputv "fox|complete") >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --file-list ./testdata/grepfilelist --exclude grepinputv "fox|complete") >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 96 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include-dir=testdata --exclude '^(?!grepinput)' --exclude=grepinput[MCU] 'fox' ./test* | sort) >>testtrygrep
+(cd "$srcdir"; run_sorted $valgrind $vjs "$pcre2grep" $pcre2grep_opts -L -r --include-dir=testdata --exclude '^(?!grepinput)' --exclude=grepinput[MCU] 'fox' ./test*) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 97 -----------------------------" >>testtrygrep
echo "grepinput$" >testtemp1grep
echo "grepinput8" >>testtemp1grep
echo "grepinputBad8" >>testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinput --exclude=grepinput[MCU] --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
+(cd "$srcdir"; run_sorted $valgrind $vjs "$pcre2grep" $pcre2grep_opts -L -r --include=grepinput --exclude=grepinput[MCU] --exclude-from "$builddir/testtemp1grep" --exclude-dir='^\.' 'fox' ./testdata) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 98 -----------------------------" >>testtrygrep
echo "grepinput$" >testtemp1grep
echo "grepinput8" >>testtemp1grep
echo "grepinputBad8" >>testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --exclude=grepinput3 --exclude=grepinput[MCU] --include=grepinput --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
+(cd "$srcdir"; run_sorted $valgrind $vjs "$pcre2grep" $pcre2grep_opts -L -r --exclude=grepinput3 --exclude=grepinput[MCU] --include=grepinput --exclude-from "$builddir/testtemp1grep" --exclude-dir='^\.' 'fox' ./testdata) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 99 -----------------------------" >>testtrygrep
echo "grepinput$" >testtemp1grep
echo "grepinput8" >testtemp2grep
echo "grepinputBad8" >>testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include grepinput --exclude=grepinput[MCU] --exclude-from $builddir/testtemp1grep --exclude-from=$builddir/testtemp2grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
+(cd "$srcdir"; run_sorted $valgrind $vjs "$pcre2grep" $pcre2grep_opts -L -r --include grepinput --exclude=grepinput[MCU] --exclude-from "$builddir/testtemp1grep" --exclude-from="$builddir/testtemp2grep" --exclude-dir='^\.' 'fox' ./testdata) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 100 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -Ho2 --only-matching=1 -o3 '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 100 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -Ho2 --only-matching=1 -o3 '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 101 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o3 -Ho2 -o12 --only-matching=1 -o3 --colour=always --om-separator='|' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 101 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o3 -Ho2 -o12 --only-matching=1 -o3 --colour=always --om-separator='|' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 102 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -n "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 103 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 104 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -n --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 105 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --colour=always "ipsum|" ./testdata/grepinput3) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --colour=always "ipsum|" ./testdata/grepinput3) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 106 -----------------------------" >>testtrygrep
-(cd $srcdir; echo "a" | $valgrind $vjs $pcre2grep -M "|a" ) >>testtrygrep 2>&1
+(cd "$srcdir"; echo "a" | $valgrind $vjs "$pcre2grep" $pcre2grep_opts -M "|a" ) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 107 -----------------------------" >>testtrygrep
echo "a" >testtemp1grep
echo "aaaaa" >>testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets --allow-lookaround-bsk '(?<=\Ka)' $builddir/testtemp1grep) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --line-offsets --allow-lookaround-bsk '(?<=\Ka)' "$builddir/testtemp1grep") >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 108 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -lq PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
+echo "---------------------------- Test 108 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -lq PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 109 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -cq --exclude=grepinputC lazy ./testdata/grepinput*) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -cq --exclude=grepinputC lazy ./testdata/grepinput*) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 110 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --om-separator / -Mo0 -o1 -o2 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --om-separator / -Mo0 -o1 -o2 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 111 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets -M 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --line-offsets -M 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 112 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --file-offsets -M 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --file-offsets -M 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 113 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --total-count --exclude=grepinputC 'the' testdata/grepinput*) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --total-count --exclude=grepinputC 'the' testdata/grepinput*) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 114 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -tc --exclude=grepinputC 'the' testdata/grepinput*) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -tc --exclude=grepinputC 'the' testdata/grepinput*) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 115 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -tlc --exclude=grepinputC 'the' testdata/grepinput*) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -tlc --exclude=grepinputC 'the' testdata/grepinput*) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 116 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --exclude=grepinput[MCU] -th 'the' testdata/grepinput*) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --exclude=grepinput[MCU] -th 'the' testdata/grepinput*) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 117 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -tch --exclude=grepinputC 'the' testdata/grepinput*) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -tch --exclude=grepinputC 'the' testdata/grepinput*) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 118 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -tL --exclude=grepinputC 'the' testdata/grepinput*) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -tL --exclude=grepinputC 'the' testdata/grepinput*) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 119 -----------------------------" >>testtrygrep
printf '123\n456\n789\n---abc\ndef\nxyz\n---\n' >testNinputgrep
-$valgrind $vjs $pcre2grep -Mo '(\n|[^-])*---' testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -Mo '(\n|[^-])*---' testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-echo "---------------------------- Test 120 ------------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -HO '$0:$2$1$3' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
+echo "---------------------------- Test 120 -----------------------------" >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -HO '$0:$2$1$3' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -HO '$&:$2$1$3' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -HO '$&:$2$1$3' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -m 1 -O '$0:$a$b$e$f$r$t$v' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -m 1 -O '$0:$a$b$e$f$r$t$v' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -HO '${X}' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -HO '${X}' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -HO 'XX$' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -HO 'XX$' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -O '$x{12345678}' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -O '$x{12345678}' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -O '$x{123Z' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -O '$x{123Z' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --output '$x{1234}' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --output '$x{1234}' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 121 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -F '\E and (regex)' testdata/grepinputv) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -F '\E and (regex)' testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 122 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -w 'cat|dog' testdata/grepinputv) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -w 'cat|dog' testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 123 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -w 'dog|cat' testdata/grepinputv) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -w 'dog|cat' testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 124 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -Mn --colour=always 'start[\s]+end' testdata/grepinputM) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -Mn --colour=always 'start[\s]+end' testdata/grepinputM) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -Mn --colour=always -A2 'start[\s]+end' testdata/grepinputM) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -Mn --colour=always -A2 'start[\s]+end' testdata/grepinputM) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -Mn 'start[\s]+end' testdata/grepinputM) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -Mn 'start[\s]+end' testdata/grepinputM) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -Mn -A2 'start[\s]+end' testdata/grepinputM) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -Mn -A2 'start[\s]+end' testdata/grepinputM) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 125 -----------------------------" >>testtrygrep
printf 'abcd\n' >testNinputgrep
-$valgrind $vjs $pcre2grep --colour=always --allow-lookaround-bsk '(?<=\K.)' testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --colour=always --allow-lookaround-bsk '(?<=\K.)' testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --colour=always --allow-lookaround-bsk '(?=.\K)' testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --colour=always --allow-lookaround-bsk '(?=.\K)' testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --colour=always --allow-lookaround-bsk '(?<=\K[ac])' testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --colour=always --allow-lookaround-bsk '(?<=\K[ac])' testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --colour=always --allow-lookaround-bsk '(?=[ac]\K)' testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --colour=always --allow-lookaround-bsk '(?=[ac]\K)' testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-GREP_COLORS='ms=1;20' $valgrind $vjs $pcre2grep --colour=always --allow-lookaround-bsk '(?=[ac]\K)' testNinputgrep >>testtrygrep
+GREP_COLORS='ms=1;20' $valgrind $vjs "$pcre2grep" $pcre2grep_opts --colour=always --allow-lookaround-bsk '(?=[ac]\K)' testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 126 -----------------------------" >>testtrygrep
printf 'Next line pattern has binary zero\nABC\0XYZ\n' >testtemp1grep
printf 'ABC\0XYZ\nABCDEF\nDEFABC\n' >testtemp2grep
-$valgrind $vjs $pcre2grep -a -f testtemp1grep testtemp2grep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -a -f testtemp1grep testtemp2grep >>testtrygrep
echo "RC=$?" >>testtrygrep
printf 'Next line pattern is erroneous.\n^abc)(xy' >testtemp1grep
-$valgrind $vjs $pcre2grep -a -f testtemp1grep testtemp2grep >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -a -f testtemp1grep testtemp2grep >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 127 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o --om-capture=0 'pattern()()()()' testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o --om-capture=0 'pattern()()()()' testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 128 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -m1M -o1 --om-capture=0 'pattern()()()()' testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -m1M -o1 --om-capture=0 'pattern()()()()' testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 129 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -m 2 'fox' testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -m 2 'fox' testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 130 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o -m2 'fox' testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o -m2 'fox' testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 131 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -oc -m2 'fox' testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -oc -m2 'fox' testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 132 -----------------------------" >>testtrygrep
-(cd $srcdir; exec 3>testtrygrep 2>&1
-echo "RC=$?" >>testtrygrep
+(cd "$srcdir"; exec 3>testtrygrep 2>&1
echo "---------------------------- Test 133 -----------------------------" >>testtrygrep
-(cd $srcdir; exec 3>testtrygrep 2>&1
-echo "RC=$?" >>testtrygrep
+(cd "$srcdir"; exec 3>testtrygrep 2>&1
echo "---------------------------- Test 134 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --max-count=1 -nH -O '=$x{41}$x423$o{103}$o1045=' 'fox' -) <$srcdir/testdata/grepinputv >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --max-count=1 -nH -O '=$x{41}$x423$o{103}$o1045=' 'fox' -) <"$srcdir/testdata/grepinputv" >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 135 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -HZ 'word' ./testdata/grepinputv) | $tr '\000' '@' >>testtrygrep
+(cd "$srcdir"; run_null_translated $valgrind $vjs "$pcre2grep" $pcre2grep_opts -HZ 'word' ./testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -lZ 'word' ./testdata/grepinputv ./testdata/grepinputv) | $tr '\000' '@' >>testtrygrep
+(cd "$srcdir"; run_null_translated $valgrind $vjs "$pcre2grep" $pcre2grep_opts -lZ 'word' ./testdata/grepinputv ./testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -A 1 -B 1 -HZ 'word' ./testdata/grepinputv) | $tr '\000' '@' >>testtrygrep
+(cd "$srcdir"; run_null_translated $valgrind $vjs "$pcre2grep" $pcre2grep_opts -A 1 -B 1 -HZ 'word' ./testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -MHZn 'start[\s]+end' testdata/grepinputM) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -MHZn 'start[\s]+end' testdata/grepinputM) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 136 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -m1MK -o1 --om-capture=0 'pattern()()()()' testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -m1MK -o1 --om-capture=0 'pattern()()()()' testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --max-count=1MK -o1 --om-capture=0 'pattern()()()()' testdata/grepinput) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --max-count=1MK -o1 --om-capture=0 'pattern()()()()' testdata/grepinput) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 137 -----------------------------" >>testtrygrep
printf 'Last line\nhas no newline' >testtemp1grep
-$valgrind $vjs $pcre2grep -A1 Last testtemp1grep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -A1 Last testtemp1grep >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 138 -----------------------------" >>testtrygrep
printf 'AbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\n' >testtemp1grep
-$valgrind $vjs $pcre2grep --no-jit --heap-limit=0 b testtemp1grep >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --no-jit --heap-limit=0 b testtemp1grep >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 139 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --line-buffered 'fox' testdata/grepinputv) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --line-buffered 'fox' testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 140 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --buffer-size=10 -A1 'brown' testdata/grepinputv) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --buffer-size=10 -A1 'brown' testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 141 -----------------------------" >>testtrygrep
printf "%s/testdata/grepinputv\n-\n" "$srcdir" >testtemp1grep
printf 'This is a line from stdin.' >testtemp2grep
-$valgrind $vjs $pcre2grep --file-list testtemp1grep "line from stdin" >testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --file-list testtemp1grep "line from stdin" >testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 142 -----------------------------" >>testtrygrep
printf "/does/not/exist\n" >testtemp1grep
printf 'This is a line from stdin.' >testtemp2grep
-$valgrind $vjs $pcre2grep --file-list testtemp1grep "line from stdin" >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --file-list testtemp1grep "line from stdin" >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 143 -----------------------------" >>testtrygrep
printf 'fox|cat' >testtemp1grep
-$valgrind $vjs $pcre2grep -f - $srcdir/testdata/grepinputv >testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -f - "$srcdir/testdata/grepinputv" >testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 144 -----------------------------" >>testtrygrep
-$valgrind $vjs $pcre2grep -f /non/exist $srcdir/testdata/grepinputv >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -f /non/exist "$srcdir/testdata/grepinputv" >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 145 -----------------------------" >>testtrygrep
printf '*meta*\rdog.' >testtemp1grep
-$valgrind $vjs $pcre2grep -Ncr -F -f testtemp1grep $srcdir/testdata/grepinputv >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -Ncr -F -f testtemp1grep "$srcdir/testdata/grepinputv" >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 146 -----------------------------" >>testtrygrep
printf 'A123B' >testtemp1grep
-$valgrind $vjs $pcre2grep -H -e '123|fox' - >testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -H -e '123|fox' - >testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep -h -e '123|fox' - $srcdir/testdata/grepinputv >testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -h -e '123|fox' - "$srcdir/testdata/grepinputv" >testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep - $srcdir/testdata/grepinputv >testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts - "$srcdir/testdata/grepinputv" >testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 147 -----------------------------" >>testtrygrep
-$valgrind $vjs $pcre2grep -e '123|fox' -- -nonfile >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -e '123|fox' -- -nonfile >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
printf 'A123B' >testtemp1grep
printf 'C123D' > ./-testtemp1grep
-$valgrind $vjs $pcre2grep '123' -- -testtemp1grep >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts '123' -- -testtemp1grep >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep '123' testtemp1grep -- -testtemp1grep >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts '123' testtemp1grep -- -testtemp1grep >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep '123' -- >testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts '123' -- >testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
printf 'E123F' > ./--
-$valgrind $vjs $pcre2grep -- '123' -- >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -- '123' -- >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 148 -----------------------------" >>testtrygrep
-$valgrind $vjs $pcre2grep --nonexist >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --nonexist >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep -n-n-bad >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -n-n-bad >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --context >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --context >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --only-matching --output=xx >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --only-matching --output=xx >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --colour=badvalue >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --colour=badvalue >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --newline=badvalue >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --newline=badvalue >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep -d badvalue >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -d badvalue >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep -D badvalue >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -D badvalue >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --buffer-size=0 >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --buffer-size=0 >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --exclude '(badpat' abc /dev/null >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --exclude '(badpat' abc /dev/null >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --exclude-from /non/exist abc /dev/null >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --exclude-from /non/exist abc /dev/null >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --include-from /non/exist abc /dev/null >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --include-from /non/exist abc /dev/null >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --file-list=/non/exist abc /dev/null >>testtrygrep 2>&1
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --file-list=/non/exist abc /dev/null >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 149 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --binary-files=binary "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --binary-files=binary "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --binary-files=wrong "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --binary-files=wrong "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
# This test runs the code that tests locale support. However, on some systems
@@ -869,8 +912,7 @@ if [ $? -ne 0 ]; then
echo "pcre2grep: Failed to set locale locale.bad (obtained from LC_CTYPE)" >>testtrygrep
echo "RC=2" >>testtrygrep
else
-
- (cd $srcdir; unset LC_ALL; LC_CTYPE=locale.bad; export LC_CTYPE; $valgrind $vjs $pcre2grep abc /dev/null >>$builddir/testtrygrep 2>&1) >testtemp1grep 2>&1
+ (cd "$srcdir"; unset LC_ALL; LC_CTYPE=locale.bad; export LC_CTYPE; $valgrind $vjs "$pcre2grep" $pcre2grep_opts abc /dev/null >>"$builddir/testtrygrep" 2>&1) >testtemp1grep 2>&1
echo "RC=$?" >>testtrygrep
shell_errors=`cat testtemp1grep`
if [ x"$shell_errors" != x ] ; then
@@ -880,68 +922,68 @@ else
fi
echo "---------------------------- Test 151 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep --colour=always -e this -e The -e 'The wo' testdata/grepinputv) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --colour=always -e this -e The -e 'The wo' testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 152 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -nA3 --group-separator='++' 'four' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -nA3 --group-separator='++' 'four' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 153 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -nA3 --no-group-separator 'four' ./testdata/grepinputx) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -nA3 --no-group-separator 'four' ./testdata/grepinputx) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 154 -----------------------------" >>testtrygrep
>testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep -f $builddir/testtemp1grep ./testdata/grepinputv) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -f "$builddir/testtemp1grep" ./testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 155 -----------------------------" >>testtrygrep
echo "" >testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep -f $builddir/testtemp1grep ./testdata/grepinputv) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -f "$builddir/testtemp1grep" ./testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 156 -----------------------------" >>testtrygrep
echo "" >testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep --posix-pattern-file --file $builddir/testtemp1grep ./testdata/grepinputv) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --posix-pattern-file --file "$builddir/testtemp1grep" ./testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 157 -----------------------------" >>testtrygrep
echo "spaces " >testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep -o --posix-pattern-file --file=$builddir/testtemp1grep ./testdata/grepinputv >$builddir/testtemp2grep && $valgrind $vjs $pcre2grep -q "s " $builddir/testtemp2grep) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -o --posix-pattern-file --file="$builddir/testtemp1grep" ./testdata/grepinputv >"$builddir/testtemp2grep" && $valgrind $vjs "$pcre2grep" $pcre2grep_opts -q "s " "$builddir/testtemp2grep") >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 158 -----------------------------" >>testtrygrep
echo "spaces." >testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep -f $builddir/testtemp1grep ./testdata/grepinputv) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -f "$builddir/testtemp1grep" ./testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 159 -----------------------------" >>testtrygrep
printf "spaces.\r\n" >testtemp1grep
-(cd $srcdir; $valgrind $vjs $pcre2grep --posix-pattern-file -f$builddir/testtemp1grep ./testdata/grepinputv) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --posix-pattern-file -f"$builddir/testtemp1grep" ./testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 160 -----------------------------" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -nC3 '^(ert|jkl)' ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -nC3 '^(ert|jkl)' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
-(cd $srcdir; $valgrind $vjs $pcre2grep -n -B4 -A2 '^(ert|dfg)' ./testdata/grepinput) >>testtrygrep
+(cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -B4 -A2 '^(ert|dfg)' ./testdata/grepinput) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test 161 -----------------------------" >>testtrygrep
printf 'XfooY\n' >testNinputgrep
-$valgrind $vjs $pcre2grep --allow-lookaround-bsk -o '(?=foo\K)' testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --allow-lookaround-bsk -o '(?=foo\K)' testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --allow-lookaround-bsk --output '$0' '(?=foo\K)' testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --allow-lookaround-bsk --output '$0' '(?=foo\K)' testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --allow-lookaround-bsk --line-offsets '(?=foo\K)' testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --allow-lookaround-bsk --line-offsets '(?=foo\K)' testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep --allow-lookaround-bsk --file-offsets '(?=foo\K)' testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts --allow-lookaround-bsk --file-offsets '(?=foo\K)' testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
# Now compare the results.
-$cf $srcdir/testdata/grepoutput testtrygrep
+$cf "$srcdir/testdata/grepoutput" testtrygrep
if [ $? != 0 ] ; then exit 1; fi
@@ -950,225 +992,226 @@ if [ $? != 0 ] ; then exit 1; fi
if [ $utf8 -ne 0 ] ; then
echo "Testing pcre2grep UTF-8 features"
- echo "---------------------------- Test U1 ------------------------------" >testtrygrep
- (cd $srcdir; $valgrind $vjs $pcre2grep -n -u --newline=any "^X" ./testdata/grepinput8) >>testtrygrep
+ rm -f testtrygrep
+ echo "---------------------------- Test U1 -----------------------------" >testtrygrep
+ (cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -u --newline=any "^X" ./testdata/grepinput8) >>testtrygrep
echo "RC=$?" >>testtrygrep
- echo "---------------------------- Test U2 ------------------------------" >>testtrygrep
- (cd $srcdir; $valgrind $vjs $pcre2grep -n -u -C 3 --newline=any "Match" ./testdata/grepinput8) >>testtrygrep
+ echo "---------------------------- Test U2 -----------------------------" >>testtrygrep
+ (cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -u -C 3 --newline=any "Match" ./testdata/grepinput8) >>testtrygrep
echo "RC=$?" >>testtrygrep
- echo "---------------------------- Test U3 ------------------------------" >>testtrygrep
- (cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets -u --newline=any --allow-lookaround-bsk '(?<=\K\x{17f})' ./testdata/grepinput8) >>testtrygrep
+ echo "---------------------------- Test U3 -----------------------------" >>testtrygrep
+ (cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts --line-offsets -u --newline=any --allow-lookaround-bsk '(?<=\K\x{17f})' ./testdata/grepinput8) >>testtrygrep
echo "RC=$?" >>testtrygrep
- echo "---------------------------- Test U4 ------------------------------" >>testtrygrep
- (cd $srcdir; $valgrind $vjs $pcre2grep -u -o '....' ./testdata/grepinputBad8) >>testtrygrep 2>&1
+ echo "---------------------------- Test U4 -----------------------------" >>testtrygrep
+ (cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -u -o '....' ./testdata/grepinputBad8) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
- echo "---------------------------- Test U5 ------------------------------" >>testtrygrep
- (cd $srcdir; $valgrind $vjs $pcre2grep -U -o '....' ./testdata/grepinputBad8) >>testtrygrep
+ echo "---------------------------- Test U5 -----------------------------" >>testtrygrep
+ (cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -U -o '....' ./testdata/grepinputBad8) >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "---------------------------- Test U6 -----------------------------" >>testtrygrep
- (cd $srcdir; $valgrind $vjs $pcre2grep -u -m1 -O '=$x{1d3}$o{744}=' 'fox') <$srcdir/testdata/grepinputv >>testtrygrep 2>&1
+ (cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -u -m1 -O '=$x{1d3}$o{744}=' 'fox') <"$srcdir/testdata/grepinputv" >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
- echo "---------------------------- Test U7 ------------------------------" >>testtrygrep
- (cd $srcdir; $valgrind $vjs $pcre2grep -ui --colour=always 'k+|\babc\b' ./testdata/grepinput8) >>testtrygrep
+ echo "---------------------------- Test U7 -----------------------------" >>testtrygrep
+ (cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -ui --colour=always 'k+|\babc\b' ./testdata/grepinput8) >>testtrygrep
echo "RC=$?" >>testtrygrep
- echo "---------------------------- Test U8 ------------------------------" >>testtrygrep
- (cd $srcdir; $valgrind $vjs $pcre2grep -UiEP --colour=always 'k+|\babc\b' ./testdata/grepinput8) >>testtrygrep
+ echo "---------------------------- Test U8 -----------------------------" >>testtrygrep
+ (cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -UiEP --colour=always 'k+|\babc\b' ./testdata/grepinput8) >>testtrygrep
echo "RC=$?" >>testtrygrep
- echo "---------------------------- Test U9 ------------------------------" >>testtrygrep
- (cd $srcdir; $valgrind $vjs $pcre2grep -u --colour=always 'A\d' ./testdata/grepinput8) >>testtrygrep
+ echo "---------------------------- Test U9 -----------------------------" >>testtrygrep
+ (cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -u --colour=always 'A\d' ./testdata/grepinput8) >>testtrygrep
echo "RC=$?" >>testtrygrep
- echo "---------------------------- Test U10 ------------------------------" >>testtrygrep
- (cd $srcdir; $valgrind $vjs $pcre2grep -u --posix-digit --colour=always 'A\d' ./testdata/grepinput8) >>testtrygrep
+ echo "---------------------------- Test U10 -----------------------------" >>testtrygrep
+ (cd "$srcdir"; $valgrind $vjs "$pcre2grep" $pcre2grep_opts -u --posix-digit --colour=always 'A\d' ./testdata/grepinput8) >>testtrygrep
echo "RC=$?" >>testtrygrep
- echo "---------------------------- Test U11 ------------------------------" >>testtrygrep
+ echo "---------------------------- Test U11 -----------------------------" >>testtrygrep
printf '................................................' | tr '.' '\200' >testtemp1grep
printf 'x\n' >>testtemp1grep
- $valgrind $vjs $pcre2grep --no-jit --buffer-size=16 -U --allow-lookaround-bsk -o '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts --no-jit --buffer-size=16 -U --allow-lookaround-bsk -o '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "only-matching RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep --no-jit --buffer-size=16 -U --allow-lookaround-bsk -M '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts --no-jit --buffer-size=16 -U --allow-lookaround-bsk -M '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "multiline RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep --no-jit --buffer-size=16 -U --allow-lookaround-bsk --colour=always '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts --no-jit --buffer-size=16 -U --allow-lookaround-bsk --colour=always '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "colour RC=$?" >>testtrygrep
- echo "---------------------------- Test U12 ------------------------------" >>testtrygrep
+ echo "---------------------------- Test U12 -----------------------------" >>testtrygrep
# Colouring only, so the subject is a single line. An empty match at the end
# of the subject, then one that matches before retrying at the end.
printf 'abc\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n --colour=always -u '$' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --colour=always -u '$' testtemp1grep >>testtrygrep 2>&1
echo "colour-empty-at-end RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n --colour=always -u '.?' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --colour=always -u '.?' testtemp1grep >>testtrygrep 2>&1
echo "colour-nonempty-then-empty RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n --colour=always -u '^' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --colour=always -u '^' testtemp1grep >>testtrygrep 2>&1
echo "colour-empty-at-start RC=$?" >>testtrygrep
# An empty line, so the first match is empty with nothing following it, and a
# final line with no newline, so a restart can reach the end of the line.
printf '\nabc\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n --colour=always -u '.?' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --colour=always -u '.?' testtemp1grep >>testtrygrep 2>&1
echo "colour-empty-line RC=$?" >>testtrygrep
printf 'abc' >testtemp1grep
- $valgrind $vjs $pcre2grep -n --colour=always -u '.?' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --colour=always -u '.?' testtemp1grep >>testtrygrep 2>&1
echo "colour-no-final-newline RC=$?" >>testtrygrep
# Multiline, where a restart may have to move on to a following line.
printf 'a\nb\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n -M -u '$' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -u '$' testtemp1grep >>testtrygrep 2>&1
echo "multiline-empty-at-line-end RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -M -u '^' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -u '^' testtemp1grep >>testtrygrep 2>&1
echo "multiline-empty-at-line-start RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -M -u '.?' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -u '.?' testtemp1grep >>testtrygrep 2>&1
echo "multiline-nonempty-then-empty RC=$?" >>testtrygrep
# A match that spans several lines, so that the restart has to skip over more
# than one line before looking for the next match.
printf 'a\nb\nc\nd\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n -M -u '(?s)a.*c' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -u '(?s)a.*c' testtemp1grep >>testtrygrep 2>&1
echo "multiline-spanning RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -M -u '(?s)a.*c|$' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -u '(?s)a.*c|$' testtemp1grep >>testtrygrep 2>&1
echo "multiline-spanning-then-empty RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -M --colour=always -u '(?s)a.*c|$' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M --colour=always -u '(?s)a.*c|$' testtemp1grep >>testtrygrep 2>&1
echo "multiline-colour-spanning RC=$?" >>testtrygrep
# Invalid UTF-8 after an empty match, which is when the scan over
# continuation bytes that follow the restart point can run. Here the scan
# stops at the start of the next character.
printf 'x\200\200y\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n --colour=always -U '^' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --colour=always -U '^' testtemp1grep >>testtrygrep 2>&1
echo "colour-utf-scan-to-char RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -M -U '^' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -U '^' testtemp1grep >>testtrygrep 2>&1
echo "multiline-utf-scan-to-char RC=$?" >>testtrygrep
# The continuation bytes run up to the newline, and then up to the end of the
# subject, when there is no newline to stop the scan.
printf 'x\200\200\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n --colour=always -U '^' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --colour=always -U '^' testtemp1grep >>testtrygrep 2>&1
echo "colour-utf-scan-to-newline RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -M -U '^' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -U '^' testtemp1grep >>testtrygrep 2>&1
echo "multiline-utf-scan-to-newline RC=$?" >>testtrygrep
printf 'x\200\200' >testtemp1grep
- $valgrind $vjs $pcre2grep -n --colour=always -U '^' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --colour=always -U '^' testtemp1grep >>testtrygrep 2>&1
echo "colour-utf-scan-to-end RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -M -U '^' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -U '^' testtemp1grep >>testtrygrep 2>&1
echo "multiline-utf-scan-to-end RC=$?" >>testtrygrep
# A subject that is nothing but continuation bytes, so the very first match
# is empty and the scan immediately reaches the end.
printf '\200\200' >testtemp1grep
- $valgrind $vjs $pcre2grep -n --colour=always -U '.?' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --colour=always -U '.?' testtemp1grep >>testtrygrep 2>&1
echo "colour-utf-only-continuations RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -M -U '.?' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -U '.?' testtemp1grep >>testtrygrep 2>&1
echo "multiline-utf-only-continuations RC=$?" >>testtrygrep
# Continuation bytes at the end of a multi-line subject, reached after an
# empty match on an earlier line, and after a match that spans lines.
printf 'a\nb\n\n\200\200' >testtemp1grep
- $valgrind $vjs $pcre2grep -n -M -U '.?' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -U '.?' testtemp1grep >>testtrygrep 2>&1
echo "multiline-utf-trailing RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -M -U '$' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -U '$' testtemp1grep >>testtrygrep 2>&1
echo "multiline-utf-trailing-empty RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -M --colour=always -U '(?s)a.*b|$' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M --colour=always -U '(?s)a.*b|$' testtemp1grep >>testtrygrep 2>&1
echo "multiline-colour-utf-trailing-spanning RC=$?" >>testtrygrep
- echo "---------------------------- Test U13 ------------------------------" >>testtrygrep
+ echo "---------------------------- Test U13 -----------------------------" >>testtrygrep
# The same restart, but reached by \K rather than by an empty match.
printf 'abc\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n --colour=always -u --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --colour=always -u --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "colour-bsk RC=$?" >>testtrygrep
printf 'a\nb\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n -M -u --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -M -u --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "multiline-bsk RC=$?" >>testtrygrep
# The same, but with the restart landing on invalid UTF-8.
printf 'x\200\200y\n' >testtemp1grep
- $valgrind $vjs $pcre2grep --no-jit -n --colour=always -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts --no-jit -n --colour=always -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "colour-bsk-utf-scan-to-char RC=$?" >>testtrygrep
printf 'x\200\200' >testtemp1grep
- $valgrind $vjs $pcre2grep --no-jit -n -M -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts --no-jit -n -M -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "multiline-bsk-utf-scan-to-end RC=$?" >>testtrygrep
printf 'a\nx\200\200' >testtemp1grep
- $valgrind $vjs $pcre2grep --no-jit -n -M --colour=always -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts --no-jit -n -M --colour=always -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "multiline-colour-bsk-utf-trailing RC=$?" >>testtrygrep
- echo "---------------------------- Test U14 ------------------------------" >>testtrygrep
+ echo "---------------------------- Test U14 -----------------------------" >>testtrygrep
# A pattern that keeps making progress, so the restart is the ordinary one
# and the line is never advanced. This is the path the other U14 tests build on.
printf 'abcabc\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n -o -u 'a.' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -o -u 'a.' testtemp1grep >>testtrygrep 2>&1
echo "control-progress RC=$?" >>testtrygrep
# An empty match, which is the case the restart exists for. "$" matches only
# at the end of the subject, so the restart is immediately at the end; "^"
# matches at the start, so it has to step forward by one character first.
- $valgrind $vjs $pcre2grep -n -o -u '$' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -o -u '$' testtemp1grep >>testtrygrep 2>&1
echo "empty-at-end RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -o -u '^' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -o -u '^' testtemp1grep >>testtrygrep 2>&1
echo "empty-at-start RC=$?" >>testtrygrep
# \K in a lookbehind reports a non-empty match that ends no later than the
# offset it was started from. PCRE2_NOTEMPTY is set once a match has been
# found, so this, unlike an empty match, can stop the loop making progress on
# every iteration and not just the first.
- $valgrind $vjs $pcre2grep -n -o -u --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -o -u --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "bsk-restart RC=$?" >>testtrygrep
# The step forward lands on invalid UTF-8, so the scan over continuation
# bytes runs. Here it stops at the start of the next character, and then at
# the newline, both of which are within the subject.
printf 'x\200\200y\n' >testtemp1grep
- $valgrind $vjs $pcre2grep --no-jit -n -o -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts --no-jit -n -o -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "bsk-utf-scan-to-char RC=$?" >>testtrygrep
printf 'x\200\200\n' >testtemp1grep
- $valgrind $vjs $pcre2grep --no-jit -n -o -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts --no-jit -n -o -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "bsk-utf-scan-to-newline RC=$?" >>testtrygrep
# The same, but with no newline to stop the scan, so it runs to the end of
# the subject and then looks at the byte after it.
printf 'x\200\200' >testtemp1grep
- $valgrind $vjs $pcre2grep --no-jit -n -o -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts --no-jit -n -o -U --allow-lookaround-bsk '(?<=\K.)' testtemp1grep >>testtrygrep 2>&1
echo "bsk-utf-scan-to-end RC=$?" >>testtrygrep
# Moving on to another line, which only happens in multiline mode. The first
# match ends exactly at the start of the next line, so the line is advanced
# and the line number with it; the second ends two lines further on.
printf 'ab\ncd\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n -o -M -u 'ab\n' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -o -M -u 'ab\n' testtemp1grep >>testtrygrep 2>&1
echo "multiline-line-boundary RC=$?" >>testtrygrep
printf 'ab\ncd\nef\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n -o -M -u '(?s)ab.*ef' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -o -M -u '(?s)ab.*ef' testtemp1grep >>testtrygrep 2>&1
echo "multiline-spanning RC=$?" >>testtrygrep
# An empty match in multiline mode, where the step forward is what takes the
# restart past the end of the line.
printf 'a\nb\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n -o -M -u '$' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -o -M -u '$' testtemp1grep >>testtrygrep 2>&1
echo "multiline-empty RC=$?" >>testtrygrep
# A match that ends between the CR and the LF of a CRLF line ending, so the
# restart is past the text of the line but short of the start of the next
# one. Without -M the line is never advanced, so that is the control.
printf 'ab\r\ncd\r\n' >testtemp1grep
- $valgrind $vjs $pcre2grep -n -o -N CRLF '\r' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -o -N CRLF '\r' testtemp1grep >>testtrygrep 2>&1
echo "crlf-not-multiline RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -o -M -N CRLF '\r' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -o -M -N CRLF '\r' testtemp1grep >>testtrygrep 2>&1
echo "crlf-mid-terminator RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -n -o -M -N ANY '\r' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -o -M -N ANY '\r' testtemp1grep >>testtrygrep 2>&1
echo "any-mid-terminator RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep -M -N CRLF --line-offsets '\r' testtemp1grep >>testtrygrep 2>&1
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -M -N CRLF --line-offsets '\r' testtemp1grep >>testtrygrep 2>&1
echo "crlf-mid-terminator-line-offsets RC=$?" >>testtrygrep
- $cf $srcdir/testdata/grepoutput8 testtrygrep
+ $cf "$srcdir/testdata/grepoutput8" testtrygrep
if [ $? != 0 ] ; then exit 1; fi
else
@@ -1186,53 +1229,54 @@ fi
echo "Testing pcre2grep newline settings"
printf 'abc\rdef\r\nghi\njkl' >testNinputgrep
-printf '%c--------------------------- Test N1 ------------------------------\r\n' - >testtrygrep
-$valgrind $vjs $pcre2grep -n -N CR "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
+rm -f testtrygrep
+printf '%c--------------------------- Test N1 -----------------------------\r\n' - >testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -n -N CR "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep -B1 -n -N CR "^def" testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -B1 -n -N CR "^def" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-printf '%c--------------------------- Test N2 ------------------------------\r\n' - >>testtrygrep
-$valgrind $vjs $pcre2grep -n --newline=crlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
+printf '%c--------------------------- Test N2 -----------------------------\r\n' - >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --newline=crlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep -B1 -n -N CRLF "^ghi" testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -B1 -n -N CRLF "^ghi" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-printf '%c--------------------------- Test N3 ------------------------------\r\n' - >>testtrygrep
+printf '%c--------------------------- Test N3 -----------------------------\r\n' - >>testtrygrep
pattern=`printf 'def\rjkl'`
-$valgrind $vjs $pcre2grep -n --newline=cr -F "$pattern" testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --newline=cr -F "$pattern" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-printf '%c--------------------------- Test N4 ------------------------------\r\n' - >>testtrygrep
-$valgrind $vjs $pcre2grep -n --newline=crlf -F -f $srcdir/testdata/greppatN4 testNinputgrep >>testtrygrep
+printf '%c--------------------------- Test N4 -----------------------------\r\n' - >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --newline=crlf -F -f "$srcdir/testdata/greppatN4" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-printf '%c--------------------------- Test N5 ------------------------------\r\n' - >>testtrygrep
-$valgrind $vjs $pcre2grep -n --newline=any "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
+printf '%c--------------------------- Test N5 -----------------------------\r\n' - >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --newline=any "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep -B1 -n --newline=any "^def" testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -B1 -n --newline=any "^def" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-printf '%c--------------------------- Test N6 ------------------------------\r\n' - >>testtrygrep
-$valgrind $vjs $pcre2grep -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
+printf '%c--------------------------- Test N6 -----------------------------\r\n' - >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep -B1 -n --newline=anycrlf "^jkl" testNinputgrep >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -B1 -n --newline=anycrlf "^jkl" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-printf '%c--------------------------- Test N7 ------------------------------\r\n' - >>testtrygrep
+printf '%c--------------------------- Test N7 -----------------------------\r\n' - >>testtrygrep
printf 'xyz\0abc\0def' >testNinputgrep
-$valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep | $tr '\000' '@' >>testtrygrep
+run_null_translated $valgrind $vjs "$pcre2grep" $pcre2grep_opts -na --newline=nul "^(abc|def)" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-$valgrind $vjs $pcre2grep -B1 -na --newline=nul "^(abc|def)" testNinputgrep | $tr '\000' '@' >>testtrygrep
+run_null_translated $valgrind $vjs "$pcre2grep" $pcre2grep_opts -B1 -na --newline=nul "^(abc|def)" testNinputgrep >>testtrygrep
echo "RC=$?" >>testtrygrep
-printf '%c--------------------------- Test N8 ------------------------------\r\n' - >>testtrygrep
-$valgrind $vjs $pcre2grep -na --newline=anycrlf "^a" $srcdir/testdata/grepinputBad8_Trail >>testtrygrep
+printf '%c--------------------------- Test N8 -----------------------------\r\n' - >>testtrygrep
+$valgrind $vjs "$pcre2grep" $pcre2grep_opts -na --newline=anycrlf "^a" "$srcdir/testdata/grepinputBad8_Trail" >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "" >>testtrygrep
-$cf $srcdir/testdata/grepoutputN testtrygrep
+$cf "$srcdir/testdata/grepoutputN" testtrygrep
if [ $? != 0 ] ; then exit 1; fi
@@ -1241,17 +1285,18 @@ if [ $? != 0 ] ; then exit 1; fi
if [ $utf8 -ne 0 ] ; then
echo "Testing pcre2grep newline settings with UTF-8 features"
- printf '%c--------------------------- Test UN1 ------------------------------\r\n' - >testtrygrep
- $valgrind $vjs $pcre2grep -nau --newline=anycrlf "^(abc|def)" $srcdir/testdata/grepinputUN >>testtrygrep
+ rm -f testtrygrep
+ printf '%c--------------------------- Test UN1 -----------------------------\r\n' - >testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -nau --newline=anycrlf "^(abc|def)" "$srcdir/testdata/grepinputUN" >>testtrygrep
echo "RC=$?" >>testtrygrep
- printf '%c--------------------------- Test UN2 ------------------------------\r\n' - >testtrygrep
- $valgrind $vjs $pcre2grep -nauU --newline=anycrlf "^a" $srcdir/testdata/grepinputBad8_Trail >>testtrygrep
+ printf '%c--------------------------- Test UN2 -----------------------------\r\n' - >>testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -nauU --newline=anycrlf "^a" "$srcdir/testdata/grepinputBad8_Trail" >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "" >>testtrygrep
- $cf $srcdir/testdata/grepoutputUN testtrygrep
+ $cf "$srcdir/testdata/grepoutputUN" testtrygrep
if [ $? != 0 ] ; then exit 1; fi
else
echo "Skipping pcre2grep newline UTF-8 tests: no UTF-8 support in PCRE2 library"
@@ -1263,33 +1308,34 @@ fi
# environments that do not support fork(). This is handled by comparing to a
# different output.
-if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q 'callout scripts in patterns are supported'; then
+if $valgrind $vjs "$pcre2grep" $pcre2grep_opts --help | $valgrind $vjs "$pcre2grep" $pcre2grep_opts -q 'callout scripts in patterns are supported'; then
echo "Testing pcre2grep script callouts"
+ rm -f testtrygrep
echo "--- Test 1 ---" >testtrygrep
- $valgrind $vjs $pcre2grep '(T)(..(.))(?C"/bin/echo|Arg1: [$1] [$2] [$3]|Arg2: $|${1}$| ($4) ($14) ($0)")()' $srcdir/testdata/grepinputv >>testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts '(T)(..(.))(?C"/bin/echo|Arg1: [$1] [$2] [$3]|Arg2: $|${1}$| ($4) ($14) ($0)")()' "$srcdir/testdata/grepinputv" >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "--- Test 2 ---" >>testtrygrep
- $valgrind $vjs $pcre2grep '(T)(..(.))()()()()()()()(..)(?C"/bin/echo|Arg1: [$11] [${11}]")' $srcdir/testdata/grepinputv >>testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts '(T)(..(.))()()()()()()()(..)(?C"/bin/echo|Arg1: [$11] [${11}]")' "$srcdir/testdata/grepinputv" >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "--- Test 3 ---" >>testtrygrep
- $valgrind $vjs $pcre2grep '(T)(?C"|$0:$1$n")' $srcdir/testdata/grepinputv >>testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts '(T)(?C"|$0:$1$n")' "$srcdir/testdata/grepinputv" >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "--- Test 4 ---" >>testtrygrep
- $valgrind $vjs $pcre2grep '(T)(?C"/bin/echo|$0:$1$n")' $srcdir/testdata/grepinputv >>testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts '(T)(?C"/bin/echo|$0:$1$n")' "$srcdir/testdata/grepinputv" >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "--- Test 5 ---" >>testtrygrep
- $valgrind $vjs $pcre2grep '(T)(?C"|$1$n")(*F)' $srcdir/testdata/grepinputv >>testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts '(T)(?C"|$1$n")(*F)' "$srcdir/testdata/grepinputv" >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "--- Test 6 ---" >>testtrygrep
- $valgrind $vjs $pcre2grep -m1 '(T)(?C"|$0:$1:$x{41}$o{101}$n")' $srcdir/testdata/grepinputv >>testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -m1 '(T)(?C"|$0:$1:$x{41}$o{101}$n")' "$srcdir/testdata/grepinputv" >>testtrygrep
echo "RC=$?" >>testtrygrep
- if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q 'Non-fork callout scripts in patterns are supported'; then
+ if $valgrind $vjs "$pcre2grep" $pcre2grep_opts --help | $valgrind $vjs "$pcre2grep" $pcre2grep_opts -q 'Non-fork callout scripts in patterns are supported'; then
nonfork=1
- $cf $srcdir/testdata/grepoutputCN testtrygrep
+ $cf "$srcdir/testdata/grepoutputCN" testtrygrep
else
nonfork=0
- $cf $srcdir/testdata/grepoutputC testtrygrep
+ $cf "$srcdir/testdata/grepoutputC" testtrygrep
fi
if [ $? != 0 ] ; then exit 1; fi
@@ -1297,17 +1343,18 @@ if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q 'callout scri
if [ $utf8 -ne 0 ] ; then
echo "Testing pcre2grep script callout with UTF-8 features"
+ rm -f testtrygrep
echo "--- Test 1 ---" >testtrygrep
- $valgrind $vjs $pcre2grep -u '(T)(?C"|$0:$x{a6}$n")' $srcdir/testdata/grepinputv >>testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -u '(T)(?C"|$0:$x{a6}$n")' "$srcdir/testdata/grepinputv" >>testtrygrep
echo "RC=$?" >>testtrygrep
echo "--- Test 2 ---" >>testtrygrep
- $valgrind $vjs $pcre2grep -u '(T)(?C"/bin/echo|$0:$x{a6}$n")' $srcdir/testdata/grepinputv >>testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts -u '(T)(?C"/bin/echo|$0:$x{a6}$n")' "$srcdir/testdata/grepinputv" >>testtrygrep
echo "RC=$?" >>testtrygrep
if [ $nonfork = 1 ] ; then
- $cf $srcdir/testdata/grepoutputCNU testtrygrep
+ $cf "$srcdir/testdata/grepoutputCNU" testtrygrep
else
- $cf $srcdir/testdata/grepoutputCU testtrygrep
+ $cf "$srcdir/testdata/grepoutputCU" testtrygrep
fi
if [ $? != 0 ] ; then exit 1; fi
else
@@ -1322,21 +1369,23 @@ fi
# Test reading .gz and .bz2 files when supported.
-if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q '\.gz are read using zlib'; then
+if $valgrind $vjs "$pcre2grep" $pcre2grep_opts --help | $valgrind $vjs "$pcre2grep" $pcre2grep_opts -q '\.gz are read using zlib'; then
echo "Testing reading .gz file"
- $valgrind $vjs $pcre2grep 'one|two' $srcdir/testdata/grepinputC.gz >testtrygrep
+ rm -f testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts 'one|two' "$srcdir/testdata/grepinputC.gz" >testtrygrep
echo "RC=$?" >>testtrygrep
- $cf $srcdir/testdata/grepoutputCgz testtrygrep
+ $cf "$srcdir/testdata/grepoutputCgz" testtrygrep
if [ $? != 0 ] ; then exit 1; fi
fi
-if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q '\.bz2 are read using bzlib2'; then
+if $valgrind $vjs "$pcre2grep" $pcre2grep_opts --help | $valgrind $vjs "$pcre2grep" $pcre2grep_opts -q '\.bz2 are read using bzlib2'; then
echo "Testing reading .bz2 file"
- $valgrind $vjs $pcre2grep 'one|two' $srcdir/testdata/grepinputC.bz2 >testtrygrep
+ rm -f testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts 'one|two' "$srcdir/testdata/grepinputC.bz2" >testtrygrep
echo "RC=$?" >>testtrygrep
- $valgrind $vjs $pcre2grep 'one|two' $srcdir/testdata/grepnot.bz2 >>testtrygrep
+ $valgrind $vjs "$pcre2grep" $pcre2grep_opts 'one|two' "$srcdir/testdata/grepnot.bz2" >>testtrygrep
echo "RC=$?" >>testtrygrep
- $cf $srcdir/testdata/grepoutputCbz2 testtrygrep
+ $cf "$srcdir/testdata/grepoutputCbz2" testtrygrep
if [ $? != 0 ] ; then exit 1; fi
fi
@@ -1346,19 +1395,20 @@ fi
# is not checked.
echo "Testing miscellaneous pcre2grep arguments (unchecked)"
+rm -f testtrygrep
echo '' >testtrygrep
-checkspecial '-xxxxx' 2
-checkspecial '--help' 0
-checkspecial '--line-buffered --colour=auto abc /dev/null' 1
-checkspecial '--line-buffered --color abc /dev/null' 1
-checkspecial '-dskip abc .' 1
-checkspecial '-Dread -Dskip abc /dev/null' 1
-checkspecial "-f $srcdir/testdata/greplistBad /dev/null" 2
-checkspecial "(unpaired /dev/null" 2
-checkspecial "-e (unpaired1 -e (unpaired2 /dev/null" 2
+checkspecial 2 -xxxxx
+checkspecial 0 --help
+checkspecial 1 --line-buffered --colour=auto abc /dev/null
+checkspecial 1 --line-buffered --color abc /dev/null
+checkspecial 1 -dskip abc .
+checkspecial 1 -Dread -Dskip abc /dev/null
+checkspecial 2 -f "$srcdir/testdata/greplistBad" /dev/null
+checkspecial 2 "(unpaired" /dev/null
+checkspecial 2 -e "(unpaired1" -e "(unpaired2" /dev/null
# Clean up local working files
-rm -f testNinputgrep teststderrgrep testtrygrep testtemp1grep testtemp2grep
+rm -f testNinputgrep teststderrgrep testtrygrep testtemp1grep testtemp2grep teststdout
rm -f ./-testtemp1grep ./--
exit 0
diff --git a/RunGrepTest.bat b/RunGrepTest.bat
deleted file mode 100644
index 38eeabee5..000000000
--- a/RunGrepTest.bat
+++ /dev/null
@@ -1,1338 +0,0 @@
-@echo off
-
-:: Run pcre2grep tests. The assumption is that the PCRE2 tests check the library
-:: itself. What we are checking here is the file handling and options that are
-:: supported by pcre2grep. This script must be run in the build directory.
-:: (jmh: I've only tested in the main directory, using my own builds.)
-
-setlocal enabledelayedexpansion
-
-:: Remove any non-default colouring that the caller may have set.
-
-set PCRE2GREP_COLOUR=
-set PCRE2GREP_COLOR=
-set PCREGREP_COLOUR=
-set PCREGREP_COLOR=
-set GREP_COLORS=
-set GREP_COLOR=
-
-:: Remember the current (build) directory and set the program to be tested.
-
-set builddir="%CD%"
-
-if [%pcre2grep%]==[] set pcre2grep=%builddir%\pcre2grep.exe
-if [%pcre2test%]==[] set pcre2test=%builddir%\pcre2test.exe
-
-if NOT exist %pcre2grep% (
- echo ** %pcre2grep% does not exist.
- exit /b 1
-)
-
-if NOT exist %pcre2test% (
- echo ** %pcre2test% does not exist.
- exit /b 1
-)
-
-for /f "delims=" %%a in ('"%pcre2grep%" -V') do set pcre2grep_version=%%a
-echo Testing %pcre2grep_version%
-
-:: Set up a suitable "diff" command for comparison. Some systems have a diff
-:: that lacks a -u option. Try to deal with this; better do the test for the -b
-:: option as well. Use FC if there's no diff, taking care to ignore equality.
-
-set cf=
-set cfout=
-diff -b nul nul 2>nul && set cf=diff -b
-diff -u nul nul 2>nul && set cf=diff -u
-diff -ub nul nul 2>nul && set cf=diff -ub
-if NOT defined cf (
- set cf=fc /n
- set "cfout=>testcf || (type testcf & cmd /c exit /b 1)"
-)
-
-:: Set srcdir to the current or parent directory, whichever one contains the
-:: test data. Subsequently, we run most of the pcre2grep tests in the source
-:: directory so that the file names in the output are always the same.
-
-if NOT defined srcdir set srcdir=.
-if NOT exist %srcdir%\testdata\ (
- if exist testdata\ (
- set srcdir=.
- ) else if exist ..\testdata\ (
- set srcdir=..
- ) else if exist ..\..\testdata\ (
- set srcdir=..\..
- ) else (
- echo Cannot find the testdata directory
- exit /b 1
- )
-)
-
-:: Check for the availability of UTF-8 support
-
-%pcre2test% -C unicode >nul
-set utf8=%ERRORLEVEL%
-
-:: Check default newline convention. If it does not include LF, force LF.
-
-for /f %%a in ('"%pcre2test%" -C newline') do set nl=%%a
-if NOT "%nl%" == "LF" if NOT "%nl%" == "ANY" if NOT "%nl%" == "ANYCRLF" (
- set pcre2grep=%pcre2grep% -N LF
- echo Default newline setting forced to LF
-)
-
-:: Provide "printf" and "tr" via pcre2test. Windows has no dependable version
-:: of either: the obvious candidates translate what they write according to the
-:: current code page, which mangles any byte greater than 0x7f, and an actual
-:: printf may turn LF into CRLF. pcre2test has undocumented options that do just
-:: as much as these tests need, so that this script can produce exactly the same
-:: bytes as RunGrepTest does with the real printf and tr.
-::
-:: %printf% supports \r, \n, \\, an octal escape such as \0 or \200, and one
-:: %%s substitution; any other escape is left alone, so a literal backslash
-:: has to be written as \\. %tr% changes one byte value into another as it
-:: copies its input.
-
-set printf=%pcre2test% -printf
-set tr=%pcre2test% -tr
-
-:: pcre2grep ends the lines it writes with CRLF on Windows and with LF
-:: elsewhere, which comparison copes with, but a line whose own text ends with
-:: CR then comes out with one CR too many. %fixcrlf% removes it, for tests that
-:: match a CR at the end of a line.
-
-set fixcrlf=%pcre2test% -fixcrlf
-
-:: The script callout tests run printf as a callout, where the program name
-:: cannot be quoted, so keep an unquoted version of the path for them.
-
-set pcre2test_unquoted=%pcre2test:"=%
-
-:: ------ Normal tests ------
-
-echo Testing pcre2grep main features
-
-echo ---------------------------- Test 1 ------------------------------>testtrygrep
-(pushd %srcdir% & %pcre2grep% PATTERN ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 2 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% "^PATTERN" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 3 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -in PATTERN ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 4 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -ic PATTERN ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 5 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -in PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 6 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -inh PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 7 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -il PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 8 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -l PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 9 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -q PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 10 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 11 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -vn pattern ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 12 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -ix pattern ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 13 ----------------------------->>testtrygrep
-echo seventeen >testtemp1grep
-(pushd %srcdir% & %pcre2grep% -f./testdata/greplist -f %builddir%\testtemp1grep ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 14 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -w pat ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 15 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% "abc^*" ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 16 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% abc ./testdata/grepinput ./testdata/nonexistfile & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 17 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -M "the\noutput" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 18 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -Mn "(the\noutput|dog\.\n--)" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 19 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -Mix "Pattern" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 20 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -Mixn "complete pair\nof lines" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 21 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -nA3 "four" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 22 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -nB3 "four" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 23 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -C3 "four" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 24 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -A9 "four" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 25 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -nB9 "four" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 26 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -A9 -B9 "four" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 27 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -A10 "four" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 28 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -nB10 "four" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 29 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -C12 -B10 "four" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 30 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -inB3 "pattern" ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 31 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -inA3 "pattern" ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 32 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -L "fox" ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 33 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% "fox" ./testdata/grepnonexist & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 34 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -s "fox" ./testdata/grepnonexist & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 35 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -L -r --include=grepinputx --include grepinput8 --exclude-dir="^\." "fox" ./testdata | sort & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 36 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -L -r --include="grepinput[^C]" --exclude "grepinput$" --exclude="grepinput(Bad)?8" --exclude=grepinputM --exclude=grepinputUN --exclude-dir="^\." "fox" ./testdata | sort & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 37 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% "^(a+)*\d" ./testdata/grepinput & popd) >>testtrygrep 2>teststderrgrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-echo ======== STDERR ========>>testtrygrep
-type teststderrgrep >>testtrygrep
-
-echo ---------------------------- Test 38 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% ">\x00<" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 39 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -A1 "before the binary zero" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 40 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -B1 "after the binary zero" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 41 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -B1 -o "\w+ the binary zero" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 42 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -B1 -onH "\w+ the binary zero" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 43 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -on "before|zero|after" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 44 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -on -e before -ezero -e after ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 45 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -on -f ./testdata/greplist -e binary ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 46 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -e "unopened)" -e abc ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -eabc -e "(unclosed" ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -eabc -e xyz -e "[unclosed" ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% --regex=123 -eabc -e xyz -e "[unclosed" ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 47 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -Fx AB.VE^
-
-elephant ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 48 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -F AB.VE^
-
-elephant ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 49 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -F -e DATA -e AB.VE^
-
-elephant ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 50 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% "^(abc|def|ghi|jkl)" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 51 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -Mv "brown\sfox" ./testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 52 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% --colour=always jumps ./testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 53 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% --file-offsets "before|zero|after" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 54 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% --line-offsets "before|zero|after" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 55 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -f./testdata/greplist --color=always ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 56 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -c --exclude=grepinputC lazy ./testdata/grepinput* & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 57 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -c -l --exclude=grepinputC lazy ./testdata/grepinput* & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 58 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --regex=PATTERN ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 59 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --regexp=PATTERN ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 60 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --regex PATTERN ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 61 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --regexp PATTERN ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 62 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --match-limit=1000 --no-jit -M "This is a file(.|\R)*file." ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 63 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --recursion-limit=1000 --no-jit -M "This is a file(.|\R)*file." ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 64 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o1 "(?<=PAT)TERN (ap(pear)s)" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 65 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o2 "(?<=PAT)TERN (ap(pear)s)" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 66 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o3 "(?<=PAT)TERN (ap(pear)s)" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 67 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o12 "(?<=PAT)TERN (ap(pear)s)" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 68 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% --only-matching=2 "(?<=PAT)TERN (ap(pear)s)" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 69 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -vn --colour=always pattern ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 70 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --color=always -M "triple:\t.*\n\n" ./testdata/grepinput3 & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% --color=always -M -n "triple:\t.*\n\n" ./testdata/grepinput3 & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -M "triple:\t.*\n\n" ./testdata/grepinput3 & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -M -n "triple:\t.*\n\n" ./testdata/grepinput3 & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 71 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o "^01|^02|^03" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 72 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --color=always "^01|^02|^03" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 73 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o --colour=always "^01|^02|^03" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 74 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o "^01|02|^03" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 75 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --color=always "^01|02|^03" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 76 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o --colour=always "^01|02|^03" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 77 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o "^01|^02|03" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 78 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --color=always "^01|^02|03" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 79 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o --colour=always "^01|^02|03" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 80 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o "\b01|\b02" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 81 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --color=always "\b01|\b02" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 82 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o --colour=always "\b01|\b02" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 83 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --buffer-size=10 --max-buffer-size=100 "^a" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 84 ----------------------------->>testtrygrep
-echo testdata/grepinput3 >testtemp1grep
-(pushd %srcdir% & %pcre2grep% --file-list ./testdata/grepfilelist --file-list %builddir%\testtemp1grep "fox|complete|t7" & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 85 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --file-list=./testdata/grepfilelist "dolor" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 86 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 87 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% "cat" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 88 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -v "cat" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 89 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -I "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 90 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --binary-files=without-match "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 91 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -a "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 92 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --binary-files=text "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 93 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --text "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 94 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -L -r --include=grepinputx --include grepinput8 "fox" ./testdata/grepinput* | sort & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 95 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --file-list ./testdata/grepfilelist --exclude grepinputv "fox|complete" & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 96 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -L -r --include-dir=testdata --exclude "^^(?^!grepinput)" --exclude=grepinput[MCU] "fox" ./test* | sort & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 97 ----------------------------->>testtrygrep
-echo grepinput$>testtemp1grep
-echo grepinput8>>testtemp1grep
-echo grepinputBad8>>testtemp1grep
-(pushd %srcdir% & %pcre2grep% -L -r --include=grepinput --exclude=grepinput[MCU] --exclude-from %builddir%\testtemp1grep --exclude-dir="^\." "fox" ./testdata | sort & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 98 ----------------------------->>testtrygrep
-echo grepinput$>testtemp1grep
-echo grepinput8>>testtemp1grep
-echo grepinputBad8>>testtemp1grep
-(pushd %srcdir% & %pcre2grep% -L -r --exclude=grepinput3 --exclude=grepinput[MCU] --include=grepinput --exclude-from %builddir%\testtemp1grep --exclude-dir="^\." "fox" ./testdata | sort & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 99 ----------------------------->>testtrygrep
-echo grepinput$>testtemp1grep
-echo grepinput8>testtemp2grep
-echo grepinputBad8>>testtemp1grep
-(pushd %srcdir% & %pcre2grep% -L -r --include grepinput --exclude=grepinput[MCU] --exclude-from %builddir%\testtemp1grep --exclude-from=%builddir%\testtemp2grep --exclude-dir="^\." "fox" ./testdata | sort & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 100 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -Ho2 --only-matching=1 -o3 "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 101 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o3 -Ho2 -o12 --only-matching=1 -o3 --colour=always --om-separator="|" "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 102 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -n "^$" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 103 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --only-matching "^$" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 104 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -n --only-matching "^$" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 105 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --colour=always "ipsum|" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 106 ----------------------------->>testtrygrep
-(pushd %srcdir% & echo a| %pcre2grep% -M "|a" & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 107 ----------------------------->>testtrygrep
-echo a>testtemp1grep
-echo aaaaa>>testtemp1grep
-(pushd %srcdir% & %pcre2grep% --line-offsets --allow-lookaround-bsk "(?<=\Ka)" %builddir%\testtemp1grep & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 108 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -lq PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 109 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -cq --exclude=grepinputC lazy ./testdata/grepinput* & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 110 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --om-separator / -Mo0 -o1 -o2 "match (\d+):\n (.)\n" testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 111 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --line-offsets -M "match (\d+):\n (.)\n" testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 112 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --file-offsets -M "match (\d+):\n (.)\n" testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 113 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --total-count --exclude=grepinputC "the" testdata/grepinput* & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 114 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -tc --exclude=grepinputC "the" testdata/grepinput* & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 115 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -tlc --exclude=grepinputC "the" testdata/grepinput* & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 116 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --exclude=grepinput[MCU] -th "the" testdata/grepinput* & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 117 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -tch --exclude=grepinputC "the" testdata/grepinput* & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 118 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -tL --exclude=grepinputC "the" testdata/grepinput* & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 119 ----------------------------->>testtrygrep
-%printf% "123\n456\n789\n---abc\ndef\nxyz\n---\n" >testNinputgrep
-%pcre2grep% -Mo "(\n|[^-])*---" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 120 ------------------------------>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -HO "$0:$2$1$3" "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -HO "$&:$2$1$3" "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -m 1 -O "$0:$a$b$e$f$r$t$v" "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -HO "${X}" "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -HO "XX$" "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -O "$x{12345678}" "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -O "$x{123Z" "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% --output "$x{1234}" "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 121 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -F "\E and (regex)" testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 122 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -w "cat|dog" testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 123 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -w "dog|cat" testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 124 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -Mn --colour=always "start[\s]+end" testdata/grepinputM & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -Mn --colour=always -A2 "start[\s]+end" testdata/grepinputM & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -Mn "start[\s]+end" testdata/grepinputM & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -Mn -A2 "start[\s]+end" testdata/grepinputM & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 125 ----------------------------->>testtrygrep
-%printf% "abcd\n" >testNinputgrep
-%pcre2grep% --colour=always --allow-lookaround-bsk "(?<=\K.)" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --colour=always --allow-lookaround-bsk "(?=.\K)" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --colour=always --allow-lookaround-bsk "(?<=\K[ac])" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --colour=always --allow-lookaround-bsk "(?=[ac]\K)" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-set GREP_COLORS=ms=1;20
-%pcre2grep% --colour=always --allow-lookaround-bsk "(?=[ac]\K)" testNinputgrep >>testtrygrep
-set GREP_COLORS=
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 126 ----------------------------->>testtrygrep
-%printf% "Next line pattern has binary zero\nABC\0XYZ\n" >testtemp1grep
-%printf% "ABC\0XYZ\nABCDEF\nDEFABC\n" >testtemp2grep
-%pcre2grep% -a -f testtemp1grep testtemp2grep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%printf% "Next line pattern is erroneous.\n^abc)(xy" >testtemp1grep
-%pcre2grep% -a -f testtemp1grep testtemp2grep >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 127 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o --om-capture=0 "pattern()()()()" testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 128 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -m1M -o1 --om-capture=0 "pattern()()()()" testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 129 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -m 2 "fox" testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 130 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -o -m2 "fox" testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 131 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -oc -m2 "fox" testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 132 ----------------------------->>testtrygrep
-:: The Unix tests use fd3 here, but Windows only has StdIn/StdOut/StdErr (which, at the kernel
-:: level, are not even numbered). Use a subshell instead.
-(pushd %srcdir% & (%pcre2grep% -m1 -A3 "^match" & echo ---& %pcre2grep% -m1 ".*") >testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 133 ----------------------------->>testtrygrep
-:: The Unix tests use fd3 here, but Windows only has StdIn/StdOut/StdErr (which, at the kernel
-:: level, are not even numbered). Use a subshell instead.
-(pushd %srcdir% & (%pcre2grep% -m1 -A3 "^match" & echo ---& %pcre2grep% -m1 -A3 "^match") >testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 134 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --max-count=1 -nH -O "=$x{41}$x423$o{103}$o1045=" "fox" - & popd) <%srcdir%\testdata\grepinputv >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 135 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -HZ "word" ./testdata/grepinputv & popd) | %tr% \0 @ >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -lZ "word" ./testdata/grepinputv ./testdata/grepinputv & popd) | %tr% \0 @ >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -A 1 -B 1 -HZ "word" ./testdata/grepinputv & popd) | %tr% \0 @ >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -MHZn "start[\s]+end" testdata/grepinputM & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 136 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -m1MK -o1 --om-capture=0 "pattern()()()()" testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% --max-count=1MK -o1 --om-capture=0 "pattern()()()()" testdata/grepinput & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 137 ----------------------------->>testtrygrep
-%printf% "Last line\nhas no newline" >testtemp1grep
-%pcre2grep% -A1 Last testtemp1grep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 138 ----------------------------->>testtrygrep
-%printf% "AbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\nAbC\n" >testtemp1grep
-%pcre2grep% --no-jit --heap-limit=0 b testtemp1grep >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 139 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --line-buffered "fox" testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 140 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --buffer-size=10 -A1 "brown" testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 141 ----------------------------->>testtrygrep
-%printf% "%%s\\testdata\\grepinputv\n-\n" "%srcdir%" >testtemp1grep
-%printf% "This is a line from stdin." >testtemp2grep
-%pcre2grep% --file-list testtemp1grep "line from stdin" >testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 142 ----------------------------->>testtrygrep
-%printf% "/does/not/exist\n" >testtemp1grep
-%printf% "This is a line from stdin." >testtemp2grep
-%pcre2grep% --file-list testtemp1grep "line from stdin" >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 143 ----------------------------->>testtrygrep
-%printf% "fox|cat" >testtemp1grep
-%pcre2grep% -f - %srcdir%\testdata\grepinputv >testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 144 ----------------------------->>testtrygrep
-%pcre2grep% -f /non/exist %srcdir%\testdata\grepinputv >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 145 ----------------------------->>testtrygrep
-%printf% "*meta*\rdog." >testtemp1grep
-%pcre2grep% -Ncr -F -f testtemp1grep %srcdir%\testdata\grepinputv >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 146 ----------------------------->>testtrygrep
-%printf% "A123B" >testtemp1grep
-%pcre2grep% -H -e "123|fox" - >testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% -h -e "123|fox" - %srcdir%\testdata\grepinputv >testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% - %srcdir%\testdata\grepinputv >testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 147 ----------------------------->>testtrygrep
-%pcre2grep% -e "123|fox" -- -nonfile >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%printf% "A123B" >testtemp1grep
-%printf% "C123D" >.\-testtemp1grep
-%pcre2grep% "123" -- -testtemp1grep >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% "123" testtemp1grep -- -testtemp1grep >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% "123" -- >testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%printf% "E123F" >.\--
-%pcre2grep% -- "123" -- >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 148 ----------------------------->>testtrygrep
-%pcre2grep% --nonexist >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% -n-n-bad >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --context >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --only-matching --output=xx >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --colour=badvalue >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --newline=badvalue >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% -d badvalue >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% -D badvalue >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --buffer-size=0 >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --exclude "(badpat" abc /dev/null >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --exclude-from /non/exist abc /dev/null >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --include-from /non/exist abc /dev/null >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --file-list=/non/exist abc /dev/null >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 149 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --binary-files=binary "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% --binary-files=wrong "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 150 ----------------------------->>testtrygrep
-:: The Unix version of this tests checks for whether locales are supported. On Windows,
-:: we assume they always are.
-set LC_ALL=
-set LC_CTYPE=locale.bad
-(pushd %srcdir% & %pcre2grep% abc /dev/null & popd) >>testtrygrep 2>&1
-echo RC=^%ERRORLEVEL%>>testtrygrep
-set LC_CTYPE=
-
-echo ---------------------------- Test 151 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% --colour=always -e this -e The -e "The wo" testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 152 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -nA3 --group-separator="++" "four" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 153 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -nA3 --no-group-separator "four" ./testdata/grepinputx & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 154 ----------------------------->>testtrygrep
-echo. >nul 2>testtemp1grep
-(pushd %srcdir% & %pcre2grep% -f %builddir%\testtemp1grep ./testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 155 ----------------------------->>testtrygrep
-echo. >testtemp1grep
-(pushd %srcdir% & %pcre2grep% -f %builddir%\testtemp1grep ./testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 156 ----------------------------->>testtrygrep
-%printf% "\n" >testtemp1grep
-(pushd %srcdir% & %pcre2grep% --posix-pattern-file --file %builddir%\testtemp1grep ./testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 157 ----------------------------->>testtrygrep
-%printf% "spaces \n" >testtemp1grep
-(pushd %srcdir% & %pcre2grep% -o --posix-pattern-file --file=%builddir%\testtemp1grep ./testdata/grepinputv >%builddir%\testtemp2grep && %pcre2grep% -q "s " %builddir%\testtemp2grep & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 158 ----------------------------->>testtrygrep
-%printf% "spaces.\n" >testtemp1grep
-(pushd %srcdir% & %pcre2grep% -f %builddir%\testtemp1grep ./testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 159 ----------------------------->>testtrygrep
-%printf% "spaces.\r\n" >testtemp1grep
-(pushd %srcdir% & %pcre2grep% --posix-pattern-file -f%builddir%\testtemp1grep ./testdata/grepinputv & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 160 ----------------------------->>testtrygrep
-(pushd %srcdir% & %pcre2grep% -nC3 "^(ert|jkl)" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-(pushd %srcdir% & %pcre2grep% -n -B4 -A2 "^(ert|dfg)" ./testdata/grepinput & popd) >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test 161 ----------------------------->>testtrygrep
-%printf% "XfooY\n" >testNinputgrep
-%pcre2grep% --allow-lookaround-bsk -o "(?=foo\K)" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --allow-lookaround-bsk --output "$0" "(?=foo\K)" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --allow-lookaround-bsk --line-offsets "(?=foo\K)" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% --allow-lookaround-bsk --file-offsets "(?=foo\K)" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-:: Now compare the results.
-
-%cf% %srcdir%\testdata\grepoutput testtrygrep %cfout%
-if ERRORLEVEL 1 exit /b 1
-
-
-:: These tests require UTF-8 support
-
-if %utf8% neq 0 (
- echo Testing pcre2grep UTF-8 features
-
- echo ---------------------------- Test U1 ------------------------------>testtrygrep
- (pushd %srcdir% & %pcre2grep% -n -u --newline=any "^X" ./testdata/grepinput8 & popd) >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U2 ------------------------------>>testtrygrep
- (pushd %srcdir% & %pcre2grep% -n -u -C 3 --newline=any "Match" ./testdata/grepinput8 & popd) >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U3 ------------------------------>>testtrygrep
- (pushd %srcdir% & %pcre2grep% --line-offsets -u --newline=any --allow-lookaround-bsk "(?<=\K\x{17f})" ./testdata/grepinput8 & popd) >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U4 ------------------------------>>testtrygrep
- (pushd %srcdir% & %pcre2grep% -u -o "...." ./testdata/grepinputBad8 & popd) >>testtrygrep 2>&1
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U5 ------------------------------>>testtrygrep
- (pushd %srcdir% & %pcre2grep% -U -o "...." ./testdata/grepinputBad8 & popd) >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U6 ----------------------------->>testtrygrep
- (pushd %srcdir% & %pcre2grep% -u -m1 -O "=$x{1d3}$o{744}=" "fox" & popd) <%srcdir%\testdata\grepinputv >>testtrygrep 2>&1
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U7 ------------------------------>>testtrygrep
- (pushd %srcdir% & %pcre2grep% -ui --colour=always "k+|\babc\b" ./testdata/grepinput8 & popd) >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U8 ------------------------------>>testtrygrep
- (pushd %srcdir% & %pcre2grep% -UiEP --colour=always "k+|\babc\b" ./testdata/grepinput8 & popd) >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U9 ------------------------------>>testtrygrep
- (pushd %srcdir% & %pcre2grep% -u --colour=always "A\d" ./testdata/grepinput8 & popd) >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U10 ------------------------------>>testtrygrep
- (pushd %srcdir% & %pcre2grep% -u --posix-digit --colour=always "A\d" ./testdata/grepinput8 & popd) >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U11 ------------------------------>>testtrygrep
- %printf% "................................................" | %tr% . \200 >testtemp1grep
- %printf% "x\n" >>testtemp1grep
- %pcre2grep% --no-jit --buffer-size=16 -U --allow-lookaround-bsk -o "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo only-matching RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% --no-jit --buffer-size=16 -U --allow-lookaround-bsk -M "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo multiline RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% --no-jit --buffer-size=16 -U --allow-lookaround-bsk --colour=always "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo colour RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U12 ------------------------------>>testtrygrep
- @REM Colouring only, so the subject is a single line. An empty match at the end
- @REM of the subject, then one that matches before retrying at the end.
- %printf% "abc\n" >testtemp1grep
- %pcre2grep% -n --colour=always -u "$" testtemp1grep >>testtrygrep 2>&1
- echo colour-empty-at-end RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n --colour=always -u ".?" testtemp1grep >>testtrygrep 2>&1
- echo colour-nonempty-then-empty RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n --colour=always -u "^" testtemp1grep >>testtrygrep 2>&1
- echo colour-empty-at-start RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM An empty line, so the first match is empty with nothing following it, and a
- @REM final line with no newline, so a restart can reach the end of the line.
- %printf% "\nabc\n" >testtemp1grep
- %pcre2grep% -n --colour=always -u ".?" testtemp1grep >>testtrygrep 2>&1
- echo colour-empty-line RC=^!ERRORLEVEL!>>testtrygrep
- %printf% "abc" >testtemp1grep
- %pcre2grep% -n --colour=always -u ".?" testtemp1grep >>testtrygrep 2>&1
- echo colour-no-final-newline RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM Multiline, where a restart may have to move on to a following line.
- %printf% "a\nb\n" >testtemp1grep
- %pcre2grep% -n -M -u "$" testtemp1grep >>testtrygrep 2>&1
- echo multiline-empty-at-line-end RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -M -u "^" testtemp1grep >>testtrygrep 2>&1
- echo multiline-empty-at-line-start RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -M -u ".?" testtemp1grep >>testtrygrep 2>&1
- echo multiline-nonempty-then-empty RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM A match that spans several lines, so that the restart has to skip over more
- @REM than one line before looking for the next match.
- %printf% "a\nb\nc\nd\n" >testtemp1grep
- %pcre2grep% -n -M -u "(?s)a.*c" testtemp1grep >>testtrygrep 2>&1
- echo multiline-spanning RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -M -u "(?s)a.*c|$" testtemp1grep >>testtrygrep 2>&1
- echo multiline-spanning-then-empty RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -M --colour=always -u "(?s)a.*c|$" testtemp1grep >>testtrygrep 2>&1
- echo multiline-colour-spanning RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM Invalid UTF-8 after an empty match, which is when the scan over
- @REM continuation bytes that follow the restart point can run. Here the scan
- @REM stops at the start of the next character.
- %printf% "x\200\200y\n" >testtemp1grep
- %pcre2grep% -n --colour=always -U "^" testtemp1grep >>testtrygrep 2>&1
- echo colour-utf-scan-to-char RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -M -U "^" testtemp1grep >>testtrygrep 2>&1
- echo multiline-utf-scan-to-char RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM The continuation bytes run up to the newline, and then up to the end of the
- @REM subject, when there is no newline to stop the scan.
- %printf% "x\200\200\n" >testtemp1grep
- %pcre2grep% -n --colour=always -U "^" testtemp1grep >>testtrygrep 2>&1
- echo colour-utf-scan-to-newline RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -M -U "^" testtemp1grep >>testtrygrep 2>&1
- echo multiline-utf-scan-to-newline RC=^!ERRORLEVEL!>>testtrygrep
- %printf% "x\200\200" >testtemp1grep
- %pcre2grep% -n --colour=always -U "^" testtemp1grep >>testtrygrep 2>&1
- echo colour-utf-scan-to-end RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -M -U "^" testtemp1grep >>testtrygrep 2>&1
- echo multiline-utf-scan-to-end RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM A subject that is nothing but continuation bytes, so the very first match
- @REM is empty and the scan immediately reaches the end.
- %printf% "\200\200" >testtemp1grep
- %pcre2grep% -n --colour=always -U ".?" testtemp1grep >>testtrygrep 2>&1
- echo colour-utf-only-continuations RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -M -U ".?" testtemp1grep >>testtrygrep 2>&1
- echo multiline-utf-only-continuations RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM Continuation bytes at the end of a multi-line subject, reached after an
- @REM empty match on an earlier line, and after a match that spans lines.
- %printf% "a\nb\n\n\200\200" >testtemp1grep
- %pcre2grep% -n -M -U ".?" testtemp1grep >>testtrygrep 2>&1
- echo multiline-utf-trailing RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -M -U "$" testtemp1grep >>testtrygrep 2>&1
- echo multiline-utf-trailing-empty RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -M --colour=always -U "(?s)a.*b|$" testtemp1grep >>testtrygrep 2>&1
- echo multiline-colour-utf-trailing-spanning RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U13 ------------------------------>>testtrygrep
- @REM The same restart, but reached by \K rather than by an empty match.
- %printf% "abc\n" >testtemp1grep
- %pcre2grep% -n --colour=always -u --allow-lookaround-bsk "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo colour-bsk RC=^!ERRORLEVEL!>>testtrygrep
- %printf% "a\nb\n" >testtemp1grep
- %pcre2grep% -n -M -u --allow-lookaround-bsk "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo multiline-bsk RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM The same, but with the restart landing on invalid UTF-8.
- %printf% "x\200\200y\n" >testtemp1grep
- %pcre2grep% --no-jit -n --colour=always -U --allow-lookaround-bsk "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo colour-bsk-utf-scan-to-char RC=^!ERRORLEVEL!>>testtrygrep
- %printf% "x\200\200" >testtemp1grep
- %pcre2grep% --no-jit -n -M -U --allow-lookaround-bsk "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo multiline-bsk-utf-scan-to-end RC=^!ERRORLEVEL!>>testtrygrep
- %printf% "a\nx\200\200" >testtemp1grep
- %pcre2grep% --no-jit -n -M --colour=always -U --allow-lookaround-bsk "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo multiline-colour-bsk-utf-trailing RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test U14 ------------------------------>>testtrygrep
-
- @REM A pattern that keeps making progress, so the restart is the ordinary one
- @REM and the line is never advanced. This is the path the other U14 tests build on.
- %printf% "abcabc\n" >testtemp1grep
- %pcre2grep% -n -o -u "a." testtemp1grep >>testtrygrep 2>&1
- echo control-progress RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM An empty match, which is the case the restart exists for. "$" matches only
- @REM at the end of the subject, so the restart is immediately at the end; "^"
- @REM matches at the start, so it has to step forward by one character first.
- %pcre2grep% -n -o -u "$" testtemp1grep >>testtrygrep 2>&1
- echo empty-at-end RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -o -u "^" testtemp1grep >>testtrygrep 2>&1
- echo empty-at-start RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM \K in a lookbehind reports a non-empty match that ends no later than the
- @REM offset it was started from. PCRE2_NOTEMPTY is set once a match has been
- @REM found, so this, unlike an empty match, can stop the loop making progress on
- @REM every iteration and not just the first.
- %pcre2grep% -n -o -u --allow-lookaround-bsk "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo bsk-restart RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM The step forward lands on invalid UTF-8, so the scan over continuation
- @REM bytes runs. Here it stops at the start of the next character, and then at
- @REM the newline, both of which are within the subject.
- %printf% "x\200\200y\n" >testtemp1grep
- %pcre2grep% --no-jit -n -o -U --allow-lookaround-bsk "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo bsk-utf-scan-to-char RC=^!ERRORLEVEL!>>testtrygrep
- %printf% "x\200\200\n" >testtemp1grep
- %pcre2grep% --no-jit -n -o -U --allow-lookaround-bsk "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo bsk-utf-scan-to-newline RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM The same, but with no newline to stop the scan, so it runs to the end of
- @REM the subject and then looks at the byte after it.
- %printf% "x\200\200" >testtemp1grep
- %pcre2grep% --no-jit -n -o -U --allow-lookaround-bsk "(?<=\K.)" testtemp1grep >>testtrygrep 2>&1
- echo bsk-utf-scan-to-end RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM Moving on to another line, which only happens in multiline mode. The first
- @REM match ends exactly at the start of the next line, so the line is advanced
- @REM and the line number with it; the second ends two lines further on.
- %printf% "ab\ncd\n" >testtemp1grep
- %pcre2grep% -n -o -M -u "ab\n" testtemp1grep >>testtrygrep 2>&1
- echo multiline-line-boundary RC=^!ERRORLEVEL!>>testtrygrep
- %printf% "ab\ncd\nef\n" >testtemp1grep
- %pcre2grep% -n -o -M -u "(?s)ab.*ef" testtemp1grep >>testtrygrep 2>&1
- echo multiline-spanning RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM An empty match in multiline mode, where the step forward is what takes the
- @REM restart past the end of the line.
- %printf% "a\nb\n" >testtemp1grep
- %pcre2grep% -n -o -M -u "$" testtemp1grep >>testtrygrep 2>&1
- echo multiline-empty RC=^!ERRORLEVEL!>>testtrygrep
-
- @REM A match that ends between the CR and the LF of a CRLF line ending, so the
- @REM restart is past the text of the line but short of the start of the next
- @REM one. Without -M the line is never advanced, so that is the control.
- @REM These match a CR at the end of a line, which pcre2grep then follows with
- @REM STDOUT_NL, so the CR has to be unpicked from the line ending to match
- @REM what RunGrepTest produces. See the -fixcrlf helper in pcre2test.
- %printf% "ab\r\ncd\r\n" >testtemp1grep
- %pcre2grep% -n -o -N CRLF "\r" testtemp1grep >>testtrygrep 2>&1
- echo crlf-not-multiline RC=^!ERRORLEVEL!>>testtrygrep
- %pcre2grep% -n -o -M -N CRLF "\r" testtemp1grep >testtemp2grep 2>&1
- set rc=^!ERRORLEVEL!
- %fixcrlf% >testtrygrep
- echo crlf-mid-terminator RC=^!rc!>>testtrygrep
- %pcre2grep% -n -o -M -N ANY "\r" testtemp1grep >testtemp2grep 2>&1
- set rc=^!ERRORLEVEL!
- %fixcrlf% >testtrygrep
- echo any-mid-terminator RC=^!rc!>>testtrygrep
- %pcre2grep% -M -N CRLF --line-offsets "\r" testtemp1grep >>testtrygrep 2>&1
- echo crlf-mid-terminator-line-offsets RC=^!ERRORLEVEL!>>testtrygrep
-
- %cf% %srcdir%\testdata\grepoutput8 testtrygrep %cfout%
- if ERRORLEVEL 1 exit /b 1
-
-) else (
- echo Skipping pcre2grep UTF-8 tests: no UTF-8 support in PCRE2 library
-)
-
-
-:: We go to some contortions to try to ensure that the tests for the various
-:: newline settings will work in environments where the normal newline sequence
-:: is not \n. Do not use exported files, whose line endings might be changed.
-:: Instead, create an input file so that its contents are exactly what we want.
-:: These tests are run in the build directory.
-
-echo Testing pcre2grep newline settings
-%printf% "abc\rdef\r\nghi\njkl" >testNinputgrep
-
-echo ---------------------------- Test N1 ------------------------------>testtrygrep
-%pcre2grep% -n -N CR "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% -B1 -n -N CR "^def" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test N2 ------------------------------>>testtrygrep
-%pcre2grep% -n --newline=crlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% -B1 -n -N CRLF "^ghi" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test N3 ------------------------------>>testtrygrep
-@REM The pattern contains a CR, which for /f keeps, but the command has to be
-@REM read from a file: %printf% starts with a quoted path, and cmd mangles the
-@REM quoting of a command given directly to for /f.
-%printf% "def\rjkl" >testtemp1grep
-for /f %%a in (testtemp1grep) do set pattern=%%a
-%pcre2grep% -n --newline=cr -F "!pattern!" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test N4 ------------------------------>>testtrygrep
-%pcre2grep% -n --newline=crlf -F -f %srcdir%\testdata\greppatN4 testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test N5 ------------------------------>>testtrygrep
-%pcre2grep% -n --newline=any "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% -B1 -n --newline=any "^def" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test N6 ------------------------------>>testtrygrep
-%pcre2grep% -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% -B1 -n --newline=anycrlf "^jkl" testNinputgrep >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test N7 ------------------------------>>testtrygrep
-%printf% "xyz\0abc\0def" >testNinputgrep
-%pcre2grep% -na --newline=nul "^(abc|def)" testNinputgrep | %tr% \0 @ >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-%pcre2grep% -B1 -na --newline=nul "^(abc|def)" testNinputgrep | %tr% \0 @ >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-echo ---------------------------- Test N8 ------------------------------>>testtrygrep
-%pcre2grep% -na --newline=anycrlf "^a" %srcdir%\testdata\grepinputBad8_Trail >>testtrygrep
-echo RC=^%ERRORLEVEL%>>testtrygrep
-
-%printf% "\n" >>testtrygrep
-
-%cf% %srcdir%\testdata\grepoutputN testtrygrep %cfout%
-if ERRORLEVEL 1 exit /b 1
-
-
-:: These newline tests need UTF support.
-
-if %utf8% neq 0 (
- echo Testing pcre2grep newline settings with UTF-8 features
-
- echo ---------------------------- Test UN1 ------------------------------>testtrygrep
- %pcre2grep% -nau --newline=anycrlf "^(abc|def)" %srcdir%\testdata\grepinputUN >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- echo ---------------------------- Test UN2 ------------------------------>testtrygrep
- %pcre2grep% -nauU --newline=anycrlf "^a" %srcdir%\testdata\grepinputBad8_Trail >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- %printf% "\n" >>testtrygrep
-
- %cf% %srcdir%\testdata\grepoutputUN testtrygrep %cfout%
- if ERRORLEVEL 1 exit /b 1
-
-) else (
- echo Skipping pcre2grep newline UTF-8 tests: no UTF-8 support in PCRE2 library
-)
-
-
-:: If pcre2grep supports script callouts, run some tests on them. It is possible
-:: to restrict these callouts to the non-fork case, either for security, or for
-:: environments that do not support fork(). This is handled by comparing to a
-:: different output.
-
-%pcre2grep% --help | %pcre2grep% -q "callout scripts in patterns are supported"
-if %ERRORLEVEL% equ 0 (
- echo Testing pcre2grep script callouts
-
- echo --- Test 1 --->testtrygrep
- %pcre2grep% "(T)(..(.))(?C'cmd|/c echo|Arg1: [$1] [$2] [$3]|Arg2: ^$|${1}^$| ($4) ($14) ($0)')()" %srcdir%\testdata\grepinputv >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
- echo --- Test 2 --->>testtrygrep
- %pcre2grep% "(T)(..(.))()()()()()()()(..)(?C'cmd|/c echo|Arg1: [$11] [${11}]')" %srcdir%\testdata\grepinputv >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
- echo --- Test 3 --->>testtrygrep
- %pcre2grep% "(T)(?C'|$0:$1$n')" %srcdir%\testdata\grepinputv >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
- echo --- Test 4 --->>testtrygrep
- %pcre2grep% "(T)(?C'%pcre2test_unquoted%|-printf|%%s\r\n|$0:$1$n')" %srcdir%\testdata\grepinputv >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
- echo --- Test 5 --->>testtrygrep
- %pcre2grep% "(T)(?C'|$1$n')(*F)" %srcdir%\testdata\grepinputv >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
- echo --- Test 6 --->>testtrygrep
- %pcre2grep% -m1 "(T)(?C'|$0:$1:$x{41}$o{101}$n')" %srcdir%\testdata\grepinputv >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- %pcre2grep% --help | %pcre2grep% -q "Non-fork callout scripts in patterns are supported"
- if ^!ERRORLEVEL! equ 0 (
- set nonfork=1
- %cf% %srcdir%\testdata\grepoutputCN testtrygrep %cfout%
- ) else (
- set nonfork=0
- %cf% %srcdir%\testdata\grepoutputC testtrygrep %cfout%
- )
- if ERRORLEVEL 1 exit /b 1
-
- @REM These callout tests need UTF support.
-
- if %utf8% neq 0 (
- echo Testing pcre2grep script callout with UTF-8 features
-
- echo --- Test 1 --->testtrygrep
- %pcre2grep% -u "(T)(?C'|$0:$x{a6}$n')" %srcdir%\testdata\grepinputv >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
- echo --- Test 2 --->>testtrygrep
- %pcre2grep% -u "(T)(?C'%pcre2test_unquoted%|-printf|%%s\r\n|$0:$x{a6}$n')" %srcdir%\testdata\grepinputv >>testtrygrep
- echo RC=^!ERRORLEVEL!>>testtrygrep
-
- if ^!nonfork! equ 1 (
- %cf% %srcdir%\testdata\grepoutputCNU testtrygrep %cfout%
- ) else (
- %cf% %srcdir%\testdata\grepoutputCU testtrygrep %cfout%
- )
- if ERRORLEVEL 1 exit /b 1
-
- ) else (
- echo Skipping pcre2grep script callout UTF-8 tests: no UTF-8 support in PCRE2 library
- )
-
-) else (
- echo Script callouts are not supported
-)
-
-
-:: Finally, some tests to exercise code that is not tested above, just to be
-:: sure that it runs OK. Doing this improves the coverage statistics. The output
-:: is not checked.
-
-echo Testing miscellaneous pcre2grep arguments (unchecked)
-echo. >nul 2>testtrygrep
-call :checkspecial "-xxxxx" 2 || exit /b 1
-call :checkspecial "--help" 0 || exit /b 1
-call :checkspecial "--line-buffered --colour=auto abc nul" 1 || exit /b 1
-call :checkspecial "--line-buffered --color abc nul" 1 || exit /b 1
-call :checkspecial "-dskip abc ." 1 || exit /b 1
-call :checkspecial "-Dread -Dskip abc nul" 1 || exit /b 1
-call :checkspecial "-f %srcdir%\testdata\greplistBad nul" 2 || exit /b 1
-call :checkspecial "(unpaired nul" 2 || exit /b 1
-call :checkspecial "-e (unpaired1 -e (unpaired2 nul" 2 || exit /b 1
-
-
-:: Clean up local working files
-del testcf testNinputgrep teststderrgrep testtrygrep testtemp1grep testtemp2grep -testtemp1grep --
-
-exit /b 0
-
-:: ------ Function to run and check a special pcre2grep arguments test -------
-
-:checkspecial
- %pcre2grep% %~1 >>testtrygrep 2>&1
- if %ERRORLEVEL% neq %2 (
- echo ** pcre2grep %~1 failed - check testtrygrep
- exit /b 1
- )
- exit /b 0
-
-:: End
diff --git a/RunGrepTest.py b/RunGrepTest.py
new file mode 100755
index 000000000..1bd1181ce
--- /dev/null
+++ b/RunGrepTest.py
@@ -0,0 +1,1390 @@
+#!/usr/bin/env python3
+
+# Run pcre2grep tests. The assumption is that the PCRE2 tests check the library
+# itself. What we are checking here is the file handling and options that are
+# supported by pcre2grep. This script must be run in the build directory.
+
+# We use `yapf` for auto-formatting our Python files.
+# Applied to both Python test runners using:
+# > pip3 install yapf
+# > yapf --in-place --style maint/formatting.yapf RunTest.py RunGrepTest.py
+
+import difflib
+import os
+import shutil
+import subprocess
+import sys
+from datetime import datetime
+from pathlib import Path
+
+# Set the C locale, so that sort(1) and pcre2grep itself behave predictably.
+
+os.environ["LC_ALL"] = "C"
+
+# Ensure that Python does not hold onto output, to make it clear where it got
+# to on failure.
+
+sys.stdout.reconfigure(line_buffering=True)
+
+# Remove any non-default colouring and aliases that the caller may have set.
+
+for name in (
+ "PCRE2GREP_COLOUR",
+ "PCRE2GREP_COLOR",
+ "PCREGREP_COLOUR",
+ "PCREGREP_COLOR",
+ "GREP_COLOR",
+ "GREP_COLORS",
+):
+ os.environ.pop(name, None)
+
+# Remember the current (build) directory, set the program to be tested, and
+# valgrind settings when requested.
+
+builddir = Path.cwd()
+pcre2grep = os.environ.get("pcre2grep", None) or ("./pcre2grep.exe" if os.name == "nt" else "./pcre2grep")
+pcre2test = os.environ.get("pcre2test", None) or ("./pcre2test.exe" if os.name == "nt" else "./pcre2test")
+
+valgrind = []
+srcdir = os.environ.get("srcdir", "")
+arguments = iter(sys.argv[1:])
+for argument in arguments:
+ if argument in ("valgrind", "-valgrind", "--valgrind"):
+ valgrind = ["valgrind", "-q", "--leak-check=no", "--smc-check=all-non-file", "--error-exitcode=70"]
+ elif argument in ("srcdir", "-srcdir", "--srcdir"):
+ try:
+ srcdir = next(arguments)
+ except StopIteration:
+ print(f"Missing argument after '{argument}'")
+ sys.exit(1)
+ elif argument in ("pcre2test", "-pcre2test", "--pcre2test"):
+ try:
+ pcre2test = next(arguments)
+ except StopIteration:
+ print(f"Missing argument after '{argument}'")
+ sys.exit(1)
+ elif argument in ("pcre2grep", "-pcre2grep", "--pcre2grep"):
+ try:
+ pcre2grep = next(arguments)
+ except StopIteration:
+ print(f"Missing argument after '{argument}'")
+ sys.exit(1)
+ else:
+ print(f"RunGrepTest.py: Unknown argument {argument}")
+ sys.exit(1)
+
+# Validate paths after argument processing
+
+if not Path(pcre2grep).is_file() or not os.access(pcre2grep, os.X_OK):
+ print(f"** {pcre2grep} does not exist or is not executable.")
+ sys.exit(1)
+if not Path(pcre2test).is_file() or not os.access(pcre2test, os.X_OK):
+ print(f"** {pcre2test} does not exist or is not executable.")
+ sys.exit(1)
+
+# Support relative paths for pcre2test and pcre2grep; these are referenced after
+# changing directory to srcdir.
+
+pcre2grep = str(Path(pcre2grep).resolve())
+pcre2test = str(Path(pcre2test).resolve())
+pcre2grep_is_exe = pcre2grep.lower().endswith(".exe")
+
+# ------ Helper functions for invoking pcre2grep ------
+
+
+def invoke(*args, cwd=None, stdin=None, stdout=None, stderr=None, use_valgrind=True, use_vjs=False):
+ command = [str(argument) for argument in args]
+ if valgrind and use_valgrind:
+ command = [*valgrind, *(vjs if use_vjs else []), *command]
+ return subprocess.run(command, cwd=cwd, stdin=stdin, stdout=stdout, stderr=stderr, check=False).returncode
+
+
+def output(arguments, cwd=builddir, stdin=None, stderr=None, transform=None, append_returncode=True, use_vjs=True):
+ with open("testtrygrep", "ab") as stream:
+ process = subprocess.run(valgrind + (vjs if use_vjs else []) + [str(argument) for argument in arguments],
+ cwd=cwd,
+ input=stdin if isinstance(stdin, bytes) else None,
+ stdin=stdin if hasattr(stdin, "read") else None,
+ stdout=subprocess.PIPE,
+ stderr=stderr,
+ check=False)
+ data = process.stdout if transform is None else transform(process.stdout)
+ stream.write(data)
+ if append_returncode:
+ stream.write(f"RC={process.returncode}\n".encode("latin-1"))
+ return process.returncode
+
+
+def output_both(arguments, **kwargs):
+ return output(arguments, stderr=subprocess.STDOUT, **kwargs)
+
+
+def write_test_output(data, append=True):
+ with open("testtrygrep", "ab" if append else "wb") as stream:
+ stream.write(data)
+
+
+def write_returncode(returncode, label=None):
+ prefix = f"{label} " if label else ""
+ write_test_output(f"{prefix}RC={returncode}\n".encode("latin-1"))
+
+
+def compare(expected, actual):
+ if Path(expected).read_bytes() == Path(actual).read_bytes():
+ return True
+ expected_mtime = datetime.fromtimestamp(Path(expected).stat().st_mtime).astimezone().isoformat()
+ actual_mtime = datetime.fromtimestamp(Path(actual).stat().st_mtime).astimezone().isoformat()
+ print("".join(
+ difflib.unified_diff(
+ Path(expected).read_bytes().decode("latin-1").splitlines(keepends=True),
+ Path(actual).read_bytes().decode("latin-1").splitlines(keepends=True),
+ fromfile=str(expected),
+ tofile=str(actual),
+ fromfiledate=expected_mtime,
+ tofiledate=actual_mtime,
+ )),
+ end="")
+ return False
+
+
+# Print the version header
+
+pcre2grep_version = subprocess.run([pcre2grep, "-V"], stdout=subprocess.PIPE,
+ check=False).stdout.decode("latin-1").strip()
+print(f"Testing {pcre2grep_version}" + (" using valgrind" if valgrind else ""))
+
+# If this test is being run from "make check", srcdir will be set in the
+# environment. If not, set it to the current or parent directory, whichever one
+# contains the test data. Subsequently, we run most of the pcre2grep tests in
+# the source directory so that the file names in the output are always the same.
+
+if srcdir:
+ if not (Path(srcdir) / "testdata").is_dir():
+ print(f"The specified srcdir '{srcdir}' does not contain a testdata directory")
+ sys.exit(1)
+ srcdir = Path(srcdir)
+else:
+ if Path("testdata").is_dir():
+ srcdir = Path(".")
+ elif Path("../testdata").is_dir():
+ srcdir = Path("..")
+ else:
+ print("Cannot find the testdata directory")
+ sys.exit(1)
+
+# Set up the path to the valgrind JIT suppressions
+
+vjs = []
+if valgrind:
+ with open(os.devnull, "wb") as null:
+ supports_jit = invoke(pcre2test, "-C", "jit", stdout=null, use_valgrind=False) != 0
+ if supports_jit:
+ vjs = [f"--suppressions={srcdir.resolve() / 'testdata' / 'valgrind-jit.supp'}"]
+
+# Check for the availability of UTF-8 support
+
+with open(os.devnull, "wb") as null:
+ supports_utf8 = invoke(pcre2test, "-C", "unicode", stdout=null, use_valgrind=False) != 0
+
+# Check default newline convention. If it does not include LF, force LF.
+
+nl = subprocess.run([pcre2test, "-C", "newline"], stdout=subprocess.PIPE, check=False).stdout.decode("latin-1").strip()
+if nl not in ("LF", "ANY", "ANYCRLF"):
+ pcre2grep_args = [pcre2grep, "-N", "LF"]
+ print("Default newline setting forced to LF")
+else:
+ pcre2grep_args = [pcre2grep]
+
+# Similarly, on Windows force the stdout diagnostic messages to use LF instead
+# of CRLF, so that we get identical text to Unix for output comparison.
+
+if pcre2grep_is_exe:
+ pcre2grep_args.append("--lf")
+
+# ------ Helper to determine feature support ------
+
+
+def supports(text):
+ help_process = subprocess.run(valgrind + vjs + [*pcre2grep_args, "--help"], stdout=subprocess.PIPE, check=False)
+ return subprocess.run(valgrind + vjs + [*pcre2grep_args, "-q", text],
+ input=help_process.stdout,
+ stdout=subprocess.DEVNULL,
+ check=False).returncode == 0
+
+
+# ------ Function to run and check a special pcre2grep arguments test -------
+
+
+def checkspecial(arguments, expected):
+ with open("testtrygrep", "ab") as stream:
+ returncode = invoke(*pcre2grep_args, *arguments, stdout=stream, stderr=subprocess.STDOUT, use_vjs=True)
+ if returncode != expected:
+ print(f"** pcre2grep {' '.join([str(arg) for arg in arguments])} failed - check testtrygrep")
+ sys.exit(1)
+
+
+# ------ Normal tests ------
+
+print("Testing pcre2grep main features")
+
+write_test_output(b"---------------------------- Test 1 -----------------------------\n", append=False)
+output([*pcre2grep_args, "PATTERN", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 2 -----------------------------\n")
+output([*pcre2grep_args, "^PATTERN", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 3 -----------------------------\n")
+output([*pcre2grep_args, "-in", "PATTERN", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 4 -----------------------------\n")
+output([*pcre2grep_args, "-ic", "PATTERN", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 5 -----------------------------\n")
+output([*pcre2grep_args, "-in", "PATTERN", "./testdata/grepinput", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 6 -----------------------------\n")
+output([*pcre2grep_args, "-inh", "PATTERN", "./testdata/grepinput", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 7 -----------------------------\n")
+output([*pcre2grep_args, "-il", "PATTERN", "./testdata/grepinput", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 8 -----------------------------\n")
+output([*pcre2grep_args, "-l", "PATTERN", "./testdata/grepinput", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 9 -----------------------------\n")
+output([*pcre2grep_args, "-q", "PATTERN", "./testdata/grepinput", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 10 -----------------------------\n")
+output([*pcre2grep_args, "-q", "NEVER-PATTERN", "./testdata/grepinput", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 11 -----------------------------\n")
+output([*pcre2grep_args, "-vn", "pattern", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 12 -----------------------------\n")
+output([*pcre2grep_args, "-ix", "pattern", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 13 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"seventeen\n")
+output([*pcre2grep_args, "-f./testdata/greplist", "-f", builddir / "testtemp1grep", "./testdata/grepinputx"],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 14 -----------------------------\n")
+output([*pcre2grep_args, "-w", "pat", "./testdata/grepinput", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 15 -----------------------------\n")
+output_both([*pcre2grep_args, "abc^*", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 16 -----------------------------\n")
+output_both([*pcre2grep_args, "abc", "./testdata/grepinput", "./testdata/nonexistfile"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 17 -----------------------------\n")
+output([*pcre2grep_args, "-M", r"the\noutput", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 18 -----------------------------\n")
+output([*pcre2grep_args, "-Mn", r"(the\noutput|dog\.\n--)", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 19 -----------------------------\n")
+output([*pcre2grep_args, "-Mix", "Pattern", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 20 -----------------------------\n")
+output([*pcre2grep_args, "-Mixn", r"complete pair\nof lines", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 21 -----------------------------\n")
+output([*pcre2grep_args, "-nA3", "four", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 22 -----------------------------\n")
+output([*pcre2grep_args, "-nB3", "four", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 23 -----------------------------\n")
+output([*pcre2grep_args, "-C3", "four", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 24 -----------------------------\n")
+output([*pcre2grep_args, "-A9", "four", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 25 -----------------------------\n")
+output([*pcre2grep_args, "-nB9", "four", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 26 -----------------------------\n")
+output([*pcre2grep_args, "-A9", "-B9", "four", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 27 -----------------------------\n")
+output([*pcre2grep_args, "-A10", "four", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 28 -----------------------------\n")
+output([*pcre2grep_args, "-nB10", "four", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 29 -----------------------------\n")
+output([*pcre2grep_args, "-C12", "-B10", "four", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 30 -----------------------------\n")
+output([*pcre2grep_args, "-inB3", "pattern", "./testdata/grepinput", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 31 -----------------------------\n")
+output([*pcre2grep_args, "-inA3", "pattern", "./testdata/grepinput", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 32 -----------------------------\n")
+output([*pcre2grep_args, "-L", "fox", "./testdata/grepinput", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 33 -----------------------------\n")
+output_both([*pcre2grep_args, "fox", "./testdata/grepnonexist"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 34 -----------------------------\n")
+output_both([*pcre2grep_args, "-s", "fox", "./testdata/grepnonexist"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 35 -----------------------------\n")
+output([
+ *pcre2grep_args, "-L", "-r", "--include=grepinputx", "--include", "grepinput8", "--exclude-dir=^\\.", "fox",
+ "./testdata"
+],
+ cwd=srcdir,
+ transform=lambda data: b"".join(sorted(data.splitlines(keepends=True))))
+
+write_test_output(b"---------------------------- Test 36 -----------------------------\n")
+output([
+ *pcre2grep_args, "-L", "-r", "--include=grepinput[^C]", "--exclude", "grepinput$", "--exclude=grepinput(Bad)?8",
+ "--exclude=grepinputM", "--exclude=grepinputUN", "--exclude-dir=^\\.", "fox", "./testdata"
+],
+ cwd=srcdir,
+ transform=lambda data: b"".join(sorted(data.splitlines(keepends=True))))
+
+write_test_output(b"---------------------------- Test 37 -----------------------------\n")
+with open("teststderrgrep", "wb") as stream:
+ output([*pcre2grep_args, r"^(a+)*\d", "./testdata/grepinput"], cwd=srcdir, stderr=stream)
+with open("testtrygrep", "ab") as stream:
+ stream.write(b"======== STDERR ========\n")
+ stream.write(Path("teststderrgrep").read_bytes())
+
+write_test_output(b"---------------------------- Test 38 -----------------------------\n")
+output([*pcre2grep_args, r">\x00<", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 39 -----------------------------\n")
+output([*pcre2grep_args, "-A1", "before the binary zero", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 40 -----------------------------\n")
+output([*pcre2grep_args, "-B1", "after the binary zero", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 41 -----------------------------\n")
+output([*pcre2grep_args, "-B1", "-o", r"\w+ the binary zero", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 42 -----------------------------\n")
+output([*pcre2grep_args, "-B1", "-onH", r"\w+ the binary zero", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 43 -----------------------------\n")
+output([*pcre2grep_args, "-on", "before|zero|after", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 44 -----------------------------\n")
+output([*pcre2grep_args, "-on", "-e", "before", "-ezero", "-e", "after", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 45 -----------------------------\n")
+output([*pcre2grep_args, "-on", "-f", "./testdata/greplist", "-e", "binary", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 46 -----------------------------\n")
+output_both([*pcre2grep_args, "-e", "unopened)", "-e", "abc", "./testdata/grepinput"], cwd=srcdir)
+output_both([*pcre2grep_args, "-eabc", "-e", "(unclosed", "./testdata/grepinput"], cwd=srcdir)
+output_both([*pcre2grep_args, "-eabc", "-e", "xyz", "-e", "[unclosed", "./testdata/grepinput"], cwd=srcdir)
+output_both([*pcre2grep_args, "--regex=123", "-eabc", "-e", "xyz", "-e", "[unclosed", "./testdata/grepinput"],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 47 -----------------------------\n")
+output([*pcre2grep_args, "-Fx", "AB.VE\nelephant", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 48 -----------------------------\n")
+output([*pcre2grep_args, "-F", "AB.VE\nelephant", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 49 -----------------------------\n")
+output([*pcre2grep_args, "-F", "-e", "DATA", "-e", "AB.VE\nelephant", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 50 -----------------------------\n")
+output([*pcre2grep_args, "^(abc|def|ghi|jkl)", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 51 -----------------------------\n")
+output([*pcre2grep_args, "-Mv", r"brown\sfox", "./testdata/grepinputv"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 52 -----------------------------\n")
+output([*pcre2grep_args, "--colour=always", "jumps", "./testdata/grepinputv"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 53 -----------------------------\n")
+output([*pcre2grep_args, "--file-offsets", "before|zero|after", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 54 -----------------------------\n")
+output([*pcre2grep_args, "--line-offsets", "before|zero|after", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 55 -----------------------------\n")
+output([*pcre2grep_args, "-f./testdata/greplist", "--color=always", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 56 -----------------------------\n")
+output([
+ *pcre2grep_args, "-c", "--exclude=grepinputC", "lazy",
+ *[f"./testdata/{path.name}" for path in sorted((srcdir / "testdata").glob("grepinput*"))]
+],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 57 -----------------------------\n")
+output([
+ *pcre2grep_args, "-c", "-l", "--exclude=grepinputC", "lazy",
+ *[f"./testdata/{path.name}" for path in sorted((srcdir / "testdata").glob("grepinput*"))]
+],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 58 -----------------------------\n")
+output([*pcre2grep_args, "--regex=PATTERN", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 59 -----------------------------\n")
+output([*pcre2grep_args, "--regexp=PATTERN", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 60 -----------------------------\n")
+output([*pcre2grep_args, "--regex", "PATTERN", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 61 -----------------------------\n")
+output([*pcre2grep_args, "--regexp", "PATTERN", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 62 -----------------------------\n")
+output_both(
+ [*pcre2grep_args, "--match-limit=1000", "--no-jit", "-M", r"This is a file(.|\R)*file.", "./testdata/grepinput"],
+ cwd=srcdir,
+ use_vjs=False)
+
+write_test_output(b"---------------------------- Test 63 -----------------------------\n")
+output_both(
+ [*pcre2grep_args, "--recursion-limit=1K", "--no-jit", "-M", r"This is a file(.|\R)*file.", "./testdata/grepinput"],
+ cwd=srcdir,
+ use_vjs=False)
+
+write_test_output(b"---------------------------- Test 64 -----------------------------\n")
+output([*pcre2grep_args, "-o1", "(?<=PAT)TERN (ap(pear)s)", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 65 -----------------------------\n")
+output([*pcre2grep_args, "-o2", "(?<=PAT)TERN (ap(pear)s)", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 66 -----------------------------\n")
+output([*pcre2grep_args, "-o3", "(?<=PAT)TERN (ap(pear)s)", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 67 -----------------------------\n")
+output([*pcre2grep_args, "-o12", "(?<=PAT)TERN (ap(pear)s)", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 68 -----------------------------\n")
+output([*pcre2grep_args, "--only-matching=2", "(?<=PAT)TERN (ap(pear)s)", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 69 -----------------------------\n")
+output([*pcre2grep_args, "-vn", "--colour=always", "pattern", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 70 -----------------------------\n")
+output([*pcre2grep_args, "--color=always", "-M", r"triple:\t.*\n\n", "./testdata/grepinput3"], cwd=srcdir)
+output([*pcre2grep_args, "--color=always", "-M", "-n", r"triple:\t.*\n\n", "./testdata/grepinput3"], cwd=srcdir)
+output([*pcre2grep_args, "-M", r"triple:\t.*\n\n", "./testdata/grepinput3"], cwd=srcdir)
+output([*pcre2grep_args, "-M", "-n", r"triple:\t.*\n\n", "./testdata/grepinput3"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 71 -----------------------------\n")
+output([*pcre2grep_args, "-o", "^01|^02|^03", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 72 -----------------------------\n")
+output([*pcre2grep_args, "--color=always", "^01|^02|^03", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 73 -----------------------------\n")
+output([*pcre2grep_args, "-o", "--colour=always", "^01|^02|^03", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 74 -----------------------------\n")
+output([*pcre2grep_args, "-o", "^01|02|^03", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 75 -----------------------------\n")
+output([*pcre2grep_args, "--color=always", "^01|02|^03", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 76 -----------------------------\n")
+output([*pcre2grep_args, "-o", "--colour=always", "^01|02|^03", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 77 -----------------------------\n")
+output([*pcre2grep_args, "-o", "^01|^02|03", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 78 -----------------------------\n")
+output([*pcre2grep_args, "--color=always", "^01|^02|03", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 79 -----------------------------\n")
+output([*pcre2grep_args, "-o", "--colour=always", "^01|^02|03", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 80 -----------------------------\n")
+output([*pcre2grep_args, "-o", r"\b01|\b02", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 81 -----------------------------\n")
+output([*pcre2grep_args, "--color=always", r"\b01|\b02", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 82 -----------------------------\n")
+output([*pcre2grep_args, "-o", "--colour=always", r"\b01|\b02", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 83 -----------------------------\n")
+output_both([*pcre2grep_args, "--buffer-size=10", "--max-buffer-size=100", "^a", "./testdata/grepinput3"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 84 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"testdata/grepinput3\n")
+output_both([
+ *pcre2grep_args, "--file-list", "./testdata/grepfilelist", "--file-list", builddir / "testtemp1grep",
+ "fox|complete|t7"
+],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 85 -----------------------------\n")
+output_both([*pcre2grep_args, "--file-list=./testdata/grepfilelist", "dolor", "./testdata/grepinput3"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 86 -----------------------------\n")
+output_both([*pcre2grep_args, "dog", "./testdata/grepbinary"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 87 -----------------------------\n")
+output_both([*pcre2grep_args, "cat", "./testdata/grepbinary"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 88 -----------------------------\n")
+output_both([*pcre2grep_args, "-v", "cat", "./testdata/grepbinary"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 89 -----------------------------\n")
+output_both([*pcre2grep_args, "-I", "dog", "./testdata/grepbinary"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 90 -----------------------------\n")
+output_both([*pcre2grep_args, "--binary-files=without-match", "dog", "./testdata/grepbinary"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 91 -----------------------------\n")
+output_both([*pcre2grep_args, "-a", "dog", "./testdata/grepbinary"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 92 -----------------------------\n")
+output_both([*pcre2grep_args, "--binary-files=text", "dog", "./testdata/grepbinary"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 93 -----------------------------\n")
+output_both([*pcre2grep_args, "--text", "dog", "./testdata/grepbinary"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 94 -----------------------------\n")
+output([
+ *pcre2grep_args, "-L", "-r", "--include=grepinputx", "--include", "grepinput8", "fox",
+ *[f"./testdata/{path.name}" for path in sorted((srcdir / "testdata").glob("grepinput*"))]
+],
+ cwd=srcdir,
+ transform=lambda data: b"".join(sorted(data.splitlines(keepends=True))))
+
+write_test_output(b"---------------------------- Test 95 -----------------------------\n")
+output_both([*pcre2grep_args, "--file-list", "./testdata/grepfilelist", "--exclude", "grepinputv", "fox|complete"],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 96 -----------------------------\n")
+output([
+ *pcre2grep_args, "-L", "-r", "--include-dir=testdata", "--exclude", "^(?!grepinput)", "--exclude=grepinput[MCU]",
+ "fox", *[f"./{path.name}" for path in sorted(srcdir.glob("test*"))]
+],
+ cwd=srcdir,
+ transform=lambda data: b"".join(sorted(data.splitlines(keepends=True))))
+
+write_test_output(b"---------------------------- Test 97 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"grepinput$\ngrepinput8\ngrepinputBad8\n")
+output([
+ *pcre2grep_args, "-L", "-r", "--include=grepinput", "--exclude=grepinput[MCU]", "--exclude-from",
+ builddir / "testtemp1grep", "--exclude-dir=^\\.", "fox", "./testdata"
+],
+ cwd=srcdir,
+ transform=lambda data: b"".join(sorted(data.splitlines(keepends=True))))
+
+write_test_output(b"---------------------------- Test 98 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"grepinput$\ngrepinput8\ngrepinputBad8\n")
+output([
+ *pcre2grep_args, "-L", "-r", "--exclude=grepinput3", "--exclude=grepinput[MCU]", "--include=grepinput",
+ "--exclude-from", builddir / "testtemp1grep", "--exclude-dir=^\\.", "fox", "./testdata"
+],
+ cwd=srcdir,
+ transform=lambda data: b"".join(sorted(data.splitlines(keepends=True))))
+
+write_test_output(b"---------------------------- Test 99 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"grepinput$\ngrepinputBad8\n")
+Path("testtemp2grep").write_bytes(b"grepinput8\n")
+output([
+ *pcre2grep_args, "-L", "-r", "--include", "grepinput", "--exclude=grepinput[MCU]", "--exclude-from", builddir /
+ "testtemp1grep", f"--exclude-from={builddir / 'testtemp2grep'}", "--exclude-dir=^\\.", "fox", "./testdata"
+],
+ cwd=srcdir,
+ transform=lambda data: b"".join(sorted(data.splitlines(keepends=True))))
+
+write_test_output(b"---------------------------- Test 100 -----------------------------\n")
+output([*pcre2grep_args, "-Ho2", "--only-matching=1", "-o3", r"(\w+) binary (\w+)(\.)?", "./testdata/grepinput"],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 101 -----------------------------\n")
+output([
+ *pcre2grep_args, "-o3", "-Ho2", "-o12", "--only-matching=1", "-o3", "--colour=always", "--om-separator=|",
+ r"(\w+) binary (\w+)(\.)?", "./testdata/grepinput"
+],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 102 -----------------------------\n")
+output_both([*pcre2grep_args, "-n", "^$", "./testdata/grepinput3"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 103 -----------------------------\n")
+output_both([*pcre2grep_args, "--only-matching", "^$", "./testdata/grepinput3"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 104 -----------------------------\n")
+output_both([*pcre2grep_args, "-n", "--only-matching", "^$", "./testdata/grepinput3"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 105 -----------------------------\n")
+output_both([*pcre2grep_args, "--colour=always", "ipsum|", "./testdata/grepinput3"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 106 -----------------------------\n")
+output_both([*pcre2grep_args, "-M", "|a"], cwd=srcdir, stdin=b"a\n")
+
+write_test_output(b"---------------------------- Test 107 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"a\naaaaa\n")
+output_both([*pcre2grep_args, "--line-offsets", "--allow-lookaround-bsk", r"(?<=\Ka)", builddir / "testtemp1grep"],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 108 -----------------------------\n")
+output([*pcre2grep_args, "-lq", "PATTERN", "./testdata/grepinput", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 109 -----------------------------\n")
+output([
+ *pcre2grep_args, "-cq", "--exclude=grepinputC", "lazy",
+ *[f"./testdata/{path.name}" for path in sorted((srcdir / "testdata").glob("grepinput*"))]
+],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 110 -----------------------------\n")
+output([*pcre2grep_args, "--om-separator", "/", "-Mo0", "-o1", "-o2", r"match (\d+):\n (.)\n", "testdata/grepinput"],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 111 -----------------------------\n")
+output([*pcre2grep_args, "--line-offsets", "-M", r"match (\d+):\n (.)\n", "testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 112 -----------------------------\n")
+output([*pcre2grep_args, "--file-offsets", "-M", r"match (\d+):\n (.)\n", "testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 113 -----------------------------\n")
+output([
+ *pcre2grep_args, "--total-count", "--exclude=grepinputC", "the",
+ *[f"testdata/{path.name}" for path in sorted((srcdir / "testdata").glob("grepinput*"))]
+],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 114 -----------------------------\n")
+output([
+ *pcre2grep_args, "-tc", "--exclude=grepinputC", "the",
+ *[f"testdata/{path.name}" for path in sorted((srcdir / "testdata").glob("grepinput*"))]
+],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 115 -----------------------------\n")
+output([
+ *pcre2grep_args, "-tlc", "--exclude=grepinputC", "the",
+ *[f"testdata/{path.name}" for path in sorted((srcdir / "testdata").glob("grepinput*"))]
+],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 116 -----------------------------\n")
+output([
+ *pcre2grep_args, "--exclude=grepinput[MCU]", "-th", "the",
+ *[f"testdata/{path.name}" for path in sorted((srcdir / "testdata").glob("grepinput*"))]
+],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 117 -----------------------------\n")
+output([
+ *pcre2grep_args, "-tch", "--exclude=grepinputC", "the",
+ *[f"testdata/{path.name}" for path in sorted((srcdir / "testdata").glob("grepinput*"))]
+],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 118 -----------------------------\n")
+output([
+ *pcre2grep_args, "-tL", "--exclude=grepinputC", "the",
+ *[f"testdata/{path.name}" for path in sorted((srcdir / "testdata").glob("grepinput*"))]
+],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 119 -----------------------------\n")
+Path("testNinputgrep").write_bytes(b"123\n456\n789\n---abc\ndef\nxyz\n---\n")
+output([*pcre2grep_args, "-Mo", r"(\n|[^-])*---", "testNinputgrep"])
+
+write_test_output(b"---------------------------- Test 120 -----------------------------\n")
+output([*pcre2grep_args, "-HO", "$0:$2$1$3", r"(\w+) binary (\w+)(\.)?", "./testdata/grepinput"], cwd=srcdir)
+output([*pcre2grep_args, "-HO", "$&:$2$1$3", r"(\w+) binary (\w+)(\.)?", "./testdata/grepinput"], cwd=srcdir)
+output([*pcre2grep_args, "-m", "1", "-O", "$0:$a$b$e$f$r$t$v", r"(\w+) binary (\w+)(\.)?", "./testdata/grepinput"],
+ cwd=srcdir)
+output_both([*pcre2grep_args, "-HO", "${X}", r"(\w+) binary (\w+)(\.)?", "./testdata/grepinput"], cwd=srcdir)
+output_both([*pcre2grep_args, "-HO", "XX$", r"(\w+) binary (\w+)(\.)?", "./testdata/grepinput"], cwd=srcdir)
+output_both([*pcre2grep_args, "-O", "$x{12345678}", r"(\w+) binary (\w+)(\.)?", "./testdata/grepinput"], cwd=srcdir)
+output_both([*pcre2grep_args, "-O", "$x{123Z", r"(\w+) binary (\w+)(\.)?", "./testdata/grepinput"], cwd=srcdir)
+output_both([*pcre2grep_args, "--output", "$x{1234}", r"(\w+) binary (\w+)(\.)?", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 121 -----------------------------\n")
+output([*pcre2grep_args, "-F", r"\E and (regex)", "testdata/grepinputv"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 122 -----------------------------\n")
+output([*pcre2grep_args, "-w", "cat|dog", "testdata/grepinputv"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 123 -----------------------------\n")
+output([*pcre2grep_args, "-w", "dog|cat", "testdata/grepinputv"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 124 -----------------------------\n")
+output([*pcre2grep_args, "-Mn", "--colour=always", r"start[\s]+end", "testdata/grepinputM"], cwd=srcdir)
+output([*pcre2grep_args, "-Mn", "--colour=always", "-A2", r"start[\s]+end", "testdata/grepinputM"], cwd=srcdir)
+output([*pcre2grep_args, "-Mn", r"start[\s]+end", "testdata/grepinputM"], cwd=srcdir)
+output([*pcre2grep_args, "-Mn", "-A2", r"start[\s]+end", "testdata/grepinputM"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 125 -----------------------------\n")
+Path("testNinputgrep").write_bytes(b"abcd\n")
+output([*pcre2grep_args, "--colour=always", "--allow-lookaround-bsk", r"(?<=\K.)", "testNinputgrep"])
+output([*pcre2grep_args, "--colour=always", "--allow-lookaround-bsk", r"(?=.\K)", "testNinputgrep"])
+output([*pcre2grep_args, "--colour=always", "--allow-lookaround-bsk", r"(?<=\K[ac])", "testNinputgrep"])
+output([*pcre2grep_args, "--colour=always", "--allow-lookaround-bsk", r"(?=[ac]\K)", "testNinputgrep"])
+with open("testtrygrep", "ab") as output_file:
+ environment = os.environ.copy()
+ environment["GREP_COLORS"] = "ms=1;20"
+ process = subprocess.run(
+ valgrind + vjs + [*pcre2grep_args, "--colour=always", "--allow-lookaround-bsk", r"(?=[ac]\K)", "testNinputgrep"],
+ stdout=output_file,
+ stderr=subprocess.STDOUT,
+ env=environment,
+ check=False)
+ output_file.write(f"RC={process.returncode}\n".encode("latin-1"))
+
+write_test_output(b"---------------------------- Test 126 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"Next line pattern has binary zero\nABC\0XYZ\n")
+Path("testtemp2grep").write_bytes(b"ABC\0XYZ\nABCDEF\nDEFABC\n")
+output([*pcre2grep_args, "-a", "-f", "testtemp1grep", "testtemp2grep"])
+Path("testtemp1grep").write_bytes(b"Next line pattern is erroneous.\n^abc)(xy")
+output_both([*pcre2grep_args, "-a", "-f", "testtemp1grep", "testtemp2grep"])
+
+write_test_output(b"---------------------------- Test 127 -----------------------------\n")
+output([*pcre2grep_args, "-o", "--om-capture=0", "pattern()()()()", "testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 128 -----------------------------\n")
+output_both([*pcre2grep_args, "-m1M", "-o1", "--om-capture=0", "pattern()()()()", "testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 129 -----------------------------\n")
+output_both([*pcre2grep_args, "-m", "2", "fox", "testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 130 -----------------------------\n")
+output_both([*pcre2grep_args, "-o", "-m2", "fox", "testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 131 -----------------------------\n")
+output_both([*pcre2grep_args, "-oc", "-m2", "fox", "testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 132 -----------------------------\n")
+with open(srcdir / "testdata" / "grepinput", "rb") as stream:
+ output_both([*pcre2grep_args, "-m1", "-A3", "^match"], cwd=srcdir, stdin=stream)
+ with open("testtrygrep", "ab") as output_file:
+ output_file.write(b"---\n")
+ output_both([*pcre2grep_args, "-m1", ".*"], cwd=srcdir, stdin=stream)
+
+write_test_output(b"---------------------------- Test 133 -----------------------------\n")
+with open(srcdir / "testdata" / "grepinput", "rb") as stream:
+ output_both([*pcre2grep_args, "-m1", "-A3", "^match"], cwd=srcdir, stdin=stream)
+ with open("testtrygrep", "ab") as output_file:
+ output_file.write(b"---\n")
+ output_both([*pcre2grep_args, "-m1", "-A3", "^match"], cwd=srcdir, stdin=stream)
+
+write_test_output(b"---------------------------- Test 134 -----------------------------\n")
+output_both([*pcre2grep_args, "--max-count=1", "-nH", "-O", "=$x{41}$x423$o{103}$o1045=", "fox", "-"],
+ cwd=srcdir,
+ stdin=(srcdir / "testdata" / "grepinputv").read_bytes())
+
+write_test_output(b"---------------------------- Test 135 -----------------------------\n")
+output([*pcre2grep_args, "-HZ", "word", "./testdata/grepinputv"],
+ cwd=srcdir,
+ transform=lambda data: data.replace(b"\0", b"@"))
+output([*pcre2grep_args, "-lZ", "word", "./testdata/grepinputv", "./testdata/grepinputv"],
+ cwd=srcdir,
+ transform=lambda data: data.replace(b"\0", b"@"))
+output([*pcre2grep_args, "-A", "1", "-B", "1", "-HZ", "word", "./testdata/grepinputv"],
+ cwd=srcdir,
+ transform=lambda data: data.replace(b"\0", b"@"))
+output([*pcre2grep_args, "-MHZn", r"start[\s]+end", "testdata/grepinputM"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 136 -----------------------------\n")
+output_both([*pcre2grep_args, "-m1MK", "-o1", "--om-capture=0", "pattern()()()()", "testdata/grepinput"], cwd=srcdir)
+output_both([*pcre2grep_args, "--max-count=1MK", "-o1", "--om-capture=0", "pattern()()()()", "testdata/grepinput"],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 137 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"Last line\nhas no newline")
+output([*pcre2grep_args, "-A1", "Last", "testtemp1grep"])
+
+write_test_output(b"---------------------------- Test 138 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"AbC\n" * 24)
+output_both([*pcre2grep_args, "--no-jit", "--heap-limit=0", "b", "testtemp1grep"])
+
+write_test_output(b"---------------------------- Test 139 -----------------------------\n")
+output([*pcre2grep_args, "--line-buffered", "fox", "testdata/grepinputv"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 140 -----------------------------\n")
+output([*pcre2grep_args, "--buffer-size=10", "-A1", "brown", "testdata/grepinputv"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 141 -----------------------------\n")
+Path("testtemp1grep").write_bytes(f"{srcdir}/testdata/grepinputv\n-\n".encode(
+ "utf-8")) # Rare use of UTF-8, for encoding the user's build directory path
+Path("testtemp2grep").write_bytes(b"This is a line from stdin.")
+output_both([*pcre2grep_args, "--file-list", "testtemp1grep", "line from stdin"],
+ stdin=Path("testtemp2grep").read_bytes())
+
+write_test_output(b"---------------------------- Test 142 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"/does/not/exist\n")
+output_both([*pcre2grep_args, "--file-list", "testtemp1grep", "line from stdin"])
+
+write_test_output(b"---------------------------- Test 143 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"fox|cat")
+output_both([*pcre2grep_args, "-f", "-", srcdir / "testdata" / "grepinputv"], stdin=Path("testtemp1grep").read_bytes())
+
+write_test_output(b"---------------------------- Test 144 -----------------------------\n")
+output_both([*pcre2grep_args, "-f", "/non/exist", srcdir / "testdata" / "grepinputv"])
+
+write_test_output(b"---------------------------- Test 145 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"*meta*\rdog.")
+output_both([*pcre2grep_args, "-Ncr", "-F", "-f", "testtemp1grep", srcdir / "testdata" / "grepinputv"])
+
+write_test_output(b"---------------------------- Test 146 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"A123B")
+output_both([*pcre2grep_args, "-H", "-e", "123|fox", "-"], stdin=Path("testtemp1grep").read_bytes())
+output_both([*pcre2grep_args, "-h", "-e", "123|fox", "-", srcdir / "testdata" / "grepinputv"],
+ stdin=Path("testtemp1grep").read_bytes())
+output_both([*pcre2grep_args, "-", srcdir / "testdata" / "grepinputv"], stdin=Path("testtemp1grep").read_bytes())
+
+write_test_output(b"---------------------------- Test 147 -----------------------------\n")
+output_both([*pcre2grep_args, "-e", "123|fox", "--", "-nonfile"])
+Path("testtemp1grep").write_bytes(b"A123B")
+Path("-testtemp1grep").write_bytes(b"C123D")
+output_both([*pcre2grep_args, "123", "--", "-testtemp1grep"])
+output_both([*pcre2grep_args, "123", "testtemp1grep", "--", "-testtemp1grep"])
+output_both([*pcre2grep_args, "123", "--"], stdin=Path("testtemp1grep").read_bytes())
+Path("--").write_bytes(b"E123F")
+output_both([*pcre2grep_args, "--", "123", "--"])
+
+write_test_output(b"---------------------------- Test 148 -----------------------------\n")
+output_both([*pcre2grep_args, "--nonexist"])
+output_both([*pcre2grep_args, "-n-n-bad"])
+output_both([*pcre2grep_args, "--context"])
+output_both([*pcre2grep_args, "--only-matching", "--output=xx"])
+output_both([*pcre2grep_args, "--colour=badvalue"])
+output_both([*pcre2grep_args, "--newline=badvalue"])
+output_both([*pcre2grep_args, "-d", "badvalue"])
+output_both([*pcre2grep_args, "-D", "badvalue"])
+output_both([*pcre2grep_args, "--buffer-size=0"])
+output_both([*pcre2grep_args, "--exclude", "(badpat", "abc", os.devnull])
+output_both([*pcre2grep_args, "--exclude-from", "/non/exist", "abc", os.devnull])
+output_both([*pcre2grep_args, "--include-from", "/non/exist", "abc", os.devnull])
+output_both([*pcre2grep_args, "--file-list=/non/exist", "abc", os.devnull])
+
+write_test_output(b"---------------------------- Test 149 -----------------------------\n")
+output_both([*pcre2grep_args, "--binary-files=binary", "dog", "./testdata/grepbinary"], cwd=srcdir)
+output_both([*pcre2grep_args, "--binary-files=wrong", "dog", "./testdata/grepbinary"], cwd=srcdir)
+
+# This test runs the code that tests locale support. However, on some systems
+# (e.g. Alpine Linux) there is no locale support and running this test just
+# generates a "no match" result. Therefore, we test for locale support, and if
+# it is found missing, we pretend that the test has run as expected so that the
+# output matches.
+
+write_test_output(b"---------------------------- Test 150 -----------------------------\n")
+if shutil.which("locale") is None:
+ with open("testtrygrep", "ab") as stream:
+ stream.write(b"pcre2grep: Failed to set locale locale.bad (obtained from LC_CTYPE)\nRC=2\n")
+else:
+ environment = os.environ.copy()
+ environment.pop("LC_ALL", None)
+ environment["LC_CTYPE"] = "locale.bad"
+ with open("testtrygrep", "ab") as stream:
+ process = subprocess.run(valgrind + vjs + [*pcre2grep_args, "abc", os.devnull],
+ cwd=srcdir,
+ stdout=stream,
+ stderr=subprocess.STDOUT,
+ env=environment,
+ check=False)
+ stream.write(f"RC={process.returncode}\n".encode("latin-1"))
+
+write_test_output(b"---------------------------- Test 151 -----------------------------\n")
+output([*pcre2grep_args, "--colour=always", "-e", "this", "-e", "The", "-e", "The wo", "testdata/grepinputv"],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 152 -----------------------------\n")
+output([*pcre2grep_args, "-nA3", "--group-separator=++", "four", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 153 -----------------------------\n")
+output([*pcre2grep_args, "-nA3", "--no-group-separator", "four", "./testdata/grepinputx"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 154 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"")
+output([*pcre2grep_args, "-f", builddir / "testtemp1grep", "./testdata/grepinputv"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 155 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"\n")
+output([*pcre2grep_args, "-f", builddir / "testtemp1grep", "./testdata/grepinputv"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 156 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"\n")
+output([*pcre2grep_args, "--posix-pattern-file", "--file", builddir / "testtemp1grep", "./testdata/grepinputv"],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 157 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"spaces \n")
+with open(builddir / "testtemp2grep", "wb") as stream:
+ process = subprocess.run(
+ valgrind + vjs +
+ [*pcre2grep_args, "-o", "--posix-pattern-file", f"--file={builddir / 'testtemp1grep'}", "./testdata/grepinputv"],
+ cwd=srcdir,
+ stdout=stream,
+ check=False)
+if process.returncode == 0:
+ output([*pcre2grep_args, "-q", "s ", builddir / "testtemp2grep"], cwd=srcdir)
+else:
+ with open("testtrygrep", "ab") as output_file:
+ output_file.write(f"RC={process.returncode}\n".encode("latin-1"))
+
+write_test_output(b"---------------------------- Test 158 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"spaces.\n")
+output([*pcre2grep_args, "-f", builddir / "testtemp1grep", "./testdata/grepinputv"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 159 -----------------------------\n")
+Path("testtemp1grep").write_bytes(b"spaces.\r\n")
+output([*pcre2grep_args, "--posix-pattern-file", f"-f{builddir / 'testtemp1grep'}", "./testdata/grepinputv"],
+ cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 160 -----------------------------\n")
+output([*pcre2grep_args, "-nC3", "^(ert|jkl)", "./testdata/grepinput"], cwd=srcdir)
+output([*pcre2grep_args, "-n", "-B4", "-A2", "^(ert|dfg)", "./testdata/grepinput"], cwd=srcdir)
+
+write_test_output(b"---------------------------- Test 161 -----------------------------\n")
+Path("testNinputgrep").write_bytes(b"XfooY\n")
+output([*pcre2grep_args, "--allow-lookaround-bsk", "-o", r"(?=foo\K)", "testNinputgrep"])
+output([*pcre2grep_args, "--allow-lookaround-bsk", "--output", "$0", r"(?=foo\K)", "testNinputgrep"])
+output([*pcre2grep_args, "--allow-lookaround-bsk", "--line-offsets", r"(?=foo\K)", "testNinputgrep"])
+output([*pcre2grep_args, "--allow-lookaround-bsk", "--file-offsets", r"(?=foo\K)", "testNinputgrep"])
+
+# Now compare the results.
+
+if not compare(srcdir / "testdata" / "grepoutput", "testtrygrep"):
+ sys.exit(1)
+
+# These tests require UTF-8 support
+
+if supports_utf8:
+ print("Testing pcre2grep UTF-8 features")
+
+ write_test_output(b"---------------------------- Test U1 -----------------------------\n", append=False)
+ output([*pcre2grep_args, "-n", "-u", "--newline=any", "^X", "./testdata/grepinput8"], cwd=srcdir)
+
+ write_test_output(b"---------------------------- Test U2 -----------------------------\n")
+ output([*pcre2grep_args, "-n", "-u", "-C", "3", "--newline=any", "Match", "./testdata/grepinput8"], cwd=srcdir)
+
+ write_test_output(b"---------------------------- Test U3 -----------------------------\n")
+ output([
+ *pcre2grep_args, "--line-offsets", "-u", "--newline=any", "--allow-lookaround-bsk", r"(?<=\K\x{17f})",
+ "./testdata/grepinput8"
+ ],
+ cwd=srcdir)
+
+ write_test_output(b"---------------------------- Test U4 -----------------------------\n")
+ output_both([*pcre2grep_args, "-u", "-o", "....", "./testdata/grepinputBad8"], cwd=srcdir)
+
+ write_test_output(b"---------------------------- Test U5 -----------------------------\n")
+ output([*pcre2grep_args, "-U", "-o", "....", "./testdata/grepinputBad8"], cwd=srcdir)
+
+ write_test_output(b"---------------------------- Test U6 -----------------------------\n")
+ output_both([*pcre2grep_args, "-u", "-m1", "-O", "=$x{1d3}$o{744}=", "fox"],
+ cwd=srcdir,
+ stdin=(srcdir / "testdata" / "grepinputv").read_bytes())
+
+ write_test_output(b"---------------------------- Test U7 -----------------------------\n")
+ output([*pcre2grep_args, "-ui", "--colour=always", r"k+|\babc\b", "./testdata/grepinput8"], cwd=srcdir)
+
+ write_test_output(b"---------------------------- Test U8 -----------------------------\n")
+ output([*pcre2grep_args, "-UiEP", "--colour=always", r"k+|\babc\b", "./testdata/grepinput8"], cwd=srcdir)
+
+ write_test_output(b"---------------------------- Test U9 -----------------------------\n")
+ output([*pcre2grep_args, "-u", "--colour=always", r"A\d", "./testdata/grepinput8"], cwd=srcdir)
+
+ write_test_output(b"---------------------------- Test U10 -----------------------------\n")
+ output([*pcre2grep_args, "-u", "--posix-digit", "--colour=always", r"A\d", "./testdata/grepinput8"], cwd=srcdir)
+
+ write_test_output(b"---------------------------- Test U11 -----------------------------\n")
+ Path("testtemp1grep").write_bytes(b"\200" * 48 + b"x\n")
+ returncode = output_both([
+ *pcre2grep_args, "--no-jit", "--buffer-size=16", "-U", "--allow-lookaround-bsk", "-o", r"(?<=\K.)",
+ "testtemp1grep"
+ ],
+ append_returncode=False)
+ write_returncode(returncode, "only-matching")
+ returncode = output_both([
+ *pcre2grep_args, "--no-jit", "--buffer-size=16", "-U", "--allow-lookaround-bsk", "-M", r"(?<=\K.)",
+ "testtemp1grep"
+ ],
+ append_returncode=False)
+ write_returncode(returncode, "multiline")
+ returncode = output_both([
+ *pcre2grep_args, "--no-jit", "--buffer-size=16", "-U", "--allow-lookaround-bsk", "--colour=always", r"(?<=\K.)",
+ "testtemp1grep"
+ ],
+ append_returncode=False)
+ write_returncode(returncode, "colour")
+
+ write_test_output(b"---------------------------- Test U12 -----------------------------\n")
+ # Colouring only, so the subject is a single line. An empty match at the end
+ # of the subject, then one that matches before retrying at the end.
+ Path("testtemp1grep").write_bytes(b"abc\n")
+ returncode = output_both([*pcre2grep_args, "-n", "--colour=always", "-u", "$", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "colour-empty-at-end")
+ returncode = output_both([*pcre2grep_args, "-n", "--colour=always", "-u", ".?", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "colour-nonempty-then-empty")
+ returncode = output_both([*pcre2grep_args, "-n", "--colour=always", "-u", "^", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "colour-empty-at-start")
+
+ # An empty line, so the first match is empty with nothing following it, and a
+ # final line with no newline, so a restart can reach the end of the line.
+ Path("testtemp1grep").write_bytes(b"\nabc\n")
+ returncode = output_both([*pcre2grep_args, "-n", "--colour=always", "-u", ".?", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "colour-empty-line")
+ Path("testtemp1grep").write_bytes(b"abc")
+ returncode = output_both([*pcre2grep_args, "-n", "--colour=always", "-u", ".?", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "colour-no-final-newline")
+
+ # Multiline, where a restart may have to move on to a following line.
+ Path("testtemp1grep").write_bytes(b"a\nb\n")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-u", "$", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-empty-at-line-end")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-u", "^", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-empty-at-line-start")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-u", ".?", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-nonempty-then-empty")
+
+ # A match that spans several lines, so that the restart has to skip over more
+ # than one line before looking for the next match.
+ Path("testtemp1grep").write_bytes(b"a\nb\nc\nd\n")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-u", "(?s)a.*c", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-spanning")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-u", "(?s)a.*c|$", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-spanning-then-empty")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "--colour=always", "-u", "(?s)a.*c|$", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "multiline-colour-spanning")
+
+ # Invalid UTF-8 after an empty match, which is when the scan over
+ # continuation bytes that follow the restart point can run. Here the scan
+ # stops at the start of the next character.
+ Path("testtemp1grep").write_bytes(b"x\200\200y\n")
+ returncode = output_both([*pcre2grep_args, "-n", "--colour=always", "-U", "^", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "colour-utf-scan-to-char")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-U", "^", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-utf-scan-to-char")
+
+ # The continuation bytes run up to the newline, and then up to the end of the
+ # subject, when there is no newline to stop the scan.
+ Path("testtemp1grep").write_bytes(b"x\200\200\n")
+ returncode = output_both([*pcre2grep_args, "-n", "--colour=always", "-U", "^", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "colour-utf-scan-to-newline")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-U", "^", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-utf-scan-to-newline")
+ Path("testtemp1grep").write_bytes(b"x\200\200")
+ returncode = output_both([*pcre2grep_args, "-n", "--colour=always", "-U", "^", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "colour-utf-scan-to-end")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-U", "^", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-utf-scan-to-end")
+
+ # A subject that is nothing but continuation bytes, so the very first match
+ # is empty and the scan immediately reaches the end.
+ Path("testtemp1grep").write_bytes(b"\200\200")
+ returncode = output_both([*pcre2grep_args, "-n", "--colour=always", "-U", ".?", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "colour-utf-only-continuations")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-U", ".?", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-utf-only-continuations")
+
+ # Continuation bytes at the end of a multi-line subject, reached after an
+ # empty match on an earlier line, and after a match that spans lines.
+ Path("testtemp1grep").write_bytes(b"a\nb\n\n\200\200")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-U", ".?", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-utf-trailing")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-U", "$", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-utf-trailing-empty")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "--colour=always", "-U", "(?s)a.*b|$", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "multiline-colour-utf-trailing-spanning")
+
+ write_test_output(b"---------------------------- Test U13 -----------------------------\n")
+ # The same restart, but reached by \K rather than by an empty match.
+ Path("testtemp1grep").write_bytes(b"abc\n")
+ returncode = output_both(
+ [*pcre2grep_args, "-n", "--colour=always", "-u", "--allow-lookaround-bsk", r"(?<=\K.)", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "colour-bsk")
+ Path("testtemp1grep").write_bytes(b"a\nb\n")
+ returncode = output_both([*pcre2grep_args, "-n", "-M", "-u", "--allow-lookaround-bsk", r"(?<=\K.)", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "multiline-bsk")
+
+ # The same, but with the restart landing on invalid UTF-8.
+ Path("testtemp1grep").write_bytes(b"x\200\200y\n")
+ returncode = output_both([
+ *pcre2grep_args, "--no-jit", "-n", "--colour=always", "-U", "--allow-lookaround-bsk", r"(?<=\K.)", "testtemp1grep"
+ ],
+ append_returncode=False)
+ write_returncode(returncode, "colour-bsk-utf-scan-to-char")
+ Path("testtemp1grep").write_bytes(b"x\200\200")
+ returncode = output_both(
+ [*pcre2grep_args, "--no-jit", "-n", "-M", "-U", "--allow-lookaround-bsk", r"(?<=\K.)", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "multiline-bsk-utf-scan-to-end")
+ Path("testtemp1grep").write_bytes(b"a\nx\200\200")
+ returncode = output_both([
+ *pcre2grep_args, "--no-jit", "-n", "-M", "--colour=always", "-U", "--allow-lookaround-bsk", r"(?<=\K.)",
+ "testtemp1grep"
+ ],
+ append_returncode=False)
+ write_returncode(returncode, "multiline-colour-bsk-utf-trailing")
+
+ write_test_output(b"---------------------------- Test U14 -----------------------------\n")
+
+ # A pattern that keeps making progress, so the restart is the ordinary one
+ # and the line is never advanced. This is the path the other U14 tests build on.
+ Path("testtemp1grep").write_bytes(b"abcabc\n")
+ returncode = output_both([*pcre2grep_args, "-n", "-o", "-u", "a.", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "control-progress")
+
+ # An empty match, which is the case the restart exists for. "$" matches only
+ # at the end of the subject, so the restart is immediately at the end; "^"
+ # matches at the start, so it has to step forward by one character first.
+ returncode = output_both([*pcre2grep_args, "-n", "-o", "-u", "$", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "empty-at-end")
+ returncode = output_both([*pcre2grep_args, "-n", "-o", "-u", "^", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "empty-at-start")
+
+ # \K in a lookbehind reports a non-empty match that ends no later than the
+ # offset it was started from. PCRE2_NOTEMPTY is set once a match has been
+ # found, so this, unlike an empty match, can stop the loop making progress on
+ # every iteration and not just the first.
+ returncode = output_both([*pcre2grep_args, "-n", "-o", "-u", "--allow-lookaround-bsk", r"(?<=\K.)", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "bsk-restart")
+
+ # The step forward lands on invalid UTF-8, so the scan over continuation
+ # bytes runs. Here it stops at the start of the next character, and then at
+ # the newline, both of which are within the subject.
+ Path("testtemp1grep").write_bytes(b"x\200\200y\n")
+ returncode = output_both(
+ [*pcre2grep_args, "--no-jit", "-n", "-o", "-U", "--allow-lookaround-bsk", r"(?<=\K.)", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "bsk-utf-scan-to-char")
+ Path("testtemp1grep").write_bytes(b"x\200\200\n")
+ returncode = output_both(
+ [*pcre2grep_args, "--no-jit", "-n", "-o", "-U", "--allow-lookaround-bsk", r"(?<=\K.)", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "bsk-utf-scan-to-newline")
+
+ # The same, but with no newline to stop the scan, so it runs to the end of
+ # the subject and then looks at the byte after it.
+ Path("testtemp1grep").write_bytes(b"x\200\200")
+ returncode = output_both(
+ [*pcre2grep_args, "--no-jit", "-n", "-o", "-U", "--allow-lookaround-bsk", r"(?<=\K.)", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "bsk-utf-scan-to-end")
+
+ # Moving on to another line, which only happens in multiline mode. The first
+ # match ends exactly at the start of the next line, so the line is advanced
+ # and the line number with it; the second ends two lines further on.
+ Path("testtemp1grep").write_bytes(b"ab\ncd\n")
+ returncode = output_both([*pcre2grep_args, "-n", "-o", "-M", "-u", r"ab\n", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-line-boundary")
+ Path("testtemp1grep").write_bytes(b"ab\ncd\nef\n")
+ returncode = output_both([*pcre2grep_args, "-n", "-o", "-M", "-u", "(?s)ab.*ef", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "multiline-spanning")
+
+ # An empty match in multiline mode, where the step forward is what takes the
+ # restart past the end of the line.
+ Path("testtemp1grep").write_bytes(b"a\nb\n")
+ returncode = output_both([*pcre2grep_args, "-n", "-o", "-M", "-u", "$", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "multiline-empty")
+
+ # A match that ends between the CR and the LF of a CRLF line ending, so the
+ # restart is past the text of the line but short of the start of the next
+ # one. Without -M the line is never advanced, so that is the control.
+ Path("testtemp1grep").write_bytes(b"ab\r\ncd\r\n")
+ returncode = output_both([*pcre2grep_args, "-n", "-o", "-N", "CRLF", r"\r", "testtemp1grep"], append_returncode=False)
+ write_returncode(returncode, "crlf-not-multiline")
+ returncode = output_both([*pcre2grep_args, "-n", "-o", "-M", "-N", "CRLF", r"\r", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "crlf-mid-terminator")
+ returncode = output_both([*pcre2grep_args, "-n", "-o", "-M", "-N", "ANY", r"\r", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "any-mid-terminator")
+ returncode = output_both([*pcre2grep_args, "-M", "-N", "CRLF", "--line-offsets", r"\r", "testtemp1grep"],
+ append_returncode=False)
+ write_returncode(returncode, "crlf-mid-terminator-line-offsets")
+
+ if not compare(srcdir / "testdata" / "grepoutput8", "testtrygrep"):
+ sys.exit(1)
+else:
+ print("Skipping pcre2grep UTF-8 tests: no UTF-8 support in PCRE2 library")
+
+# We go to some contortions to try to ensure that the tests for the various
+# newline settings will work in environments where the normal newline sequence
+# is not \n. Do not use exported files, whose line endings might be changed.
+# Instead, create an input file using printf so that its contents are exactly
+# what we want. Note the messy fudge to get printf to write a string that
+# starts with a hyphen. These tests are run in the build directory.
+
+print("Testing pcre2grep newline settings")
+Path("testNinputgrep").write_bytes(b"abc\rdef\r\nghi\njkl")
+
+write_test_output(b"---------------------------- Test N1 -----------------------------\r\n", append=False)
+output([*pcre2grep_args, "-n", "-N", "CR", "^(abc|def|ghi|jkl)", "testNinputgrep"])
+output([*pcre2grep_args, "-B1", "-n", "-N", "CR", "^def", "testNinputgrep"])
+
+write_test_output(b"---------------------------- Test N2 -----------------------------\r\n")
+output([*pcre2grep_args, "-n", "--newline=crlf", "^(abc|def|ghi|jkl)", "testNinputgrep"])
+output([*pcre2grep_args, "-B1", "-n", "-N", "CRLF", "^ghi", "testNinputgrep"])
+
+write_test_output(b"---------------------------- Test N3 -----------------------------\r\n")
+output([*pcre2grep_args, "-n", "--newline=cr", "-F", "def\rjkl", "testNinputgrep"])
+
+write_test_output(b"---------------------------- Test N4 -----------------------------\r\n")
+output([*pcre2grep_args, "-n", "--newline=crlf", "-F", "-f", srcdir / "testdata" / "greppatN4", "testNinputgrep"])
+
+write_test_output(b"---------------------------- Test N5 -----------------------------\r\n")
+output([*pcre2grep_args, "-n", "--newline=any", "^(abc|def|ghi|jkl)", "testNinputgrep"])
+output([*pcre2grep_args, "-B1", "-n", "--newline=any", "^def", "testNinputgrep"])
+
+write_test_output(b"---------------------------- Test N6 -----------------------------\r\n")
+output([*pcre2grep_args, "-n", "--newline=anycrlf", "^(abc|def|ghi|jkl)", "testNinputgrep"])
+output([*pcre2grep_args, "-B1", "-n", "--newline=anycrlf", "^jkl", "testNinputgrep"])
+
+write_test_output(b"---------------------------- Test N7 -----------------------------\r\n")
+Path("testNinputgrep").write_bytes(b"xyz\0abc\0def")
+output([*pcre2grep_args, "-na", "--newline=nul", "^(abc|def)", "testNinputgrep"],
+ transform=lambda data: data.replace(b"\0", b"@"))
+output([*pcre2grep_args, "-B1", "-na", "--newline=nul", "^(abc|def)", "testNinputgrep"],
+ transform=lambda data: data.replace(b"\0", b"@"))
+
+write_test_output(b"---------------------------- Test N8 -----------------------------\r\n")
+output([*pcre2grep_args, "-na", "--newline=anycrlf", "^a", srcdir / "testdata" / "grepinputBad8_Trail"])
+
+write_test_output(b"\n")
+if not compare(srcdir / "testdata" / "grepoutputN", "testtrygrep"):
+ sys.exit(1)
+
+# These newline tests need UTF support.
+
+if supports_utf8:
+ print("Testing pcre2grep newline settings with UTF-8 features")
+
+ write_test_output(b"---------------------------- Test UN1 -----------------------------\r\n", append=False)
+ output([*pcre2grep_args, "-nau", "--newline=anycrlf", "^(abc|def)", srcdir / "testdata" / "grepinputUN"])
+
+ write_test_output(b"---------------------------- Test UN2 -----------------------------\r\n")
+ output([*pcre2grep_args, "-nauU", "--newline=anycrlf", "^a", srcdir / "testdata" / "grepinputBad8_Trail"])
+ write_test_output(b"\n")
+
+ if not compare(srcdir / "testdata" / "grepoutputUN", "testtrygrep"):
+ sys.exit(1)
+else:
+ print("Skipping pcre2grep newline UTF-8 tests: no UTF-8 support in PCRE2 library")
+
+# If pcre2grep supports script callouts, run some tests on them. It is possible
+# to restrict these callouts to the non-fork case, either for security, or for
+# environments that do not support fork(). This is handled by comparing to a
+# different output.
+
+if supports("callout scripts in patterns are supported"):
+ print("Testing pcre2grep script callouts")
+
+ # On Windows, we don't have a convenient echo binary, so it's built into
+ # pcre2test for convenience.
+ callout_echo = "/bin/echo" if os.name != "nt" else f"{pcre2test}|-echo"
+
+ write_test_output(b"--- Test 1 ---\n", append=False)
+ output([
+ *pcre2grep_args, f'(T)(..(.))(?C"{callout_echo}|Arg1: [$1] [$2] [$3]|Arg2: $|${{1}}$| ($4) ($14) ($0)")()',
+ srcdir / "testdata" / "grepinputv"
+ ])
+ write_test_output(b"--- Test 2 ---\n")
+ output([
+ *pcre2grep_args, f'(T)(..(.))()()()()()()()(..)(?C"{callout_echo}|Arg1: [$11] [${{11}}]")',
+ srcdir / "testdata" / "grepinputv"
+ ])
+ write_test_output(b"--- Test 3 ---\n")
+ output([*pcre2grep_args, '(T)(?C"|$0:$1$n")', srcdir / "testdata" / "grepinputv"])
+ write_test_output(b"--- Test 4 ---\n")
+ output([*pcre2grep_args, f'(T)(?C"{callout_echo}|$0:$1$n")', srcdir / "testdata" / "grepinputv"])
+ write_test_output(b"--- Test 5 ---\n")
+ output([*pcre2grep_args, '(T)(?C"|$1$n")(*F)', srcdir / "testdata" / "grepinputv"])
+ write_test_output(b"--- Test 6 ---\n")
+ output([*pcre2grep_args, "-m1", '(T)(?C"|$0:$1:$x{41}$o{101}$n")', srcdir / "testdata" / "grepinputv"])
+ supports_nonfork_callouts = supports("Non-fork callout scripts in patterns are supported")
+ if not compare(srcdir / "testdata" / ("grepoutputCN" if supports_nonfork_callouts else "grepoutputC"), "testtrygrep"):
+ sys.exit(1)
+ if supports_utf8:
+ print("Testing pcre2grep script callout with UTF-8 features")
+ write_test_output(b"--- Test 1 ---\n", append=False)
+ output([*pcre2grep_args, "-u", '(T)(?C"|$0:$x{a6}$n")', srcdir / "testdata" / "grepinputv"])
+ write_test_output(b"--- Test 2 ---\n")
+ output([*pcre2grep_args, "-u", f'(T)(?C"{callout_echo}|$0:$x{{a6}}$n")', srcdir / "testdata" / "grepinputv"])
+ if not compare(srcdir / "testdata" /
+ ("grepoutputCNU" if supports_nonfork_callouts else "grepoutputCU"), "testtrygrep"):
+ sys.exit(1)
+ else:
+ print("Skipping pcre2grep script callout UTF-8 tests: no UTF-8 support in PCRE2 library")
+else:
+ print("Script callouts are not supported")
+
+# Test reading .gz and .bz2 files when supported.
+
+if supports(r"\.gz are read using zlib"):
+ print("Testing reading .gz file")
+ with open("testtrygrep", "wb") as output_file:
+ returncode = invoke(*pcre2grep_args,
+ "one|two",
+ srcdir / "testdata" / "grepinputC.gz",
+ stdout=output_file,
+ use_vjs=True)
+ write_returncode(returncode)
+ if not compare(srcdir / "testdata" / "grepoutputCgz", "testtrygrep"):
+ sys.exit(1)
+
+if supports(r"\.bz2 are read using bzlib2"):
+ print("Testing reading .bz2 file")
+ with open("testtrygrep", "wb") as output_file:
+ returncode = invoke(*pcre2grep_args,
+ "one|two",
+ srcdir / "testdata" / "grepinputC.bz2",
+ stdout=output_file,
+ use_vjs=True)
+ write_returncode(returncode)
+ with open("testtrygrep", "ab") as output_file:
+ returncode = invoke(*pcre2grep_args,
+ "one|two",
+ srcdir / "testdata" / "grepnot.bz2",
+ stdout=output_file,
+ use_vjs=True)
+ write_returncode(returncode)
+ if not compare(srcdir / "testdata" / "grepoutputCbz2", "testtrygrep"):
+ sys.exit(1)
+
+# Finally, some tests to exercise code that is not tested above, just to be
+# sure that it runs OK. Doing this improves the coverage statistics. The output
+# is not checked.
+
+print("Testing miscellaneous pcre2grep arguments (unchecked)")
+Path("testtrygrep").write_bytes(b"\n")
+checkspecial(("-xxxxx", ), 2)
+checkspecial(("--help", ), 0)
+checkspecial(("--line-buffered", "--colour=auto", "abc", os.devnull), 1)
+checkspecial(("--line-buffered", "--color", "abc", os.devnull), 1)
+checkspecial(("-dskip", "abc", "."), 1)
+checkspecial(("-Dread", "-Dskip", "abc", os.devnull), 1)
+checkspecial(("-f", srcdir / "testdata" / "greplistBad", os.devnull), 2)
+checkspecial(("(unpaired", os.devnull), 2)
+checkspecial(("-e", "(unpaired1", "-e", "(unpaired2", os.devnull), 2)
+
+# Clean up local working files
+for filename in ("testNinputgrep", "teststderrgrep", "testtrygrep", "testtemp1grep", "testtemp2grep", "-testtemp1grep",
+ "--"):
+ try:
+ Path(filename).unlink()
+ except FileNotFoundError:
+ pass
+
+sys.exit(0)
diff --git a/RunTest b/RunTest
index d8a254333..584353447 100755
--- a/RunTest
+++ b/RunTest
@@ -77,9 +77,9 @@ title17="Test 17: JIT-specific features when JIT is available"
title18="Test 18: Tests of the POSIX interface, excluding UTF/UCP"
title19="Test 19: Tests of the POSIX interface with UTF/UCP"
title20="Test 20: Serialization and code copy tests"
-title21="Test 21: \C tests without UTF (supported for DFA matching)"
-title22="Test 22: \C tests with UTF (not supported for DFA matching)"
-title23="Test 23: \C disabled test"
+title21="Test 21: \\C tests without UTF (supported for DFA matching)"
+title22="Test 22: \\C tests with UTF (not supported for DFA matching)"
+title23="Test 23: \\C disabled test"
title24="Test 24: Non-UTF pattern conversion tests"
title25="Test 25: UTF pattern conversion tests"
title26="Test 26: Unicode property tests (compatible with Perl >= 5.38)"
@@ -89,7 +89,7 @@ title29="Test 29: EBCDIC-specific tests (for NL=0x25)"
maxtest=29
titleheap="Test 'heap': Environment-specific heap tests"
-if [ $# -eq 1 -a "$1" = "list" ]; then
+if [ $# -eq 1 ] && [ "$1" = "list" -o "$1" = "-list" -o "$1" = "--list" ] ; then
echo $title0
echo $title1
echo $title2 "(not UTF or UCP)"
@@ -128,6 +128,10 @@ if [ $# -eq 1 -a "$1" = "list" ]; then
exit 0
fi
+
+yield=0
+
+
# Set up a suitable "diff" command for comparison. Some systems
# have a diff that lacks a -u option. Try to deal with this.
# Use gdiff if available.
@@ -136,21 +140,6 @@ cf="diff"
gdiff /dev/null /dev/null 2>/dev/null && cf="gdiff"
$cf -u /dev/null /dev/null 2>/dev/null && cf="$cf -u"
-# Find the test data
-
-if [ -n "$srcdir" -a -d "$srcdir" ] ; then
- testdata="$srcdir/testdata"
-elif [ -d "./testdata" ] ; then
- testdata=./testdata
-elif [ -d "../testdata" ] ; then
- testdata=../testdata
-else
- echo "Cannot find the testdata directory"
- exit 1
-fi
-
-yield=0
-
# ------ Function to check results of a test -------
@@ -182,7 +171,7 @@ checkresult()
# - No-UTF
# Run in "preprocess-only" mode (-E) on the testoutput file to trim
# the output lines matching the input lines which are discarded.
- $sim $pcre2test -q -E "$cf_out" >testoutput$bits$3/testoutput$2-expected
+ $sim "$pcre2test" -q -E "$cf_out" >testoutput$bits$3/testoutput$2-expected
cf_out=testoutput$bits$3/testoutput$2-expected
fi
$cf "$cf_out" testoutput$bits$3/testoutput$2
@@ -200,16 +189,27 @@ checkresult()
checkspecial()
{
- expect=${2:-0}
- $sim $valgrind $vjs $pcre2test $1 >>testSoutput 2>&1
+ expect=$1
+ checkspecial_use_vjs=$2
+ shift 2
+ if [ "$checkspecial_use_vjs" = use_vjs ]; then
+ $sim $valgrind $vjs "$pcre2test" "$@" >>testSoutput 2>&1
+ else
+ $sim $valgrind "$pcre2test" "$@" >>testSoutput 2>&1
+ fi
if [ $? -ne "$expect" ] ; then
- echo "** pcre2test $1 failed - check testSoutput"
+ echo "** pcre2test $* failed - check testSoutput"
yield=1
return 1
fi
return 0
}
+set_vjs_for_opt()
+ {
+ if [ "$1" = "-jit" ]; then optvjs="$vjs"; else optvjs=; fi
+ }
+
# ------ Test setup ------
@@ -231,11 +231,6 @@ globalopts="-q"
# This is in case the caller has set aliases (as I do - PH)
unset cp ls mv rm
-if [ ! -x $pcre2test ] ; then
- echo "** $pcre2test does not exist or is not executable."
- exit 1
-fi
-
# Process options and select which tests to run; for those that are explicitly
# requested, check that the necessary optional facilities are available.
@@ -307,12 +302,14 @@ while [ $# -gt 0 ] ; do
-8) arg8=yes;;
-16) arg16=yes;;
-32) arg32=yes;;
- bigstack|-bigstack) bigstack=yes;;
- malloc|-malloc) malloc=yes;;
- nojit|-nojit) nojit=yes;;
- sim|-sim) shift; sim=$1;;
- valgrind|-valgrind) valgrind="valgrind --tool=memcheck -q --leak-check=yes --errors-for-leak-kinds=all --smc-check=all-non-file --error-exitcode=70";;
- valgrind-log|-valgrind-log) valgrind="valgrind --tool=memcheck --num-callers=30 --leak-check=yes --errors-for-leak-kinds=all --error-limit=no --smc-check=all-non-file --log-file=report.%p ";;
+ bigstack|-bigstack|--bigstack) bigstack=yes;;
+ malloc|-malloc|--malloc) malloc=yes;;
+ nojit|-nojit|--nojit) nojit=yes;;
+ sim|-sim|--sim) if [ $# -lt 2 ]; then echo "Missing argument after '$1'"; exit 1; fi; shift; sim="$1";;
+ srcdir|-srcdir|--srcdir) if [ $# -lt 2 ]; then echo "Missing argument after '$1'"; exit 1; fi; shift; srcdir="$1";;
+ pcre2test|-pcre2test|--pcre2test) if [ $# -lt 2 ]; then echo "Missing argument after '$1'"; exit 1; fi; shift; pcre2test="$1";;
+ valgrind|-valgrind|--valgrind) valgrind="valgrind --tool=memcheck -q --leak-check=yes --errors-for-leak-kinds=all --smc-check=all-non-file --error-exitcode=70";;
+ valgrind-log|-valgrind-log|--valgrind-log) valgrind="valgrind --tool=memcheck --num-callers=30 --leak-check=yes --errors-for-leak-kinds=all --error-limit=no --smc-check=all-non-file --log-file=report.%p ";;
~*)
if expr "$1" : '~[0-9][0-9]*$' >/dev/null; then
skip="$skip `expr "$1" : '~\([0-9]*\)*$'`"
@@ -341,10 +338,40 @@ while [ $# -gt 0 ] ; do
shift
done
+# Validate paths after argument processing
+
+if [ ! -x "$pcre2test" ] ; then
+ echo "** $pcre2test does not exist or is not executable."
+ exit 1
+fi
+
+# Find the test data
+
+if [ -n "$srcdir" ] ; then
+ if [ ! -d "$srcdir/testdata" ] ; then
+ echo "The specified srcdir '$srcdir' does not contain a testdata directory"
+ exit 1
+ fi
+
+ case "$srcdir" in
+ */) testdata="${srcdir}testdata";;
+ *) testdata="${srcdir}/testdata";;
+ esac
+else
+ if [ -d "./testdata" ] ; then
+ testdata=./testdata
+ elif [ -d "../testdata" ] ; then
+ testdata=../testdata
+ else
+ echo "Cannot find the testdata directory"
+ exit 1
+ fi
+fi
+
# If it is possible to set the system stack size and -bigstack was given,
# set up a large stack.
-$sim $pcre2test -S 32 /dev/null /dev/null >/dev/null 2>&1
+$sim "$pcre2test" -S 32 /dev/null /dev/null >/dev/null 2>&1
support_setstack=$?
if [ $support_setstack -eq 0 -a "$bigstack" != "" ] ; then
globalopts="$globalopts -S 32"
@@ -359,24 +386,24 @@ fi
# All of 8-bit, 16-bit, and 32-bit character strings may be supported, but only
# one need be.
-$sim $pcre2test -C pcre2-8 >/dev/null
+$sim "$pcre2test" -C pcre2-8 >/dev/null
support8=$?
-$sim $pcre2test -C pcre2-16 >/dev/null
+$sim "$pcre2test" -C pcre2-16 >/dev/null
support16=$?
-$sim $pcre2test -C pcre2-32 >/dev/null
+$sim "$pcre2test" -C pcre2-32 >/dev/null
support32=$?
# \C may be disabled
-$sim $pcre2test -C backslash-C >/dev/null
+$sim "$pcre2test" -C backslash-C >/dev/null
supportBSC=$?
# Check if compiled in EBCDIC mode, and whether we have EBCDIC I/O and NL=0x25
-$sim $pcre2test -C ebcdic >/dev/null
+$sim "$pcre2test" -C ebcdic >/dev/null
ebcdic=$?
-$sim $pcre2test -C ebcdic-io >/dev/null
+$sim "$pcre2test" -C ebcdic-io >/dev/null
ebcdic_io=$?
-$sim $pcre2test -C ebcdic-nl25 >/dev/null
+$sim "$pcre2test" -C ebcdic-nl25 >/dev/null
ebcdic_nl25=$?
if [ $ebcdic -eq 1 ]; then
@@ -441,7 +468,7 @@ fi
# sizes if both are supported; we can't have UTF-8 support without UTF-16 or
# UTF-32 support.
-$sim $pcre2test -C unicode >/dev/null
+$sim "$pcre2test" -C unicode >/dev/null
utf=$?
# When JIT is used with valgrind, we need to set up valgrind suppressions as
@@ -449,7 +476,7 @@ utf=$?
# the hardware supports SSE2.
jitopt=
-$sim $pcre2test -C jit >/dev/null
+$sim "$pcre2test" -C jit >/dev/null
jit=$?
if [ $jit -ne 0 -a "$nojit" != "yes" ] ; then
jitopt=-jit
@@ -511,7 +538,7 @@ for i in $skip; do eval do$i=no; done
echo ""
echo PCRE2 C library tests using test data from $testdata
-$sim $pcre2test /dev/null
+$sim "$pcre2test" /dev/null
echo ""
@@ -542,23 +569,23 @@ for bmode in "$test8" "$test16" "$test32"; do
echo ' abc' >>testSinput
echo '' >testSoutput
saverc=0
- checkspecial "$bmode -C" || saverc=$?
- checkspecial '--help' || saverc=$?
- checkspecial "$bmode testSinput" || saverc=$?
- checkspecial "$bmode $testdata/testinputheap" || saverc=$?
+ checkspecial 0 no_vjs "$bmode" -C || saverc=$?
+ checkspecial 0 no_vjs --help || saverc=$?
+ checkspecial 0 use_vjs "$bmode" testSinput || saverc=$?
+ checkspecial 0 no_vjs "$bmode" "$testdata/testinputheap" || saverc=$?
if [ $support_setstack -eq 0 ] ; then
- checkspecial "$bmode -S 1 -t 10 testSinput" || saverc=$?
+ checkspecial 0 use_vjs "$bmode" -S 1 -t 10 testSinput || saverc=$?
fi
- checkspecial "$bmode reallydoesnotexist" 1 || saverc=$?
- checkspecial "$bmode testSinput reallydoesnotexist/outfile" 1 || saverc=$?
- checkspecial "$bmode -pattern debug testSinput" || saverc=$?
- checkspecial "$bmode -pattern INVALID testSinput" 1 2>/dev/null || saverc=$?
- checkspecial "$bmode -subject notempty testSinput" || saverc=$?
- checkspecial "$bmode -subject INVALID testSinput" 1 2>/dev/null || saverc=$?
- checkspecial -LM || saverc=$?
- checkspecial -LP || saverc=$?
- checkspecial -LS || saverc=$?
- checkspecial "$bmode -unittest" || saverc=$?
+ checkspecial 1 no_vjs "$bmode" reallydoesnotexist || saverc=$?
+ checkspecial 1 no_vjs "$bmode" testSinput reallydoesnotexist/outfile || saverc=$?
+ checkspecial 0 use_vjs "$bmode" -pattern debug testSinput || saverc=$?
+ checkspecial 1 no_vjs "$bmode" -pattern INVALID testSinput 2>/dev/null || saverc=$?
+ checkspecial 0 use_vjs "$bmode" -subject notempty testSinput || saverc=$?
+ checkspecial 1 no_vjs "$bmode" -subject INVALID testSinput 2>/dev/null || saverc=$?
+ checkspecial 0 no_vjs -LM || saverc=$?
+ checkspecial 0 no_vjs -LP || saverc=$?
+ checkspecial 0 no_vjs -LS || saverc=$?
+ checkspecial 0 use_vjs "$bmode" -unittest || saverc=$?
if [ $saverc -eq 0 ] ; then
echo " OK"
fi
@@ -569,7 +596,8 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $do1 = yes ] ; then
echo $title1
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput1 testoutput$bits$opt/testoutput1
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput1" testoutput$bits$opt/testoutput1
checkresult $? 1 "$opt"
done
fi
@@ -579,12 +607,13 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $do2 = yes ] ; then
echo $title2 "(excluding UTF-$bits)"
- cp $testdata/testbtables .
+ cp "$testdata/testbtables" .
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput2 testoutput$bits$opt/testoutput2
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput2" testoutput$bits$opt/testoutput2
saverc=$?
if [ $saverc = 0 ] ; then
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt -error -80,-62,-2,-1,0,100,101,191,300 >>testoutput$bits$opt/testoutput2
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt -error -80,-62,-2,-1,0,100,101,191,300 >>testoutput$bits$opt/testoutput2
checkresult $? 2 "$opt"
else
checkresult $saverc 2 "$opt"
@@ -592,58 +621,59 @@ for bmode in "$test8" "$test16" "$test32"; do
done
fi
- # Locale-specific tests, provided that either the "fr_FR", "fr_CA", "french"
- # or "fr" locale is available. The first two are Unix-like standards; the
- # last two are for Windows. Unfortunately, different versions of the French
+ # Locale-specific tests. Unfortunately, different versions of the French
# locale give different outputs for some items. This test passes if the
# output matches any one of the alternative output files.
if [ $do3 = yes ] ; then
locale=
+ locales='french fr_FR fr fr_CA'
# In some environments locales that are listed by the "locale -a"
# command do not seem to work with setlocale(). Therefore, we do
# a preliminary test to see if pcre2test can set one before going
# on to use it.
- for loc in 'fr_FR' 'french' 'fr' 'fr_CA'; do
- locale -a | grep "^$loc\$" >/dev/null
- if [ $? -eq 0 ] ; then
- echo "/a/locale=$loc" | \
- $sim $valgrind $pcre2test -q $bmode | \
- grep "Failed to set locale" >/dev/null
- if [ $? -ne 0 ] ; then
- locale=$loc
- if [ "$locale" = "fr_FR" ] ; then
- infile=$testdata/testinput3
- outfile=$testdata/testoutput3
- outfile2=$testdata/testoutput3A
- outfile3=$testdata/testoutput3B
- outfile4=$testdata/testoutput3C
- outfile5=$testdata/testoutput3D
- else
- infile=test3input
- outfile=test3output
- outfile2=test3outputA
- outfile3=test3outputB
- outfile4=test3outputC
- outfile5=test3outputD
- sed "s/fr_FR/$loc/" $testdata/testinput3 >test3input
- sed "s/fr_FR/$loc/" $testdata/testoutput3 >test3output
- sed "s/fr_FR/$loc/" $testdata/testoutput3A >test3outputA
- sed "s/fr_FR/$loc/" $testdata/testoutput3B >test3outputB
- sed "s/fr_FR/$loc/" $testdata/testoutput3C >test3outputC
- sed "s/fr_FR/$loc/" $testdata/testoutput3D >test3outputD
- fi
- break
- fi
+ for loc in $locales; do
+ if ! command -v locale >/dev/null 2>&1; then
+ continue
fi
+
+ if ! (locale -a | grep "^$loc\$" >/dev/null); then
+ continue
+ fi
+
+ if (echo "/a/locale=$loc" | \
+ $sim $valgrind "$pcre2test" -q $bmode | \
+ grep "Failed to set locale" >/dev/null); then
+ continue
+ fi
+
+ locale=$loc
+ infile=test3input
+ outfile=test3output
+ outfile2=test3outputA
+ outfile3=test3outputB
+ outfile4=test3outputC
+ outfile5=test3outputD
+ outfile6=test3outputE
+ outfile7=test3outputF
+ sed "s/fr_FR/$loc/" "$testdata/testinput3" >test3input
+ sed "s/fr_FR/$loc/" "$testdata/testoutput3" >test3output
+ sed "s/fr_FR/$loc/" "$testdata/testoutput3A" >test3outputA
+ sed "s/fr_FR/$loc/" "$testdata/testoutput3B" >test3outputB
+ sed "s/fr_FR/$loc/" "$testdata/testoutput3C" >test3outputC
+ sed "s/fr_FR/$loc/" "$testdata/testoutput3D" >test3outputD
+ sed "s/fr_FR/$loc/" "$testdata/testoutput3E" >test3outputE
+ sed "s/fr_FR/$loc/" "$testdata/testoutput3F" >test3outputF
+ break
done
if [ "$locale" != "" ] ; then
echo $title3 "(using '$locale' locale)"
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $infile testoutput$bits/testoutput3
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$infile" testoutput$bits/testoutput3
if [ $? = 0 ] ; then
case "$opt" in
-jit) with=" with JIT";;
@@ -653,14 +683,16 @@ for bmode in "$test8" "$test16" "$test32"; do
$cf $outfile2 testoutput$bits/testoutput3 >>teststdout || \
$cf $outfile3 testoutput$bits/testoutput3 >>teststdout || \
$cf $outfile4 testoutput$bits/testoutput3 >>teststdout || \
- $cf $outfile5 testoutput$bits/testoutput3 >>teststdout
+ $cf $outfile5 testoutput$bits/testoutput3 >>teststdout || \
+ $cf $outfile6 testoutput$bits/testoutput3 >>teststdout || \
+ $cf $outfile7 testoutput$bits/testoutput3 >>teststdout
then
echo " OK$with"
else
cat teststdout
echo ""
echo "** Locale test did not run successfully$with. The output did not match"
- echo " $outfile, $outfile2, $outfile3, $outfile4 or $outfile5."
+ echo " $outfile, $outfile2, $outfile3, $outfile4, $outfile5, $outfile6 or $outfile7."
echo " This may mean that there is a problem with the locale settings rather"
echo " than a bug in PCRE2."
yield=1
@@ -671,11 +703,13 @@ for bmode in "$test8" "$test16" "$test32"; do
fi
done
else
- echo "Cannot test locale-specific features - none of the 'fr_FR', 'fr_CA',"
- echo "'fr' or 'french' locales can be set, or the \"locale\" command is"
- echo "not available to check for them."
+ echo "Cannot test locale-specific features - none of the French locales"
+ echo "($locales) could be set."
echo " "
fi
+
+ unset locale
+ unset locales
fi
# Tests for UTF and Unicode property support
@@ -686,7 +720,8 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped because UTF-$bits support is not available"
else
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput4 testoutput$bits$opt/testoutput4
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput4" testoutput$bits$opt/testoutput4
checkresult $? 4 "$opt"
done
fi
@@ -698,7 +733,8 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped because UTF-$bits support is not available"
else
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput5 testoutput$bits$opt/testoutput5
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput5" testoutput$bits$opt/testoutput5
checkresult $? 5 "$opt"
done
fi
@@ -708,7 +744,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $do6 = yes ] ; then
echo $title6
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput6 testoutput$bits/testoutput6
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput6" testoutput$bits/testoutput6
checkresult $? 6 ""
fi
@@ -717,7 +753,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $utf -eq 0 ] ; then
echo " Skipped because UTF-$bits support is not available"
else
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput7 testoutput$bits/testoutput7
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput7" testoutput$bits/testoutput7
checkresult $? 7 ""
fi
fi
@@ -732,12 +768,12 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $do8 = yes ] ; then
echo $title8
- $sim $pcre2test -$bits -C linksize >/dev/null
+ $sim "$pcre2test" -$bits -C linksize >/dev/null
bits_link_size=$?
if [ $utf -eq 0 ] ; then
echo " Skipped because UTF-$bits support is not available"
else
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput8 testoutput$bits/testoutput8-$bits-$bits_link_size
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput8" testoutput$bits/testoutput8-$bits-$bits_link_size
checkresult $? 8-$bits-$bits_link_size ""
fi
fi
@@ -750,7 +786,8 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped when running 16/32-bit tests"
else
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput9 testoutput$bits$opt/testoutput9
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput9" testoutput$bits$opt/testoutput9
checkresult $? 9 "$opt"
done
fi
@@ -766,7 +803,8 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped because UTF-$bits support is not available"
else
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput10 testoutput$bits$opt/testoutput10
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput10" testoutput$bits$opt/testoutput10
checkresult $? 10 "$opt"
done
fi
@@ -780,7 +818,8 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped when running 8-bit tests"
else
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput11 testoutput$bits$opt/testoutput11-$bits
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput11" testoutput$bits$opt/testoutput11-$bits
checkresult $? 11-$bits "$opt"
done
fi
@@ -797,7 +836,8 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped because UTF-$bits support is not available"
else
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput12 testoutput$bits$opt/testoutput12-$bits
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput12" testoutput$bits$opt/testoutput12-$bits
checkresult $? 12-$bits "$opt"
done
fi
@@ -810,7 +850,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ "$bits" = "8" ] ; then
echo " Skipped when running 8-bit tests"
else
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput13 testoutput$bits/testoutput13
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput13" testoutput$bits/testoutput13
checkresult $? 13 ""
fi
fi
@@ -822,7 +862,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $utf -eq 0 ] ; then
echo " Skipped because UTF-$bits support is not available"
else
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput14 testoutput$bits/testoutput14-$bits
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput14" testoutput$bits/testoutput14-$bits
checkresult $? 14-$bits ""
fi
fi
@@ -831,7 +871,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $do15 = yes ] ; then
echo $title15
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput15 testoutput$bits/testoutput15
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput15" testoutput$bits/testoutput15
checkresult $? 15 ""
fi
@@ -842,7 +882,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $jit -ne 0 ] ; then
echo " Skipped because JIT is available"
else
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput16 testoutput$bits/testoutput16
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput16" testoutput$bits/testoutput16
checkresult $? 16 ""
fi
fi
@@ -854,7 +894,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $jit -eq 0 -o "$nojit" = "yes" ] ; then
echo " Skipped because JIT is not available or nojit was specified"
else
- $sim $valgrind $vjs $pcre2test $globalopts $bmode $testdata/testinput17 testoutput$bits/testoutput17
+ $sim $valgrind $vjs "$pcre2test" $globalopts $bmode "$testdata/testinput17" testoutput$bits/testoutput17
checkresult $? 17 ""
fi
fi
@@ -866,7 +906,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ "$bits" = "16" -o "$bits" = "32" ] ; then
echo " Skipped when running 16/32-bit tests"
else
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput18 testoutput$bits/testoutput18
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput18" testoutput$bits/testoutput18
checkresult $? 18 ""
fi
fi
@@ -880,7 +920,7 @@ for bmode in "$test8" "$test16" "$test32"; do
elif [ $utf -eq 0 ] ; then
echo " Skipped because UTF-$bits support is not available"
else
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput19 testoutput$bits/testoutput19
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput19" testoutput$bits/testoutput19
checkresult $? 19 ""
fi
fi
@@ -889,7 +929,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $do20 = yes ] ; then
echo $title20
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput20 testoutput$bits/testoutput20
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput20" testoutput$bits/testoutput20
checkresult $? 20 ""
fi
@@ -901,7 +941,8 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped because \C is disabled"
else
for opt in "" $jitopt -dfa; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput21 testoutput$bits$opt/testoutput21
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput21" testoutput$bits$opt/testoutput21
checkresult $? 21 "$opt"
done
fi
@@ -917,7 +958,8 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped because UTF-$bits support is not available"
else
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput22 testoutput$bits$opt/testoutput22-$bits
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput22" testoutput$bits$opt/testoutput22-$bits
checkresult $? 22-$bits "$opt"
done
fi
@@ -930,7 +972,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $supportBSC -ne 0 ] ; then
echo " Skipped because \C is not disabled"
else
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput23 testoutput$bits/testoutput23
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput23" testoutput$bits/testoutput23
checkresult $? 23 ""
fi
fi
@@ -939,7 +981,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ "$do24" = yes ] ; then
echo $title24
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput24 testoutput$bits/testoutput24
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput24" testoutput$bits/testoutput24
checkresult $? 24 ""
fi
@@ -950,7 +992,7 @@ for bmode in "$test8" "$test16" "$test32"; do
if [ $utf -eq 0 ] ; then
echo " Skipped because UTF-$bits support is not available"
else
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinput25 testoutput$bits/testoutput25
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinput25" testoutput$bits/testoutput25
checkresult $? 25 ""
fi
fi
@@ -963,7 +1005,8 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped because UTF-$bits support is not available"
else
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput26 testoutput$bits$opt/testoutput26
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput26" testoutput$bits$opt/testoutput26
checkresult $? 26 "$opt"
done
fi
@@ -977,7 +1020,8 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped because UTF-$bits support is not available"
else
for opt in "" $jitopt; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput27 testoutput$bits$opt/testoutput27
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput27" testoutput$bits$opt/testoutput27
checkresult $? 27 "$opt"
done
fi
@@ -991,7 +1035,8 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped when not targetting EBCDIC"
else
for opt in "" $jitopt "-dfa"; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput28 testoutput$bits$opt/testoutput28
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput28" testoutput$bits$opt/testoutput28
checkresult $? 28 "$opt"
done
fi
@@ -1007,18 +1052,19 @@ for bmode in "$test8" "$test16" "$test32"; do
echo " Skipped because EBCDIC newline is not 0x25"
else
for opt in "" $jitopt "-dfa"; do
- $sim $valgrind ${opt:+$vjs} $pcre2test $globalopts $bmode $opt $testdata/testinput29 testoutput$bits$opt/testoutput29
+ set_vjs_for_opt "$opt"
+ $sim $valgrind $optvjs "$pcre2test" $globalopts $bmode $opt "$testdata/testinput29" testoutput$bits$opt/testoutput29
checkresult $? 29 "$opt"
done
fi
fi
# Manually selected heap tests - output may vary in different environments,
- # which is why that are not automatically run.
+ # which is why they are not automatically run.
if [ $doheap = yes ] ; then
echo $titleheap
- $sim $valgrind $pcre2test $globalopts $bmode $testdata/testinputheap testoutput$bits/testoutputheap-$bits
+ $sim $valgrind "$pcre2test" $globalopts $bmode "$testdata/testinputheap" testoutput$bits/testoutputheap-$bits
checkresult $? heap-$bits ""
fi
@@ -1031,7 +1077,9 @@ if [ $yield -eq 0 ] ; then
echo "All tests passed."
# Clean up local working files
- rm -f testbtables testSinput testSoutput test3input test3output test3outputA test3outputB testsaved1 testsaved2 teststdout teststderr
+ rm -f testbtables testSinput testSoutput test3input \
+ test3output test3outputA test3outputB test3outputC test3outputD test3outputE test3outputF \
+ testsaved1 testsaved2 teststdout teststderr
rm -rf testoutput8 testoutput8-jit testoutput8-dfa \
testoutput16 testoutput16-jit testoutput16-dfa \
testoutput32 testoutput32-jit testoutput32-dfa
diff --git a/RunTest.bat b/RunTest.bat
deleted file mode 100644
index f55e5bbbd..000000000
--- a/RunTest.bat
+++ /dev/null
@@ -1,603 +0,0 @@
-@echo off
-@rem
-@rem MS Windows batch file to run pcre2test on testfiles with the correct
-@rem options. This file must use CRLF linebreaks to function properly.
-@rem
-@rem ------------------------ HISTORY ----------------------------------
-@rem This file was originally contributed to PCRE1 by Ralf Junker, and touched
-@rem up by Daniel Richard G. Tests 10-12 added by Philip H.
-@rem Philip H also changed test 3 to use "wintest" files.
-@rem
-@rem Updated by Tom Fortmann to support explicit test numbers on the command
-@rem line. Added argument validation and added error reporting.
-@rem
-@rem Sheri Pierce added logic to skip feature dependent tests
-@rem tests 4 5 7 10 12 14 19 22 25 and 26 require Unicode support
-@rem 8 requires Unicode
-@rem 16 requires absence of jit support
-@rem 17 requires presence of jit support
-@rem Sheri P also added override tests for study and jit testing
-@rem Zoltan Herczeg added libpcre16 support
-@rem Zoltan Herczeg added libpcre32 support
-@rem -------------------------------------------------------------------
-@rem
-@rem The file was converted for PCRE2 by PH, February 2015.
-@rem Updated for new test 14 (moving others up a number), August 2015.
-@rem Tidied and updated for new tests 21, 22, 23 by PH, October 2015.
-@rem PH added missing "set type" for test 22, April 2016.
-@rem PH added copy command for new testbtables file, November 2020
-@rem PH caused it to show comparison output when comparison failed, July 2023
-@rem PH updated unknown error number in test
-
-
-setlocal enabledelayedexpansion
-if [%srcdir%]==[] (
-if exist testdata\ set srcdir=.)
-if [%srcdir%]==[] (
-if exist ..\testdata\ set srcdir=..)
-if [%srcdir%]==[] (
-if exist ..\..\testdata\ set srcdir=..\..)
-if NOT exist %srcdir%\testdata\ (
-echo Error: distribution testdata folder not found!
-call :conferror
-exit /b 1
-goto :eof
-)
-
-if [%pcre2test%]==[] set pcre2test=.\pcre2test.exe
-
-echo source dir is %srcdir%
-echo pcre2test=%pcre2test%
-
-if NOT exist %pcre2test% (
-echo Error: %pcre2test% not found!
-echo.
-call :conferror
-exit /b 1
-)
-
-%pcre2test% -C pcre2-8 >NUL
-set support8=%ERRORLEVEL%
-%pcre2test% -C pcre2-16 >NUL
-set support16=%ERRORLEVEL%
-%pcre2test% -C pcre2-32 >NUL
-set support32=%ERRORLEVEL%
-%pcre2test% -C unicode >NUL
-set unicode=%ERRORLEVEL%
-%pcre2test% -C jit >NUL
-set jit=%ERRORLEVEL%
-%pcre2test% -C backslash-C >NUL
-set supportBSC=%ERRORLEVEL%
-%pcre2test% -C ebcdic >NUL
-set ebcdic=%ERRORLEVEL%
-%pcre2test% -C ebcdic-nl25 >NUL
-set ebcdic_nl25=%ERRORLEVEL%
-
-if %support8% EQU 1 (
-if not exist testout8 md testout8
-if not exist testoutjit8 md testoutjit8
-)
-
-if %support16% EQU 1 (
-if not exist testout16 md testout16
-if not exist testoutjit16 md testoutjit16
-)
-
-if %support32% EQU 1 (
-if not exist testout32 md testout32
-if not exist testoutjit32 md testoutjit32
-)
-
-set do1=no
-set do2=no
-set do3=no
-set do4=no
-set do5=no
-set do6=no
-set do7=no
-set do8=no
-set do9=no
-set do10=no
-set do11=no
-set do12=no
-set do13=no
-set do14=no
-set do15=no
-set do16=no
-set do17=no
-set do18=no
-set do19=no
-set do20=no
-set do21=no
-set do22=no
-set do23=no
-set do24=no
-set do25=no
-set do26=no
-set do27=no
-set do28=no
-set do29=no
-set all=yes
-
-for %%a in (%*) do (
- set valid=no
- for %%v in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29) do if %%v == %%a set valid=yes
- if "!valid!" == "yes" (
- set do%%a=yes
- set all=no
- ) else (
- echo Invalid test number - %%a!
- echo Usage %0 [ test_number ] ...
- echo Where test_number is one or more optional test numbers 1 through 29, default is all tests.
- exit /b 1
- )
-)
-set failed="no"
-
-if "%all%" == "yes" (
- set do1=yes
- set do2=yes
- set do3=yes
- set do4=yes
- set do5=yes
- set do6=yes
- set do7=yes
- set do8=yes
- set do9=yes
- set do10=yes
- set do11=yes
- set do12=yes
- set do13=yes
- set do14=yes
- set do15=yes
- set do16=yes
- set do17=yes
- set do18=yes
- set do19=yes
- set do20=yes
- set do21=yes
- set do22=yes
- set do23=yes
- set do24=yes
- set do25=yes
- set do26=yes
- set do27=yes
- set do28=yes
- set do29=yes
-)
-
-@echo RunTest.bat's pcre2test output is written to newly created subfolders
-@echo named testout{8,16,32} and testoutjit{8,16,32}.
-@echo.
-
-set mode=
-set bits=8
-
-:nextMode
-if "%mode%" == "" (
- if %support8% EQU 0 goto modeSkip
- echo.
- echo ---- Testing 8-bit library ----
- echo.
-)
-if "%mode%" == "-16" (
- if %support16% EQU 0 goto modeSkip
- echo.
- echo ---- Testing 16-bit library ----
- echo.
-)
-if "%mode%" == "-32" (
- if %support32% EQU 0 goto modeSkip
- echo.
- echo ---- Testing 32-bit library ----
- echo.
-)
-if "%do1%" == "yes" call :do1
-if "%do2%" == "yes" call :do2
-if "%do3%" == "yes" call :do3
-if "%do4%" == "yes" call :do4
-if "%do5%" == "yes" call :do5
-if "%do6%" == "yes" call :do6
-if "%do7%" == "yes" call :do7
-if "%do8%" == "yes" call :do8
-if "%do9%" == "yes" call :do9
-if "%do10%" == "yes" call :do10
-if "%do11%" == "yes" call :do11
-if "%do12%" == "yes" call :do12
-if "%do13%" == "yes" call :do13
-if "%do14%" == "yes" call :do14
-if "%do15%" == "yes" call :do15
-if "%do16%" == "yes" call :do16
-if "%do17%" == "yes" call :do17
-if "%do18%" == "yes" call :do18
-if "%do19%" == "yes" call :do19
-if "%do20%" == "yes" call :do20
-if "%do21%" == "yes" call :do21
-if "%do22%" == "yes" call :do22
-if "%do23%" == "yes" call :do23
-if "%do24%" == "yes" call :do24
-if "%do25%" == "yes" call :do25
-if "%do26%" == "yes" call :do26
-if "%do27%" == "yes" call :do27
-if "%do28%" == "yes" call :do28
-if "%do29%" == "yes" call :do29
-:modeSkip
-if "%mode%" == "" (
- set mode=-16
- set bits=16
- goto nextMode
-)
-if "%mode%" == "-16" (
- set mode=-32
- set bits=32
- goto nextMode
-)
-
-@rem If mode is -32, testing is finished
-if %failed% == "yes" (
-echo In above output, one or more of the various tests failed!
-exit /b 1
-)
-echo All OK
-goto :eof
-
-:runsub
-@rem Function to execute pcre2test and compare the output
-@rem Arguments are as follows:
-@rem
-@rem 1 = test number
-@rem 2 = outputdir
-@rem 3 = test name use double quotes
-@rem 4 - 9 = pcre2test options
-
-if [%1] == [] (
- echo Missing test number argument!
- exit /b 1
-)
-
-if [%2] == [] (
- echo Missing outputdir!
- exit /b 1
-)
-
-if [%3] == [] (
- echo Missing test name argument!
- exit /b 1
-)
-
-if %1 == 8 (
- %pcre2test% -%bits% -C linksize >NUL
- set bits_link_size=!ERRORLEVEL!
- set outnum=%1-%bits%-!bits_link_size!
-) else if %1 == 11 (
- set outnum=%1-%bits%
-) else if %1 == 12 (
- set outnum=%1-%bits%
-) else if %1 == 14 (
- set outnum=%1-%bits%
-) else if %1 == 22 (
- set outnum=%1-%bits%
-) else (
- set outnum=%1
-)
-set testinput=testinput%1
-set testoutput=testoutput%outnum%
-if exist %srcdir%\testdata\win%testinput% (
- set testinput=wintestinput%1
- set testoutput=wintestoutput%outnum%
-)
-
-echo Test %1: %3
-%pcre2test% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% >%2%bits%\%testoutput%
-if errorlevel 1 (
- echo. failed executing command-line:
- echo. %pcre2test% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% ^>%2%bits%\%testoutput%
- set failed="yes"
- goto :eof
-) else if [%1]==[2] (
- %pcre2test% %mode% %4 %5 %6 %7 %8 %9 -error -80,-62,-2,-1,0,100,101,191,300 >>%2%bits%\%testoutput%
-)
-
-set testexpected=%srcdir%\testdata\%testoutput%
-
-if %ebcdic% EQU 1 (
- @rem We currently only use the #if ... #endif support in pcre2test for EBCDIC
- @rem testing. Run in "preprocess-only" mode (-E) on the testoutput file to trim
- @rem the output lines matching the input lines which are discarded.
- %pcre2test% -q -E %testexpected% >%2%bits%\%testoutput%-trimmed
- set testexpected=%2%bits%\%testoutput%-trimmed
-)
-
-fc /n %testexpected% %2%bits%\%testoutput% >NUL
-
-if errorlevel 1 (
- echo. failed comparison: fc /n %testexpected% %2%bits%\%testoutput%
- if [%1]==[3] (
- echo.
- echo ** Test 3 failure usually means french locale is not
- echo ** available on the system, rather than a bug or problem with PCRE2.
- echo.
- goto :eof
-)
- fc /n %testexpected% %2%bits%\%testoutput%
-
- set failed="yes"
- goto :eof
-)
-
-echo. Passed.
-goto :eof
-
-:do1
-call :runsub 1 testout "Main non-UTF, non-UCP functionality (Compatible with Perl >= 5.10)" -q
-if %jit% EQU 1 call :runsub 1 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do2
- copy /y %srcdir%\testdata\testbtables testbtables
- call :runsub 2 testout "API, errors, internals, and non-Perl stuff" -q
- if %jit% EQU 1 call :runsub 2 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do3
- call :runsub 3 testout "Locale-specific features" -q
- if %jit% EQU 1 call :runsub 3 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do4
-if %unicode% EQU 0 (
- echo Test 4 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 4 testout "UTF-%bits% and Unicode property support - (Compatible with Perl >= 5.10)" -q
- if %jit% EQU 1 call :runsub 4 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do5
-if %unicode% EQU 0 (
- echo Test 5 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 5 testout "API, internals, and non-Perl stuff for UTF-%bits% and UCP" -q
- if %jit% EQU 1 call :runsub 5 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do6
- call :runsub 6 testout "DFA matching main non-UTF, non-UCP functionality" -q
-goto :eof
-
-:do7
-if %unicode% EQU 0 (
- echo Test 7 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 7 testout "DFA matching with UTF-%bits% and Unicode property support" -q
- goto :eof
-
-:do8
-if %unicode% EQU 0 (
- echo Test 8 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 8 testout "Internal offsets and code size tests" -q
-goto :eof
-
-:do9
-if NOT %bits% EQU 8 (
- echo Test 9 Skipped when running 16/32-bit tests.
- goto :eof
-)
- call :runsub 9 testout "Specials for the basic 8-bit library" -q
- if %jit% EQU 1 call :runsub 9 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do10
-if NOT %bits% EQU 8 (
- echo Test 10 Skipped when running 16/32-bit tests.
- goto :eof
-)
-if %unicode% EQU 0 (
- echo Test 10 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 10 testout "Specials for the 8-bit library with Unicode support" -q
- if %jit% EQU 1 call :runsub 10 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do11
-if %bits% EQU 8 (
- echo Test 11 Skipped when running 8-bit tests.
- goto :eof
-)
- call :runsub 11 testout "Specials for the basic 16/32-bit library" -q
- if %jit% EQU 1 call :runsub 11 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do12
-if %bits% EQU 8 (
- echo Test 12 Skipped when running 8-bit tests.
- goto :eof
-)
-if %unicode% EQU 0 (
- echo Test 12 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 12 testout "Specials for the 16/32-bit library with Unicode support" -q
- if %jit% EQU 1 call :runsub 12 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do13
-if %bits% EQU 8 (
- echo Test 13 Skipped when running 8-bit tests.
- goto :eof
-)
- call :runsub 13 testout "DFA specials for the basic 16/32-bit library" -q
-goto :eof
-
-:do14
-if %unicode% EQU 0 (
- echo Test 14 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 14 testout "DFA specials for UTF and UCP support" -q
- goto :eof
-
-:do15
-call :runsub 15 testout "Non-JIT limits and other non_JIT tests" -q
-goto :eof
-
-:do16
-if %jit% EQU 1 (
- echo Test 16 Skipped due to presence of JIT support.
- goto :eof
-)
- call :runsub 16 testout "JIT-specific features when JIT is not available" -q
-goto :eof
-
-:do17
-if %jit% EQU 0 (
- echo Test 17 Skipped due to absence of JIT support.
- goto :eof
-)
- call :runsub 17 testout "JIT-specific features when JIT is available" -q
-goto :eof
-
-:do18
-if %bits% EQU 16 (
- echo Test 18 Skipped when running 16-bit tests.
- goto :eof
-)
-if %bits% EQU 32 (
- echo Test 18 Skipped when running 32-bit tests.
- goto :eof
-)
- call :runsub 18 testout "POSIX interface, excluding UTF-8 and UCP" -q
-goto :eof
-
-:do19
-if %bits% EQU 16 (
- echo Test 19 Skipped when running 16-bit tests.
- goto :eof
-)
-if %bits% EQU 32 (
- echo Test 19 Skipped when running 32-bit tests.
- goto :eof
-)
-if %unicode% EQU 0 (
- echo Test 19 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 19 testout "POSIX interface with UTF-8 and UCP" -q
-goto :eof
-
-:do20
-call :runsub 20 testout "Serialization tests" -q
-goto :eof
-
-:do21
-if %supportBSC% EQU 0 (
- echo Test 21 Skipped due to absence of backslash-C support.
- goto :eof
-)
- call :runsub 21 testout "Backslash-C tests without UTF" -q
- call :runsub 21 testout "Backslash-C tests without UTF (DFA)" -q -dfa
- if %jit% EQU 1 call :runsub 21 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do22
-if %supportBSC% EQU 0 (
- echo Test 22 Skipped due to absence of backslash-C support.
- goto :eof
-)
-if %unicode% EQU 0 (
- echo Test 22 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 22 testout "Backslash-C tests with UTF" -q
- if %jit% EQU 1 call :runsub 22 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do23
-if %supportBSC% EQU 1 (
- echo Test 23 Skipped due to presence of backslash-C support.
- goto :eof
-)
- call :runsub 23 testout "Backslash-C disabled test" -q
-goto :eof
-
-:do24
-call :runsub 24 testout "Non-UTF pattern conversion tests" -q
-goto :eof
-
-:do25
-if %unicode% EQU 0 (
- echo Test 25 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 25 testout "UTF pattern conversion tests" -q
-goto :eof
-
-:do26
-if %unicode% EQU 0 (
- echo Test 26 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 26 testout "Unicode property tests (Compatible with Perl >= 5.38)" -q
- if %jit% EQU 1 call :runsub 26 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do27
-if %unicode% EQU 0 (
- echo Test 27 Skipped due to absence of Unicode support.
- goto :eof
-)
- call :runsub 27 testout "Auto-generated unicode property tests" -q
- if %jit% EQU 1 call :runsub 27 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do28
-if %ebcdic% EQU 0 (
- echo Test 28 Skipped when not targetting EBCDIC.
- goto :eof
-)
- call :runsub 28 testout "EBCDIC-specific tests" -q
- call :runsub 28 testout "EBCDIC-specific tests (DFA)" -q -dfa
- if %jit% EQU 1 call :runsub 28 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:do29
-if %ebcdic% EQU 0 (
- echo Test 29 Skipped when not targetting EBCDIC.
- goto :eof
-)
-if %ebcdic_nl25% EQU 0 (
- echo Test 29 Skipped because EBCDIC newline is not 0x25.
- goto :eof
-)
- call :runsub 29 testout "EBCDIC-specific tests for NL=0x25" -q
- call :runsub 29 testout "EBCDIC-specific tests for NL=0x25 (DFA)" -q -dfa
- if %jit% EQU 1 call :runsub 29 testoutjit "Test with JIT Override" -q -jit
-goto :eof
-
-:conferror
-@echo.
-@echo Either your build is incomplete or you have a configuration error.
-@echo.
-@echo If configured with cmake and executed via "make test" or the MSVC "RUN_TESTS"
-@echo project, pcre2_test.bat defines variables and automatically calls RunTest.bat.
-@echo For manual testing of all available features, after configuring with cmake
-@echo and building, you can run the built pcre2_test.bat. For best results with
-@echo cmake builds and tests avoid directories with full path names that include
-@echo spaces for source or build.
-@echo.
-@echo Otherwise, if the build dir is in a subdir of the source dir, testdata needed
-@echo for input and verification should be found automatically when (from the
-@echo location of the the built exes) you call RunTest.bat. By default RunTest.bat
-@echo runs all tests compatible with the linked pcre2 library but it can be given
-@echo a test number as an argument.
-@echo.
-@echo If the build dir is not under the source dir you can either copy your exes
-@echo to the source folder or copy RunTest.bat and the testdata folder to the
-@echo location of your built exes and then run RunTest.bat.
-@echo.
-goto :eof
diff --git a/RunTest.py b/RunTest.py
new file mode 100755
index 000000000..3a64bea43
--- /dev/null
+++ b/RunTest.py
@@ -0,0 +1,942 @@
+#!/usr/bin/env python3
+
+###############################################################################
+# Run the PCRE2 tests using the pcre2test program. The appropriate tests are
+# selected, depending on which build-time options were used.
+#
+# When JIT support is available, all appropriate tests are run with and without
+# JIT, unless "-nojit" is given on the command line. There are also two tests
+# for JIT-specific features, one to be run when JIT support is available
+# (unless "-nojit" is specified), and one when it is not.
+#
+# Whichever of the 8-, 16- and 32-bit libraries exist are tested. It is also
+# possible to select which to test by giving "-8", "-16" or "-32" on the
+# command line.
+#
+# As well as "-nojit", "-8", "-16", and "-32", arguments for this script are
+# individual test numbers, ranges of tests such as 3-6 or 3- (meaning 3 to the
+# end), or a number preceded by ~ to exclude a test. For example, "3-15 ~10"
+# runs tests 3 to 15, excluding test 10, and just "~10" runs all the tests
+# except test 10. Whatever order the arguments are in, these tests are always
+# run in numerical order.
+#
+# If no specific tests are selected (which is the case when this script is run
+# via 'make check') the default is to run all the numbered tests.
+#
+# There may also be named (as well as numbered) tests for special purposes. At
+# present there is just one, called "heap". This test's output contains the
+# sizes of heap frames and frame vectors, which depend on the environment. It
+# is therefore not run unless explicitly requested.
+#
+# Inappropriate tests are automatically skipped (with a comment to say so). For
+# example, if JIT support is not compiled, test 16 is skipped, whereas if JIT
+# support is compiled, test 15 is skipped.
+#
+# Other arguments can be one of the words "-valgrind", "-valgrind-log", or
+# "-sim" followed by an argument to run cross-compiled executables under a
+# simulator, for example:
+#
+# RunTest 3 -sim "qemu-arm -s 8388608"
+#
+# For backwards compatibility, -nojit, -valgrind, -valgrind-log, and -sim may
+# be given without the leading "-" character.
+#
+# When PCRE2 is compiled by clang with -fsanitize arguments, some tests need
+# very much more stack than normal. In environments where the stack can be
+# set at runtime, -bigstack sets a gigantic stack.
+#
+# Special cases where only one argument is allowed:
+# - If the script is invoked as "RunTest list", a list of available tests is
+# output, but none of them are run.
+###############################################################################
+
+# We use `yapf` for auto-formatting our Python files.
+# Applied to both Python test runners using:
+# > pip3 install yapf
+# > yapf --in-place --style maint/formatting.yapf RunTest.py RunGrepTest.py
+
+import difflib
+import os
+import re
+import shutil
+import subprocess
+import sys
+from pathlib import Path
+
+# Ensure that Python does not hold onto output, to make it clear where it got
+# to on failure.
+
+sys.stdout.reconfigure(line_buffering=True)
+
+# Define test titles in variables so that they can be output as a list. Some
+# of them are modified (e.g. with -8 or -16) when used in the actual tests.
+
+title0 = "Test 0: Unchecked pcre2test argument tests (to improve coverage)"
+title1 = "Test 1: Main non-UTF, non-UCP functionality (compatible with Perl >= 5.10)"
+title2 = "Test 2: API, errors, internals and non-Perl stuff"
+title3 = "Test 3: Locale-specific features"
+title4A = "Test 4: UTF"
+title4B = " and Unicode property support (compatible with Perl >= 5.10)"
+title5A = "Test 5: API, internals, and non-Perl stuff for UTF"
+title5B = " and UCP support"
+title6 = "Test 6: DFA matching main non-UTF, non-UCP functionality"
+title7A = "Test 7: DFA matching with UTF"
+title7B = " and Unicode property support"
+title8 = "Test 8: Internal offsets and code size tests"
+title9 = "Test 9: Specials for the basic 8-bit library"
+title10 = "Test 10: Specials for the 8-bit library with UTF-8 and UCP support"
+title11 = "Test 11: Specials for the basic 16-bit and 32-bit libraries"
+title12 = "Test 12: Specials for the 16-bit and 32-bit libraries UTF and UCP support"
+title13 = "Test 13: DFA specials for the basic 16-bit and 32-bit libraries"
+title14 = "Test 14: DFA specials for UTF and UCP support"
+title15 = "Test 15: Non-JIT limits and other non-JIT tests"
+title16 = "Test 16: JIT-specific features when JIT is not available"
+title17 = "Test 17: JIT-specific features when JIT is available"
+title18 = "Test 18: Tests of the POSIX interface, excluding UTF/UCP"
+title19 = "Test 19: Tests of the POSIX interface with UTF/UCP"
+title20 = "Test 20: Serialization and code copy tests"
+title21 = "Test 21: \\C tests without UTF (supported for DFA matching)"
+title22 = "Test 22: \\C tests with UTF (not supported for DFA matching)"
+title23 = "Test 23: \\C disabled test"
+title24 = "Test 24: Non-UTF pattern conversion tests"
+title25 = "Test 25: UTF pattern conversion tests"
+title26 = "Test 26: Unicode property tests (compatible with Perl >= 5.38)"
+title27 = "Test 27: Auto-generated unicode property tests"
+title28 = "Test 28: EBCDIC-specific tests"
+title29 = "Test 29: EBCDIC-specific tests (for NL=0x25)"
+maxtest = 29
+titleheap = "Test 'heap': Environment-specific heap tests"
+
+if len(sys.argv) == 2 and sys.argv[1] in ("list", "-list", "--list"):
+ for title in (title0, title1, title2 + " (not UTF or UCP)", title3, title4A + title4B, title5A + title5B, title6,
+ title7A + title7B, title8, title9, title10, title11, title12, title13, title14, title15, title16,
+ title17, title18, title19, title20, title21, title22, title23, title24, title25, title26, title27,
+ title28, title29):
+ print(title)
+ print()
+ print(titleheap)
+ print()
+ print("Numbered tests are automatically run if nothing selected.")
+ print("Named tests must be explicitly selected.")
+ sys.exit(0)
+
+failed = False
+
+# ------ Functions to help invoking tests -------
+
+# This function is called with four parameters:
+#
+# returncode the return code after a call to pcre2test
+# suffix the suffix of the output file to compare with
+# opts the pcre2test option arguments (empty, -jit, or -dfa)
+# bits the library code unit width
+
+
+def invoke(*args, stdin=None, stdout=None, stderr=None, use_valgrind=True, use_vjs=False):
+ command = [str(arg) for arg in args]
+ if valgrind and use_valgrind:
+ command = [*valgrind, *(vjs if use_vjs else []), *command]
+ command = [*sim, *command]
+ return subprocess.run(command, stdin=stdin, stdout=stdout, stderr=stderr, check=False).returncode
+
+
+def compare(first, second):
+ try:
+ with open(first, "rb") as first_file, open(second, "rb") as second_file:
+ while True:
+ first_bytes = first_file.read(65536)
+ second_bytes = second_file.read(65536)
+ if first_bytes != second_bytes:
+ return False
+ if not first_bytes:
+ return True
+ except OSError:
+ return False
+
+
+# ------ Function to check results of a test -------
+
+# This function is called with four parameters:
+#
+# returncode the return code after a call to pcre2test
+# suffix the suffix of the output file to compare with
+# opts the pcre2test option arguments ([], [-jit], or [-dfa])
+# bits the library code unit width
+
+
+def checkresult(returncode, suffix, opts, bits):
+ global failed
+ opt = "".join(opts)
+ output = Path(f"testoutput{bits}{opt}") / f"testoutput{suffix}"
+ if returncode != 0:
+ print(f"** pcre2test failed - check {output}")
+ failed = True
+ return
+ with_message = " with JIT" if opt == "-jit" else " with DFA" if opt == "-dfa" else ""
+ expected = testdata / f"testoutput{suffix}"
+ if uses_ebcdic or not supports_utf:
+ # We currently only use the #if ... #endif support in pcre2test for tests
+ # which are excluded in certain builds:
+ # - EBCDIC
+ # - No-UTF
+ # Run in "preprocess-only" mode (-E) on the testoutput file to trim
+ # the output lines matching the input lines which are discarded.
+ expected_output = Path(f"testoutput{bits}{opt}") / f"testoutput{suffix}-expected"
+ with open(expected_output, "wb") as stream:
+ invoke(pcre2test, "-q", "-E", expected, stdout=stream, use_valgrind=False)
+ expected = expected_output
+ if not compare(expected, output):
+ try:
+ print("".join(
+ difflib.unified_diff(expected.read_bytes().decode("latin-1").splitlines(keepends=True),
+ output.read_bytes().decode("latin-1").splitlines(keepends=True),
+ fromfile=str(expected),
+ tofile=str(output))),
+ end="")
+ except OSError:
+ pass
+ print()
+ print(f"** Test {suffix} failed{with_message}")
+ failed = True
+ return
+ print(f" OK{with_message}")
+
+
+# ------ Test setup ------
+
+arg8 = arg16 = arg32 = nojit = bigstack = malloc = False
+sim = []
+skip = []
+valgrind = []
+globalopts = ["-q"]
+pcre2test = os.environ.get("pcre2test", None) or ("./pcre2test.exe" if os.name == "nt" else "./pcre2test")
+srcdir = os.environ.get("srcdir", "")
+testdatatar = os.environ.get("testdatatar", "")
+bazel_runfiles = False
+
+# Process options and select which tests to run; for those that are explicitly
+# requested, check that the necessary optional facilities are available.
+
+do = [False] * 30
+doheap = False
+
+arguments = iter(sys.argv[1:])
+for argument in arguments:
+ range_match = re.fullmatch(r"([0-9]+)-([0-9]*)", argument)
+ if argument.isascii() and argument.isdecimal() and int(argument) <= maxtest:
+ do[int(argument)] = True
+ elif argument == "heap":
+ doheap = True
+ elif argument == "-8":
+ arg8 = True
+ elif argument == "-16":
+ arg16 = True
+ elif argument == "-32":
+ arg32 = True
+ elif argument in ("bigstack", "-bigstack", "--bigstack"):
+ bigstack = True
+ elif argument in ("malloc", "-malloc", "--malloc"):
+ malloc = True
+ elif argument in ("nojit", "-nojit", "--nojit"):
+ nojit = True
+ elif argument in ("sim", "-sim", "--sim"):
+ try:
+ # The historical RunTest(.sh) behaviour is to assign the argument following
+ # '-sim' to one variable, then invoke it unquoted as $sim, performing word
+ # splitting. It's crude, but allows a simulator binary with simple arguments.
+ sim = next(arguments).split()
+ except StopIteration:
+ print(f"Missing argument after '{argument}'")
+ sys.exit(1)
+ elif argument in ("srcdir", "-srcdir", "--srcdir"):
+ try:
+ srcdir = next(arguments)
+ except StopIteration:
+ print(f"Missing argument after '{argument}'")
+ sys.exit(1)
+ elif argument in ("pcre2test", "-pcre2test", "--pcre2test"):
+ try:
+ pcre2test = next(arguments)
+ except StopIteration:
+ print(f"Missing argument after '{argument}'")
+ sys.exit(1)
+ elif argument in ("testdatatar", "-testdatatar", "--testdatatar"):
+ try:
+ testdatatar = next(arguments)
+ except StopIteration:
+ print(f"Missing argument after '{argument}'")
+ sys.exit(1)
+ elif argument in ("valgrind", "-valgrind", "--valgrind"):
+ valgrind = [
+ "valgrind", "--tool=memcheck", "-q", "--leak-check=yes", "--errors-for-leak-kinds=all",
+ "--smc-check=all-non-file", "--error-exitcode=70"
+ ]
+ elif argument in ("valgrind-log", "-valgrind-log", "--valgrind-log"):
+ valgrind = [
+ "valgrind", "--tool=memcheck", "--num-callers=30", "--leak-check=yes", "--errors-for-leak-kinds=all",
+ "--error-limit=no", "--smc-check=all-non-file", "--log-file=report.%p"
+ ]
+ elif argument in ("bazel-runfiles", "-bazel-runfiles", "--bazel-runfiles"):
+ bazel_runfiles = True
+ elif re.fullmatch(r"~[0-9]+", argument):
+ skip.append(int(argument[1:]))
+ elif range_match:
+ first = int(range_match.group(1))
+ last = int(range_match.group(2) or maxtest)
+ if first > maxtest or last > maxtest:
+ print(f"Invalid test range '{argument}'")
+ sys.exit(1)
+ for number in range(first, last + 1):
+ do[number] = True
+ else:
+ print(f"Unknown option or test selector '{argument}'")
+ sys.exit(1)
+
+# For some reason that's hard to understand, Bazel struggles to pass actual,
+# honest file paths within its build sandbox, so we have support for its
+# pseudo-paths, which are handles to file paths within a manifest somewhere.
+
+if bazel_runfiles:
+ from python.runfiles import runfiles
+
+ r = runfiles.Create()
+ if pcre2test:
+ pcre2test = str(r.Rlocation(pcre2test))
+ if srcdir:
+ srcdir = str(r.Rlocation(srcdir))
+ if testdatatar:
+ testdatatar = str(r.Rlocation(testdatatar))
+
+# Validate paths after argument processing
+
+if not Path(pcre2test).is_file() or not os.access(pcre2test, os.X_OK):
+ print(f"** {pcre2test} does not exist or is not executable.")
+ sys.exit(1)
+
+# Find the test data
+
+if testdatatar:
+ import tarfile
+ with tarfile.open(testdatatar) as tar:
+ tar.extractall(path=".")
+
+ testdata = Path("testdata")
+ testdata_display = "./testdata"
+ if not testdata.is_dir():
+ print(f"The specified testdata tarball '{testdatatar}' does not contain a testdata directory.")
+ sys.exit(1)
+elif srcdir:
+ testdata = Path(srcdir) / "testdata"
+ if not testdata.is_dir():
+ print(f"The specified srcdir '{srcdir}' does not contain a testdata directory")
+ sys.exit(1)
+ testdata_display = os.path.join(srcdir, "testdata")
+else:
+ if Path("testdata").is_dir():
+ testdata = Path("testdata")
+ testdata_display = "./testdata"
+ elif Path("../testdata").is_dir():
+ testdata = Path("../testdata")
+ testdata_display = "../testdata"
+ else:
+ print("Cannot find the testdata directory")
+ sys.exit(1)
+
+
+def has_capability(name):
+ with open(os.devnull, "wb") as null:
+ return invoke(pcre2test, "-C", name, stdout=null, stderr=null, use_valgrind=False) != 0
+
+
+# If it is possible to set the system stack size and -bigstack was given,
+# set up a large stack.
+
+with open(os.devnull, "wb") as null:
+ supports_setstack = invoke(pcre2test,
+ "-S",
+ "32",
+ os.devnull,
+ os.devnull,
+ stdout=null,
+ stderr=null,
+ use_valgrind=False) == 0
+if supports_setstack and bigstack:
+ globalopts.extend(("-S", "32"))
+
+# If the malloc option is given, then call pcre2test with -malloc.
+
+if malloc:
+ globalopts.append("-malloc")
+
+# All of 8-bit, 16-bit, and 32-bit character strings may be supported, but only
+# one need be.
+
+supports_8 = has_capability("pcre2-8")
+supports_16 = has_capability("pcre2-16")
+supports_32 = has_capability("pcre2-32")
+
+# \C may be disabled
+
+supports_backslash_c = has_capability("backslash-C")
+
+# Check if compiled in EBCDIC mode, and whether we have EBCDIC I/O and NL=0x25
+
+uses_ebcdic = has_capability("ebcdic")
+supports_ebcdic_io = has_capability("ebcdic-io")
+uses_ebcdic_nl25 = has_capability("ebcdic-nl25")
+if uses_ebcdic:
+ if not supports_ebcdic_io:
+ print("Running tests in EBCDIC mode, and expecting ASCII test data")
+ else:
+ print("Running tests in EBCDIC mode, and expecting EBCDIC test data")
+ print("If you are on an EBCDIC machine, you will need to convert the PCRE2")
+ print("testdata/ directory from ISO8859-1, so the data match the EBCDIC")
+ print("codepage that your C compiler is using for C character literals.")
+ print("For example:")
+ print(" iconv -f ISO8859-1 -t IBM-1047 ...")
+
+# If no bitsize arguments, select all that are available. Otherwise, select the
+# requested bit sizes.
+
+if arg8 and not supports_8:
+ print("Cannot run 8-bit library tests: 8-bit library not compiled")
+ sys.exit(1)
+if arg16 and not supports_16:
+ print("Cannot run 16-bit library tests: 16-bit library not compiled")
+ sys.exit(1)
+if arg32 and not supports_32:
+ print("Cannot run 32-bit library tests: 32-bit library not compiled")
+ sys.exit(1)
+
+width_selected = arg8 or arg16 or arg32
+test8 = "-8" if supports_8 and (not width_selected or arg8) else False
+test16 = "-16" if supports_16 and (not width_selected or arg16) else False
+test32 = "-32" if supports_32 and (not width_selected or arg32) else False
+
+# UTF support is implied by Unicode support, and it always applies to all bit
+# sizes if both are supported; we can't have UTF-8 support without UTF-16 or
+# UTF-32 support.
+
+supports_utf = has_capability("unicode")
+
+# When JIT is used with valgrind, we need to set up valgrind suppressions as
+# otherwise there are a lot of false positive valgrind reports when the
+# the hardware supports SSE2.
+
+supports_jit = has_capability("jit")
+
+vjs = []
+jitopts = []
+if supports_jit and not nojit:
+ jitopts = [["-jit"]]
+if jitopts and valgrind:
+ vjs = [f"--suppressions={testdata / 'valgrind-jit.supp'}"]
+
+# If no specific tests were requested, select all the numbered tests. Those
+# that are not relevant will be automatically skipped.
+
+if not any(do) and not doheap:
+ do = [True] * 30
+
+# Handle any explicit skips at this stage, so that an argument list may consist
+# only of explicit skips.
+
+for number in skip:
+ if number <= maxtest:
+ do[number] = False
+
+# Show which release and which test data
+
+print()
+print(f"PCRE2 C library tests using test data from {testdata_display}", flush=True)
+invoke(pcre2test, os.devnull, use_valgrind=False)
+print()
+
+# ------ Normal Tests ------
+
+for bmode in (test8, test16, test32):
+ if not bmode:
+ continue
+ bits = bmode[1:]
+ if bmode == "-16" and test8 or bmode == "-32" and (test8 or test16):
+ print()
+
+ print(f"---- Testing {bits}-bit library ----")
+ print()
+
+ # Set up directories for test output.
+ for opts in [[], *jitopts, ["-dfa"]]:
+ Path(f"testoutput{bits}{''.join(opts)}").mkdir(exist_ok=True)
+
+ # Test 0 is a special test. Its output is not checked, because it will
+ # be different on different hardware and with different configurations.
+ # Running this test just exercises the code.
+
+ if do[0]:
+ print(title0)
+ Path("testSinput").write_bytes(b"/abc/jit,memory,framesize\n abc\n")
+ Path("testSoutput").write_bytes(b"\n")
+ special_tests_passed = True
+
+ def checkspecial(arguments, expect=0, stderr=subprocess.STDOUT, use_vjs=False):
+ global failed
+ with open("testSoutput", "ab") as stream:
+ returncode = invoke(pcre2test, *arguments, stdout=stream, stderr=stderr, use_vjs=use_vjs)
+ if returncode != expect:
+ print(f"** pcre2test {' '.join(arguments)} failed - check testSoutput")
+ failed = True
+ return False
+ return True
+
+ special_tests_passed &= checkspecial((bmode, "-C"))
+ special_tests_passed &= checkspecial(("--help", ))
+ special_tests_passed &= checkspecial((bmode, "testSinput"), use_vjs=True)
+ special_tests_passed &= checkspecial((bmode, str(testdata / "testinputheap")))
+ if supports_setstack:
+ special_tests_passed &= checkspecial((bmode, "-S", "1", "-t", "10", "testSinput"), use_vjs=True)
+ special_tests_passed &= checkspecial((bmode, "reallydoesnotexist"), expect=1)
+ special_tests_passed &= checkspecial((bmode, "testSinput", "reallydoesnotexist/outfile"), expect=1)
+ special_tests_passed &= checkspecial((bmode, "-pattern", "debug", "testSinput"), use_vjs=True)
+ special_tests_passed &= checkspecial((bmode, "-pattern", "INVALID", "testSinput"),
+ expect=1,
+ stderr=subprocess.DEVNULL)
+ special_tests_passed &= checkspecial((bmode, "-subject", "notempty", "testSinput"), use_vjs=True)
+ special_tests_passed &= checkspecial((bmode, "-subject", "INVALID", "testSinput"),
+ expect=1,
+ stderr=subprocess.DEVNULL)
+ special_tests_passed &= checkspecial(("-LM", ))
+ special_tests_passed &= checkspecial(("-LP", ))
+ special_tests_passed &= checkspecial(("-LS", ))
+ special_tests_passed &= checkspecial((bmode, "-unittest"), use_vjs=True)
+ if special_tests_passed:
+ print(" OK")
+
+ # Primary non-UTF test, compatible with JIT and all versions of Perl >= 5.8
+
+ if do[1]:
+ print(title1)
+ for opts in [[], *jitopts]:
+ output = Path(f"testoutput{bits}{''.join(opts)}") / "testoutput1"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput1", output, use_vjs=opts == ["-jit"]), "1",
+ opts, bits)
+
+ # PCRE2 tests that are not Perl-compatible: API, errors, internals. We copy
+ # the testbtables file to the current directory for use by this test.
+
+ if do[2]:
+ print(f"{title2} (excluding UTF-{bits})")
+ shutil.copyfile(testdata / "testbtables", "testbtables")
+ for opts in [[], *jitopts]:
+ output = Path(f"testoutput{bits}{''.join(opts)}") / "testoutput2"
+ returncode = invoke(pcre2test,
+ *globalopts,
+ bmode,
+ *opts,
+ testdata / "testinput2",
+ output,
+ use_vjs=opts == ["-jit"])
+ if returncode == 0:
+ with open(output, "ab") as stream:
+ returncode = invoke(pcre2test,
+ *globalopts,
+ bmode,
+ *opts,
+ "-error",
+ "-80,-62,-2,-1,0,100,101,191,300",
+ stdout=stream,
+ use_vjs=opts == ["-jit"])
+ checkresult(returncode, "2", opts, bits)
+
+ # Locale-specific tests. Unfortunately, different versions of the French
+ # locale give different outputs for some items. This test passes if the
+ # output matches any one of the alternative output files.
+
+ if do[3]:
+ selected_locale = ""
+ locales = ("french", "fr_FR", "fr", "fr_CA")
+ if shutil.which("locale") is None:
+ available_locales = []
+ else:
+ available_locales = subprocess.run(
+ ["locale", "-a"],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.DEVNULL,
+ check=False,
+ ).stdout.decode("latin-1").splitlines()
+ for loc in locales:
+ if loc not in available_locales:
+ continue
+ probe = subprocess.run(
+ [*sim, *valgrind, pcre2test, "-q", bmode],
+ input=f"/a/locale={loc}\n".encode("latin-1"),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.DEVNULL,
+ check=False,
+ )
+ if b"Failed to set locale" in probe.stdout:
+ continue
+ selected_locale = loc
+ for name_in, name_out in (("testinput3", "test3input"), ("testoutput3", "test3output"), ("testoutput3A", "test3outputA"), ("testoutput3B", "test3outputB"), ("testoutput3C", "test3outputC"), ("testoutput3D", "test3outputD"), ("testoutput3E", "test3outputE"), ("testoutput3F", "test3outputF")):
+ Path(name_out).write_bytes((testdata / name_in).read_bytes().replace(b"fr_FR", loc.encode("latin-1")))
+ break
+ if selected_locale:
+ print(f"{title3} (using '{selected_locale}' locale)")
+ for opts in [[], *jitopts]:
+ output = Path(f"testoutput{bits}") / "testoutput3"
+ returncode = invoke(pcre2test, *globalopts, bmode, *opts, "test3input", output, use_vjs=opts == ["-jit"])
+ with_message = " with JIT" if opts == ["-jit"] else ""
+ expected_outputs = (
+ Path("test3output"),
+ Path("test3outputA"),
+ Path("test3outputB"),
+ Path("test3outputC"),
+ Path("test3outputD"),
+ Path("test3outputE"),
+ Path("test3outputF"),
+ )
+ if returncode != 0:
+ print(f"** pcre2test failed - check {output}")
+ failed = True
+ elif any(compare(expected, output) for expected in expected_outputs):
+ print(f" OK{with_message}")
+ else:
+ print()
+ print(f"** Locale test did not run successfully{with_message}. The output did not match")
+ print(" testoutput3, testoutput3A, testoutput3B, testoutput3C, testoutput3D, testoutput3E, or testoutput3F.")
+ print(" This may mean that there is a problem with the locale settings rather")
+ print(" than a bug in PCRE2.")
+ failed = True
+ else:
+ print("Cannot test locale-specific features - none of the French locales")
+ print(f"({' '.join(locales)}) could be set.")
+ print(" ")
+
+ # Tests for UTF and Unicode property support
+
+ if do[4]:
+ print(f"{title4A}-{bits}{title4B}")
+ if not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ for opts in [[], *jitopts]:
+ output = Path(f"testoutput{bits}{''.join(opts)}") / "testoutput4"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput4", output, use_vjs=opts == ["-jit"]),
+ "4", opts, bits)
+
+ if do[5]:
+ print(f"{title5A}-{bits}{title5B}")
+ if not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ for opts in [[], *jitopts]:
+ output = Path(f"testoutput{bits}{''.join(opts)}") / "testoutput5"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput5", output, use_vjs=opts == ["-jit"]),
+ "5", opts, bits)
+
+ # Tests for DFA matching support
+
+ if do[6]:
+ print(title6)
+ output = Path(f"testoutput{bits}") / "testoutput6"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput6", output), "6", [], bits)
+
+ if do[7]:
+ print(f"{title7A}-{bits}{title7B}")
+ if not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ output = Path(f"testoutput{bits}") / "testoutput7"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput7", output), "7", [], bits)
+
+ # Test of internal offsets and code sizes. This test is run only when there
+ # is UTF/UCP support. The actual tests are mostly the same as in some of the
+ # above, but in this test we inspect some offsets and sizes. This is a
+ # doublecheck for the maintainer, just in case something changes unexpectedly.
+
+ if do[8]:
+ print(title8)
+ with open(os.devnull, "wb") as null:
+ bits_link_size = invoke(pcre2test, f"-{bits}", "-C", "linksize", stdout=null, stderr=null)
+ if not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ suffix = f"8-{bits}-{bits_link_size}"
+ output = Path(f"testoutput{bits}") / f"testoutput{suffix}"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput8", output), suffix, [], bits)
+
+ # Tests for 8-bit-specific features
+
+ if do[9]:
+ print(title9)
+ if bits in ("16", "32"):
+ print(" Skipped when running 16/32-bit tests")
+ else:
+ for opts in [[], *jitopts]:
+ output = Path(f"testoutput{bits}{''.join(opts)}") / "testoutput9"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput9", output, use_vjs=opts == ["-jit"]),
+ "9", opts, bits)
+
+ # Tests for UTF-8 and UCP 8-bit-specific features
+
+ if do[10]:
+ print(title10)
+ if bits in ("16", "32"):
+ print(" Skipped when running 16/32-bit tests")
+ elif not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ for opts in [[], *jitopts]:
+ output = Path(f"testoutput{bits}{''.join(opts)}") / "testoutput10"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput10", output, use_vjs=opts == ["-jit"]),
+ "10", opts, bits)
+
+ # Tests for 16-bit and 32-bit features. Output is different for the two widths.
+
+ if do[11]:
+ print(title11)
+ if bits == "8":
+ print(" Skipped when running 8-bit tests")
+ else:
+ for opts in [[], *jitopts]:
+ suffix = f"11-{bits}"
+ output = Path(f"testoutput{bits}{''.join(opts)}") / f"testoutput{suffix}"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput11", output, use_vjs=opts == ["-jit"]),
+ suffix, opts, bits)
+
+ # Tests for 16-bit and 32-bit features with UTF-16/32 and UCP support. Output
+ # is different for the two widths.
+
+ if do[12]:
+ print(title12)
+ if bits == "8":
+ print(" Skipped when running 8-bit tests")
+ elif not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ for opts in [[], *jitopts]:
+ suffix = f"12-{bits}"
+ output = Path(f"testoutput{bits}{''.join(opts)}") / f"testoutput{suffix}"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput12", output, use_vjs=opts == ["-jit"]),
+ suffix, opts, bits)
+
+ # Tests for 16/32-bit-specific features in DFA non-UTF modes
+
+ if do[13]:
+ print(title13)
+ if bits == "8":
+ print(" Skipped when running 8-bit tests")
+ else:
+ output = Path(f"testoutput{bits}") / "testoutput13"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput13", output), "13", [], bits)
+
+ # Tests for DFA UTF and UCP features. Output is different for the different widths.
+
+ if do[14]:
+ print(title14)
+ if not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ suffix = f"14-{bits}"
+ output = Path(f"testoutput{bits}") / f"testoutput{suffix}"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput14", output), suffix, [], bits)
+
+ # Test non-JIT match and recursion limits
+
+ if do[15]:
+ print(title15)
+ output = Path(f"testoutput{bits}") / "testoutput15"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput15", output), "15", [], bits)
+
+ # Test JIT-specific features when JIT is not available
+
+ if do[16]:
+ print(title16)
+ if supports_jit:
+ print(" Skipped because JIT is available")
+ else:
+ output = Path(f"testoutput{bits}") / "testoutput16"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput16", output), "16", [], bits)
+
+ # Test JIT-specific features when JIT is available
+
+ if do[17]:
+ print(title17)
+ if not supports_jit or nojit:
+ print(" Skipped because JIT is not available or nojit was specified")
+ else:
+ output = Path(f"testoutput{bits}") / "testoutput17"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput17", output, use_vjs=True), "17", [], bits)
+
+ # Tests for the POSIX interface without UTF/UCP (8-bit only)
+
+ if do[18]:
+ print(title18)
+ if bits in ("16", "32"):
+ print(" Skipped when running 16/32-bit tests")
+ else:
+ output = Path(f"testoutput{bits}") / "testoutput18"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput18", output), "18", [], bits)
+
+ # Tests for the POSIX interface with UTF/UCP (8-bit only)
+
+ if do[19]:
+ print(title19)
+ if bits in ("16", "32"):
+ print(" Skipped when running 16/32-bit tests")
+ elif not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ output = Path(f"testoutput{bits}") / "testoutput19"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput19", output), "19", [], bits)
+
+ # Serialization tests
+
+ if do[20]:
+ print(title20)
+ output = Path(f"testoutput{bits}") / "testoutput20"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput20", output), "20", [], bits)
+
+ # \C tests without UTF - DFA matching is supported
+
+ if do[21]:
+ print(title21)
+ if not supports_backslash_c:
+ print(r" Skipped because \C is disabled")
+ else:
+ for opts in [[], *jitopts, ["-dfa"]]:
+ output = Path(f"testoutput{bits}{''.join(opts)}") / "testoutput21"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput21", output, use_vjs=opts == ["-jit"]),
+ "21", opts, bits)
+
+ # \C tests with UTF - DFA matching is not supported for \C in UTF mode
+
+ if do[22]:
+ print(title22)
+ if not supports_backslash_c:
+ print(r" Skipped because \C is disabled")
+ elif not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ for opts in [[], *jitopts]:
+ suffix = f"22-{bits}"
+ output = Path(f"testoutput{bits}{''.join(opts)}") / f"testoutput{suffix}"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput22", output, use_vjs=opts == ["-jit"]),
+ suffix, opts, bits)
+
+ # Test when \C is disabled
+
+ if do[23]:
+ print(title23)
+ if supports_backslash_c:
+ print(r" Skipped because \C is not disabled")
+ else:
+ output = Path(f"testoutput{bits}") / "testoutput23"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput23", output), "23", [], bits)
+
+ # Non-UTF pattern conversion tests
+
+ if do[24]:
+ print(title24)
+ output = Path(f"testoutput{bits}") / "testoutput24"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput24", output), "24", [], bits)
+
+ # UTF pattern conversion tests
+
+ if do[25]:
+ print(title25)
+ if not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ output = Path(f"testoutput{bits}") / "testoutput25"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinput25", output), "25", [], bits)
+
+ # Unicode property tests
+
+ if do[26]:
+ print(title26)
+ if not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ for opts in [[], *jitopts]:
+ output = Path(f"testoutput{bits}{''.join(opts)}") / "testoutput26"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput26", output, use_vjs=opts == ["-jit"]),
+ "26", opts, bits)
+
+ # Auto-generated Unicode property tests
+
+ if do[27]:
+ print(title27)
+ if not supports_utf:
+ print(f" Skipped because UTF-{bits} support is not available")
+ else:
+ for opts in [[], *jitopts]:
+ output = Path(f"testoutput{bits}{''.join(opts)}") / "testoutput27"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput27", output, use_vjs=opts == ["-jit"]),
+ "27", opts, bits)
+
+ # EBCDIC tests
+
+ if do[28]:
+ print(title28)
+ if not uses_ebcdic:
+ print(" Skipped when not targetting EBCDIC")
+ else:
+ for opts in [[], *jitopts, ["-dfa"]]:
+ output = Path(f"testoutput{bits}{''.join(opts)}") / "testoutput28"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput28", output, use_vjs=opts == ["-jit"]),
+ "28", opts, bits)
+
+ # EBCDIC tests (for NL=0x25)
+
+ if do[29]:
+ print(title29)
+ if not uses_ebcdic:
+ print(" Skipped when not targetting EBCDIC")
+ elif not uses_ebcdic_nl25:
+ print(" Skipped because EBCDIC newline is not 0x25")
+ else:
+ for opts in [[], *jitopts, ["-dfa"]]:
+ output = Path(f"testoutput{bits}{''.join(opts)}") / "testoutput29"
+ checkresult(
+ invoke(pcre2test, *globalopts, bmode, *opts, testdata / "testinput29", output, use_vjs=opts == ["-jit"]),
+ "29", opts, bits)
+
+ # Manually selected heap tests - output may vary in different environments,
+ # which is why they are not automatically run.
+
+ if doheap:
+ print(titleheap)
+ suffix = f"heap-{bits}"
+ output = Path(f"testoutput{bits}") / f"testoutput{suffix}"
+ checkresult(invoke(pcre2test, *globalopts, bmode, testdata / "testinputheap", output), suffix, [], bits)
+
+if not failed:
+ print()
+ print("All tests passed.")
+ for name in ("testbtables", "testSinput", "testSoutput", "test3input", "test3output", "test3outputA", "test3outputB",
+ "test3outputC", "test3outputD", "test3outputE", "test3outputF", "testsaved1", "testsaved2", "teststdout", "teststderr"):
+ try:
+ Path(name).unlink()
+ except FileNotFoundError:
+ pass
+ for cleanup_bits in ("8", "16", "32"):
+ shutil.rmtree(f"testoutput{cleanup_bits}", ignore_errors=True)
+ shutil.rmtree(f"testoutput{cleanup_bits}-jit", ignore_errors=True)
+ shutil.rmtree(f"testoutput{cleanup_bits}-dfa", ignore_errors=True)
+else:
+ print()
+ print("** Tests failed. See output above for details.")
+
+sys.exit(1 if failed else 0)
diff --git a/cmake/PCRE2CheckVscript.cmake b/cmake/PCRE2CheckVscript.cmake
index eeda4c004..3ed363f14 100644
--- a/cmake/PCRE2CheckVscript.cmake
+++ b/cmake/PCRE2CheckVscript.cmake
@@ -23,18 +23,24 @@ function(_pcre2_try_vscript_shared_lib link_flag map_file result_var)
file(MAKE_DIRECTORY "${try_dir}")
# Write a minimal C source with exported symbols
- file(WRITE "${try_dir}/test_vscript.c" "
+ file(
+ WRITE "${try_dir}/test_vscript.c"
+ "
int hidethis(void) { return 0; }
int exposethis(void) { return hidethis(); }
-")
+"
+ )
# Write a CMakeLists.txt that builds a shared library with the version script
- file(WRITE "${try_dir}/CMakeLists.txt" "
+ file(
+ WRITE "${try_dir}/CMakeLists.txt"
+ "
cmake_minimum_required(VERSION 3.15)
project(test_vscript C)
add_library(test_vscript SHARED test_vscript.c)
target_link_options(test_vscript PRIVATE \"-Wl,${link_flag},${map_file}\")
-")
+"
+ )
try_compile(
compile_result
@@ -98,7 +104,11 @@ function(pcre2_check_vscript have_var flag_var no_star_var)
if(HAVE_VSCRIPT)
# Perform the same logic as ax_check_vscript.m4, to test whether the linker
# silently ignores (and overwrites) linker scripts it doesn't understand.
- _pcre2_try_vscript_shared_lib("${VSCRIPT_FLAG}" "${PROJECT_BINARY_DIR}/test-map-file-broken.sym" HAVE_VSCRIPT_BROKEN)
+ _pcre2_try_vscript_shared_lib(
+ "${VSCRIPT_FLAG}"
+ "${PROJECT_BINARY_DIR}/test-map-file-broken.sym"
+ HAVE_VSCRIPT_BROKEN
+ )
if(HAVE_VSCRIPT_BROKEN)
set(HAVE_VSCRIPT FALSE)
@@ -122,7 +132,11 @@ function(pcre2_check_vscript have_var flag_var no_star_var)
# Test that the linker works without requiring a wildcard to hide platform-specific
# symbols (_init, _fini, etc.).
- _pcre2_try_vscript_shared_lib("${VSCRIPT_FLAG}" "${PROJECT_BINARY_DIR}/test-map-file-no-star.sym" HAVE_VSCRIPT_NO_STAR)
+ _pcre2_try_vscript_shared_lib(
+ "${VSCRIPT_FLAG}"
+ "${PROJECT_BINARY_DIR}/test-map-file-no-star.sym"
+ HAVE_VSCRIPT_NO_STAR
+ )
if(first_run)
message(STATUS "Detecting if version scripts work without wildcard - ${HAVE_VSCRIPT_NO_STAR}")
diff --git a/doc/html/NON-AUTOTOOLS-BUILD.txt b/doc/html/NON-AUTOTOOLS-BUILD.txt
index 45c8bad39..43a10a152 100644
--- a/doc/html/NON-AUTOTOOLS-BUILD.txt
+++ b/doc/html/NON-AUTOTOOLS-BUILD.txt
@@ -11,7 +11,7 @@ This document contains the following sections:
Comments about Win32 builds
Building PCRE2 on Windows with CMake
Building PCRE2 on Windows with Visual Studio
- Testing with RunTest.bat
+ Testing with Python
Building PCRE2 on z/OS and z/VM
Building PCRE2 under VMS
@@ -183,18 +183,18 @@ example.
Some tests are relevant only when certain build-time options are selected.
For example, test 4 is for Unicode support, and will not run if you have
built PCRE2 without it. See the comments at the start of each testinput
- file. If you have a suitable Unix-like shell, the RunTest script will run
- the appropriate tests for you. The command "RunTest list" will output a
- list of all the tests.
+ file. The Python script RunTest.py will run the appropriate tests on
+ Unix-like systems and Windows. A Unix shell version is also available
+ as RunTest. The command "python3 RunTest.py list" (or "RunTest list" for
+ the shell version) will output a list of all the tests.
Note that the supplied files are in Unix format, with just LF characters
- as line terminators. You may need to edit them to change this if your
- system uses a different convention.
+ as line terminators.
(10) If you have built PCRE2 with SUPPORT_JIT, the JIT features can be tested
by running pcre2test with the -jit option. This is done automatically by
- the RunTest script. You might also like to build and run the freestanding
- JIT test program, src/pcre2_jit_test.c.
+ RunTest.py and RunTest. You might also like to build and run the
+ freestanding JIT test program, src/pcre2_jit_test.c.
(11) The pcre2test program tests the POSIX wrapper library, but there is also a
freestanding test program in src/pcre2posix_test.c. It must be linked with
@@ -371,52 +371,48 @@ be deleted.
Regardless of build system used, `ctest` will run the tests.
-Building PCRE2 on Windows with Visual Studio
---------------------------------------------
+Testing with Python
+-------------------
-The code currently cannot be compiled without an inttypes.h header, which is
-available only with Visual Studio 2013 or newer. However, this portable and
-permissively-licensed implementation of the stdint.h header could be used as an
-alternative:
+The autotools build uses `make check` to run the test suites using the `RunTest`
+and `RunGrepTest` shell (bash) scripts. The test suite is also available for
+non-Unix platforms using the equivalent `RunTest.py` and `RunGrepTest.py` Python
+scripts instead.
- http://www.azillionmonkeys.com/qed/pstdint.h
+These Python scripts can be used with any build system, and should work on
+supported PCRE2 platforms.
-Just rename it and drop it into the top level of the build tree.
+The autotools build only uses the shell scripts.
+The CMake build tests for a Python 3 installation, and defaults to registering
+the Python scripts with CTest. If Python 3 is not found, CMake registers the
+shell scripts on Unix, or fails otherwise.
-Testing with RunTest.bat
-------------------------
-
-If configured with CMake, building the test project ("make test" or building
-ALL_TESTS in Visual Studio) creates (and runs) pcre2_test.bat (and depending
-on your configuration options, possibly other test programs) in the build
-directory. The pcre2_test.bat script runs RunTest.bat with correct source and
-exe paths.
-
-For manual testing with RunTest.bat, provided the build dir is a subdirectory
-of the source directory: Open command shell window. Chdir to the location
-of your pcre2test.exe and pcre2grep.exe programs. Call RunTest.bat with
-"..\RunTest.Bat" or "..\..\RunTest.bat" as appropriate.
-
-To run only a particular test with RunTest.Bat provide a test number argument.
-
-Otherwise:
-
-1. Copy RunTest.bat into the directory where pcre2test.exe and pcre2grep.exe
- have been created.
+On Windows, the requirement for a Python installation to run the test suite can
+be avoided by passing `-DPCRE2_BUILD_TESTS=OFF`, although releasing untested
+builds is not recommended.
-2. Edit RunTest.bat to identify the full or relative location of
- the pcre2 source (wherein which the testdata folder resides), e.g.:
+After building, run CTest in the usual way, specifying the configuration for a
+multi-configuration generator. For example:
- set srcdir=C:\pcre2\pcre2-10.00
+ cmake --build build --config Release
+ ctest --test-dir build -C Release --output-on-failure
-3. In a Windows command environment, chdir to the location of your bat and
- exe programs.
+The scripts can also be run directly from the build directory. If the source
+and executable paths cannot be inferred from that directory, pass them
+explicitly. For example:
-4. Run RunTest.bat. Test outputs will automatically be compared to expected
- results, and discrepancies will be identified in the console output.
+ python3 ../RunTest.py --srcdir .. --pcre2test ./Release/pcre2test.exe
+ python3 ../RunGrepTest.py --srcdir .. ^
+ --pcre2test ./Release/pcre2test.exe ^
+ --pcre2grep ./Release/pcre2grep.exe
-To independently test the just-in-time compiler, run pcre2_jit_test.exe.
+The runner scripts (shell and Python) support out-of-tree builds by accepting
+commandline arguments specifying the location of the srcdir (the directory
+containing the `testdata/` directory); of `pcre2test[.exe]`; and for
+`RunGrepTest` and `RunGrepTest.py`, `pcre2grep[.exe]`. Alternatively,
+environment variables can be used to pass the paths; and if none are provided
+the working directory is used.
Building PCRE2 on z/OS and z/VM
diff --git a/doc/html/README.txt b/doc/html/README.txt
index 3adf495a9..f07ada8fc 100644
--- a/doc/html/README.txt
+++ b/doc/html/README.txt
@@ -632,18 +632,24 @@ pages.
Testing PCRE2
-------------
-To test the basic PCRE2 library on a Unix-like system, run the RunTest script.
-There is another script called RunGrepTest that tests the pcre2grep command.
+To test the basic PCRE2 library on a Unix-like system, run the RunTest shell
+script. A portable Python version is available as RunTest.py. There are
+corresponding RunGrepTest and RunGrepTest.py scripts that test the pcre2grep
+command. Run the scripts from the build directory; for example:
+
+ python3 ../RunTest.py
+ python3 ../RunGrepTest.py
+
When the 8-bit library is built, a test program for the POSIX wrapper, called
pcre2posix_test, is compiled, and when JIT support is enabled, a test program
called pcre2_jit_test is built. The scripts and the program tests are all run
-when you obey "make check". For other environments, see the instructions in
+when you run "make check". For other environments, see the instructions in
NON-AUTOTOOLS-BUILD.
-The RunTest script runs the pcre2test test program (which is documented in its
-own man page) on each of the relevant testinput files in the testdata
-directory, and compares the output with the contents of the corresponding
-testoutput files. RunTest places its output in directories
+The RunTest (and RunTest.py) scripts run the pcre2test test program (which is
+documented in its own man page) on each of the relevant testinput files in the
+testdata directory, and compare the output with the contents of the
+corresponding testoutput files. The output is placed in directories
testoutput{8,16,32}{,-jit,-dfa}. Other files whose names begin with "test" are
used as working files in some tests.
@@ -930,9 +936,9 @@ The distribution should contain the files listed below.
NON-AUTOTOOLS-BUILD notes on building PCRE2 without using autotools
README this file
RunTest a Unix shell script for running tests
+ RunTest.py a portable Python script for running tests
RunGrepTest a Unix shell script for pcre2grep tests
- RunTest.bat a Windows batch file for running tests
- RunGrepTest.bat a Windows batch file for pcre2grep tests
+ RunGrepTest.py a portable Python script for pcre2grep tests
aclocal.m4 m4 macros (generated by "aclocal")
m4/* m4 macros (used by autoconf)
configure a configuring shell script (built by autoconf)
diff --git a/doc/html/pcre2grep.html b/doc/html/pcre2grep.html
index deb667ed3..2177a9819 100644
--- a/doc/html/pcre2grep.html
+++ b/doc/html/pcre2grep.html
@@ -532,6 +532,11 @@
short form for this option.
+--lf
+Use LF as the line ending for standard output. This has no effect except on
+Windows, where CRLF is the default. There is no short form for this option.
+
+
--line-buffered
When this option is given, non-compressed input is read and processed line by
line, and the output is flushed after each write. By default, input is read in
@@ -949,7 +954,7 @@
(GNU terminology) is also available as --xxx-regex (PCRE2 terminology).
However, the --case-restrict, --depth-limit, -E,
--file-list, --file-offsets, --heap-limit,
---include-dir, --line-offsets, --locale, --match-limit,
+--include-dir, --lf, --line-offsets, --locale, --match-limit,
-M, --multiline, -N, --newline, --no-ucp,
--om-separator, --output, -P, -u, --utf,
-U, and --utf-allow-invalid options are specific to
diff --git a/doc/pcre2grep.1 b/doc/pcre2grep.1
index 71abc0fad..58fe66eea 100644
--- a/doc/pcre2grep.1
+++ b/doc/pcre2grep.1
@@ -461,6 +461,10 @@ This option supplies a name to be used for the standard input when file names
are being output. If not supplied, "(standard input)" is used. There is no
short form for this option.
.TP
+\fB--lf\fP
+Use LF as the line ending for standard output. This has no effect except on
+Windows, where CRLF is the default. There is no short form for this option.
+.TP
\fB--line-buffered\fP
When this option is given, non-compressed input is read and processed line by
line, and the output is flushed after each write. By default, input is read in
@@ -836,7 +840,7 @@ in the GNU \fBgrep\fP program. Any long option of the form \fB--xxx-regexp\fP
(GNU terminology) is also available as \fB--xxx-regex\fP (PCRE2 terminology).
However, the \fB--case-restrict\fP, \fB--depth-limit\fP, \fB-E\fP,
\fB--file-list\fP, \fB--file-offsets\fP, \fB--heap-limit\fP,
-\fB--include-dir\fP, \fB--line-offsets\fP, \fB--locale\fP, \fB--match-limit\fP,
+\fB--include-dir\fP, \fB--lf\fP, \fB--line-offsets\fP, \fB--locale\fP, \fB--match-limit\fP,
\fB-M\fP, \fB--multiline\fP, \fB-N\fP, \fB--newline\fP, \fB--no-ucp\fP,
\fB--om-separator\fP, \fB--output\fP, \fB-P\fP, \fB-u\fP, \fB--utf\fP,
\fB-U\fP, and \fB--utf-allow-invalid\fP options are specific to
diff --git a/doc/pcre2grep.txt b/doc/pcre2grep.txt
index 6ad0cf181..d2d5627c8 100644
--- a/doc/pcre2grep.txt
+++ b/doc/pcre2grep.txt
@@ -507,131 +507,135 @@ OPTIONS
when file names are being output. If not supplied, "(standard
input)" is used. There is no short form for this option.
+ --lf Use LF as the line ending for standard output. This has no
+ effect except on Windows, where CRLF is the default. There is
+ no short form for this option.
+
--line-buffered
- When this option is given, non-compressed input is read and
- processed line by line, and the output is flushed after each
- write. By default, input is read in large chunks, unless
- pcre2grep can determine that it is reading from a terminal,
+ When this option is given, non-compressed input is read and
+ processed line by line, and the output is flushed after each
+ write. By default, input is read in large chunks, unless
+ pcre2grep can determine that it is reading from a terminal,
which is currently possible only in Unix-like environments or
Windows. Output to terminal is normally automatically flushed
- by the operating system. This option can be useful when the
- input or output is attached to a pipe and you do not want
- pcre2grep to buffer up large amounts of data. However, its
- use will affect performance, and the -M (multiline) option
- ceases to work. When input is from a compressed .gz or .bz2
+ by the operating system. This option can be useful when the
+ input or output is attached to a pipe and you do not want
+ pcre2grep to buffer up large amounts of data. However, its
+ use will affect performance, and the -M (multiline) option
+ ceases to work. When input is from a compressed .gz or .bz2
file, --line-buffered is ignored.
--line-offsets
- Instead of showing lines or parts of lines that match, show
+ Instead of showing lines or parts of lines that match, show
each match as a line number, the offset from the start of the
- line, and a length. The line number is terminated by a colon
- (as usual; see the -n option), and the offset and length are
- separated by a comma. In this mode, --colour has no effect,
- and no context is shown. That is, the -A, -B, and -C options
- are ignored. If there is more than one match in a line, each
- of them is shown separately. This option is mutually exclu-
+ line, and a length. The line number is terminated by a colon
+ (as usual; see the -n option), and the offset and length are
+ separated by a comma. In this mode, --colour has no effect,
+ and no context is shown. That is, the -A, -B, and -C options
+ are ignored. If there is more than one match in a line, each
+ of them is shown separately. This option is mutually exclu-
sive with --output, --file-offsets, and --only-matching.
--locale=locale-name
- This option specifies a locale to be used for pattern match-
- ing. It overrides the value in the LC_ALL or LC_CTYPE envi-
- ronment variables. If no locale is specified, the PCRE2 li-
+ This option specifies a locale to be used for pattern match-
+ ing. It overrides the value in the LC_ALL or LC_CTYPE envi-
+ ronment variables. If no locale is specified, the PCRE2 li-
brary's default (usually the "C" locale) is used. There is no
short form for this option.
-M, --multiline
- Allow patterns to match more than one line. When this option
- is set, the PCRE2 library is called in "multiline" mode, and
- a match is allowed to continue past the end of the initial
+ Allow patterns to match more than one line. When this option
+ is set, the PCRE2 library is called in "multiline" mode, and
+ a match is allowed to continue past the end of the initial
line and onto one or more subsequent lines.
- Patterns used with -M may usefully contain literal newline
- characters and internal occurrences of ^ and $ characters,
- because in multiline mode these can match at internal new-
- lines. Because pcre2grep is scanning multiple lines, the \Z
- and \z assertions match only at the end of the last line in
+ Patterns used with -M may usefully contain literal newline
+ characters and internal occurrences of ^ and $ characters,
+ because in multiline mode these can match at internal new-
+ lines. Because pcre2grep is scanning multiple lines, the \Z
+ and \z assertions match only at the end of the last line in
the file. The \A assertion matches at the start of the first
- line of a match. This can be any line in the file; it is not
+ line of a match. This can be any line in the file; it is not
anchored to the first line.
- The output for a successful match may consist of more than
- one line. The first line is the line in which the match
- started, and the last line is the line in which the match
- ended. If the matched string ends with a newline sequence,
- the output ends at the end of that line. If -v is set, none
- of the lines in a multi-line match are output. Once a match
- has been handled, scanning restarts at the beginning of the
+ The output for a successful match may consist of more than
+ one line. The first line is the line in which the match
+ started, and the last line is the line in which the match
+ ended. If the matched string ends with a newline sequence,
+ the output ends at the end of that line. If -v is set, none
+ of the lines in a multi-line match are output. Once a match
+ has been handled, scanning restarts at the beginning of the
line after the one in which the match ended.
- The newline sequence that separates multiple lines must be
- matched as part of the pattern. For example, to find the
- phrase "regular expression" in a file where "regular" might
- be at the end of a line and "expression" at the start of the
+ The newline sequence that separates multiple lines must be
+ matched as part of the pattern. For example, to find the
+ phrase "regular expression" in a file where "regular" might
+ be at the end of a line and "expression" at the start of the
next line, you could use this command:
pcre2grep -M 'regular\s+expression'
The \s escape sequence matches any white space character, in-
- cluding newlines, and is followed by + so as to match trail-
- ing white space on the first line as well as possibly han-
+ cluding newlines, and is followed by + so as to match trail-
+ ing white space on the first line as well as possibly han-
dling a two-character newline sequence.
- There is a limit to the number of lines that can be matched,
- imposed by the way that pcre2grep buffers the input file as
- it scans it. With a sufficiently large processing buffer,
+ There is a limit to the number of lines that can be matched,
+ imposed by the way that pcre2grep buffers the input file as
+ it scans it. With a sufficiently large processing buffer,
this should not be a problem.
- The -M option does not work when input is read line by line
+ The -M option does not work when input is read line by line
(see --line-buffered.)
-m number, --max-count=number
- Stop processing after finding number matching lines, or non-
- matching lines if -v is also set. Any trailing context lines
- are output after the final match. In multiline mode, each
- multiline match counts as just one line for this purpose. If
- this limit is reached when reading the standard input from a
+ Stop processing after finding number matching lines, or non-
+ matching lines if -v is also set. Any trailing context lines
+ are output after the final match. In multiline mode, each
+ multiline match counts as just one line for this purpose. If
+ this limit is reached when reading the standard input from a
regular file, the file is left positioned just after the last
- matching line. If -c is also set, the count that is output
- is never greater than number. This option has no effect if
+ matching line. If -c is also set, the count that is output
+ is never greater than number. This option has no effect if
used with -L, -l, or -q, or when just checking for a match in
a binary file.
--match-limit=number
- Processing some regular expression patterns may take a very
+ Processing some regular expression patterns may take a very
long time to search for all possible matching strings. Others
- may require a very large amount of memory. There are three
+ may require a very large amount of memory. There are three
options that set resource limits for matching.
The --match-limit option provides a means of limiting comput-
- ing resource usage when processing patterns that are not go-
+ ing resource usage when processing patterns that are not go-
ing to match, but which have a very large number of possibil-
ities in their search trees. The classic example is a pattern
- that uses nested unlimited repeats. Internally, PCRE2 has a
- counter that is incremented each time around its main pro-
- cessing loop. If the value set by --match-limit is reached,
+ that uses nested unlimited repeats. Internally, PCRE2 has a
+ counter that is incremented each time around its main pro-
+ cessing loop. If the value set by --match-limit is reached,
an error occurs.
- The --heap-limit option specifies, as a number of kibibytes
+ The --heap-limit option specifies, as a number of kibibytes
(units of 1024 bytes), the maximum amount of heap memory that
may be used for matching.
- The --depth-limit option limits the depth of nested back-
+ The --depth-limit option limits the depth of nested back-
tracking points, which indirectly limits the amount of memory
that is used. The amount of memory needed for each backtrack-
- ing point depends on the number of capturing parentheses in
+ ing point depends on the number of capturing parentheses in
the pattern, so the amount of memory that is used before this
- limit acts varies from pattern to pattern. This limit is of
+ limit acts varies from pattern to pattern. This limit is of
use only if it is set smaller than --match-limit.
- There are no short forms for these options. The default lim-
- its can be set when the PCRE2 library is compiled; if they
- are not specified, the defaults are very large and so effec-
+ There are no short forms for these options. The default lim-
+ its can be set when the PCRE2 library is compiled; if they
+ are not specified, the defaults are very large and so effec-
tively unlimited.
--max-buffer-size=number
- This limits the expansion of the processing buffer, whose
- initial size can be set by --buffer-size. The maximum buffer
- size is silently forced to be no smaller than the starting
+ This limits the expansion of the processing buffer, whose
+ initial size can be set by --buffer-size. The maximum buffer
+ size is silently forced to be no smaller than the starting
buffer size.
-N newline-type, --newline=newline-type
@@ -640,250 +644,250 @@ OPTIONS
pcre2grep -N CRLF 'some pattern'
- The newline type may be specified in upper, lower, or mixed
- case. If the newline type is NUL, lines are separated by bi-
- nary zero characters. The other types are the single-charac-
- ter sequences CR (carriage return) and LF (linefeed), the
- two-character sequence CRLF, an "anycrlf" type, which recog-
- nizes any of the preceding three types, and an "any" type,
- for which any Unicode line ending sequence is assumed to end
- a line. The Unicode sequences are the three just mentioned,
- plus VT (vertical tab, U+000B), FF (form feed, U+000C), NEL
- (next line, U+0085), LS (line separator, U+2028), and PS
+ The newline type may be specified in upper, lower, or mixed
+ case. If the newline type is NUL, lines are separated by bi-
+ nary zero characters. The other types are the single-charac-
+ ter sequences CR (carriage return) and LF (linefeed), the
+ two-character sequence CRLF, an "anycrlf" type, which recog-
+ nizes any of the preceding three types, and an "any" type,
+ for which any Unicode line ending sequence is assumed to end
+ a line. The Unicode sequences are the three just mentioned,
+ plus VT (vertical tab, U+000B), FF (form feed, U+000C), NEL
+ (next line, U+0085), LS (line separator, U+2028), and PS
(paragraph separator, U+2029).
- When the PCRE2 library is built, a default line-ending se-
- quence is specified. This is normally the standard sequence
- for the operating system. Unless otherwise specified by this
+ When the PCRE2 library is built, a default line-ending se-
+ quence is specified. This is normally the standard sequence
+ for the operating system. Unless otherwise specified by this
option, pcre2grep uses the library's default.
- This option makes it possible to use pcre2grep to scan files
+ This option makes it possible to use pcre2grep to scan files
that have come from other environments without having to mod-
- ify their line endings. If the data that is being scanned
- does not agree with the convention set by this option,
- pcre2grep may behave in strange ways. Note that this option
- does not apply to files specified by the -f, --exclude-from,
- or --include-from options, which are expected to use the op-
+ ify their line endings. If the data that is being scanned
+ does not agree with the convention set by this option,
+ pcre2grep may behave in strange ways. Note that this option
+ does not apply to files specified by the -f, --exclude-from,
+ or --include-from options, which are expected to use the op-
erating system's standard newline sequence.
-n, --line-number
Precede each output line by its line number in the file, fol-
- lowed by a colon for matching lines or a hyphen for context
+ lowed by a colon for matching lines or a hyphen for context
lines. If the file name is also being output, it precedes the
- line number. When the -M option causes a pattern to match
- more than one line, only the first is preceded by its line
+ line number. When the -M option causes a pattern to match
+ more than one line, only the first is preceded by its line
number. This option is forced if --line-offsets is used.
--no-group-separator
- Do not output a separator between groups of lines when -A,
+ Do not output a separator between groups of lines when -A,
-B, or -C is in use. The default is to output a line contain-
ing two hyphens. See also --group-separator.
- --no-jit If the PCRE2 library is built with support for just-in-time
+ --no-jit If the PCRE2 library is built with support for just-in-time
compiling (which speeds up matching), pcre2grep automatically
makes use of this, unless it was explicitly disabled at build
- time. This option can be used to disable the use of JIT at
+ time. This option can be used to disable the use of JIT at
run time. It is provided for testing and working around prob-
lems. It should never be needed in normal use.
-O text, --output=text
- When there is a match, instead of outputting the line that
- matched, output just the text specified in this option, fol-
- lowed by an operating-system standard newline. In this mode,
- --colour has no effect, and no context is shown. That is,
- the -A, -B, and -C options are ignored. The --newline option
- has no effect on this option, which is mutually exclusive
+ When there is a match, instead of outputting the line that
+ matched, output just the text specified in this option, fol-
+ lowed by an operating-system standard newline. In this mode,
+ --colour has no effect, and no context is shown. That is,
+ the -A, -B, and -C options are ignored. The --newline option
+ has no effect on this option, which is mutually exclusive
with --only-matching, --file-offsets, and --line-offsets.
- However, like --only-matching, if there is more than one
+ However, like --only-matching, if there is more than one
match in a line, each of them causes a line of output.
Escape sequences starting with a dollar character may be used
to insert the contents of the matched part of the line and/or
captured substrings into the text.
- $ or ${} is replaced by the captured sub-
- string of the given decimal number; $& (or the legacy $0)
- substitutes the whole match. If the number is greater than
- the number of capturing substrings, or if the capture is un-
+ $ or ${} is replaced by the captured sub-
+ string of the given decimal number; $& (or the legacy $0)
+ substitutes the whole match. If the number is greater than
+ the number of capturing substrings, or if the capture is un-
set, the replacement is empty.
- $a is replaced by bell; $b by backspace; $e by escape; $f by
- form feed; $n by newline; $r by carriage return; $t by tab;
+ $a is replaced by bell; $b by backspace; $e by escape; $f by
+ form feed; $n by newline; $r by carriage return; $t by tab;
$v by vertical tab.
$o or $o{} is replaced by the character whose
- code point is the given octal number. In the first form, up
- to three octal digits are processed. When more digits are
- needed in Unicode mode to specify a wide character, the sec-
+ code point is the given octal number. In the first form, up
+ to three octal digits are processed. When more digits are
+ needed in Unicode mode to specify a wide character, the sec-
ond form must be used.
- $x or $x{} is replaced by the character rep-
- resented by the given hexadecimal number. In the first form,
- up to two hexadecimal digits are processed. When more digits
- are needed in Unicode mode to specify a wide character, the
+ $x or $x{} is replaced by the character rep-
+ resented by the given hexadecimal number. In the first form,
+ up to two hexadecimal digits are processed. When more digits
+ are needed in Unicode mode to specify a wide character, the
second form must be used.
- Any other character is substituted by itself. In particular,
+ Any other character is substituted by itself. In particular,
$$ is replaced by a single dollar.
-o, --only-matching
Show only the part of the line that matched a pattern instead
- of the whole line. In this mode, no context is shown. That
- is, the -A, -B, and -C options are ignored. If there is more
- than one match in a line, each of them is shown separately,
- on a separate line of output. If -o is combined with -v (in-
- vert the sense of the match to find non-matching lines), no
- output is generated, but the return code is set appropri-
- ately. If the matched portion of the line is empty, nothing
- is output unless the file name or line number are being
- printed, in which case they are shown on an otherwise empty
+ of the whole line. In this mode, no context is shown. That
+ is, the -A, -B, and -C options are ignored. If there is more
+ than one match in a line, each of them is shown separately,
+ on a separate line of output. If -o is combined with -v (in-
+ vert the sense of the match to find non-matching lines), no
+ output is generated, but the return code is set appropri-
+ ately. If the matched portion of the line is empty, nothing
+ is output unless the file name or line number are being
+ printed, in which case they are shown on an otherwise empty
line. This option is mutually exclusive with --output,
--file-offsets and --line-offsets.
-onumber, --only-matching=number
- Show only the part of the line that matched the capturing
+ Show only the part of the line that matched the capturing
parentheses of the given number. Up to 50 capturing parenthe-
- ses are supported by default. This limit can be changed via
- the --om-capture option. A pattern may contain any number of
- capturing parentheses, but only those whose number is within
- the limit can be accessed by -o. An error occurs if the num-
+ ses are supported by default. This limit can be changed via
+ the --om-capture option. A pattern may contain any number of
+ capturing parentheses, but only those whose number is within
+ the limit can be accessed by -o. An error occurs if the num-
ber specified by -o is greater than the limit.
-o0 is the same as -o without a number. Because these options
- can be given without an argument (see above), if an argument
- is present, it must be given in the same shell item, for ex-
- ample, -o3 or --only-matching=2. The comments given for the
- non-argument case above also apply to this option. If the
- specified capturing parentheses do not exist in the pattern,
- or were not set in the match, nothing is output unless the
+ can be given without an argument (see above), if an argument
+ is present, it must be given in the same shell item, for ex-
+ ample, -o3 or --only-matching=2. The comments given for the
+ non-argument case above also apply to this option. If the
+ specified capturing parentheses do not exist in the pattern,
+ or were not set in the match, nothing is output unless the
file name or line number are being output.
- If this option is given multiple times, multiple substrings
- are output for each match, in the order the options are
- given, and all on one line. For example, -o3 -o1 -o3 causes
- the substrings matched by capturing parentheses 3 and 1 and
- then 3 again to be output. By default, there is no separator
+ If this option is given multiple times, multiple substrings
+ are output for each match, in the order the options are
+ given, and all on one line. For example, -o3 -o1 -o3 causes
+ the substrings matched by capturing parentheses 3 and 1 and
+ then 3 again to be output. By default, there is no separator
(but see the next but one option).
--om-capture=number
- Set the number of capturing parentheses that can be accessed
+ Set the number of capturing parentheses that can be accessed
by -o. The default is 50.
--om-separator=text
- Specify a separating string for multiple occurrences of -o.
- The default is an empty string. Separating strings are never
+ Specify a separating string for multiple occurrences of -o.
+ The default is an empty string. Separating strings are never
coloured.
-P, --no-ucp
- Starting from release 10.43, when UTF/Unicode mode is speci-
- fied with -u or -U, the PCRE2_UCP option is used by default.
+ Starting from release 10.43, when UTF/Unicode mode is speci-
+ fied with -u or -U, the PCRE2_UCP option is used by default.
This means that the POSIX classes in patterns match more than
- just ASCII characters. For example, [:digit:] matches any
- Unicode decimal digit. The --no-ucp option suppresses
- PCRE2_UCP, thus restricting the POSIX classes to ASCII char-
- acters, as was the case in earlier releases. Note that there
- are now more fine-grained option settings within patterns
- that affect individual classes. For example, when in UCP
+ just ASCII characters. For example, [:digit:] matches any
+ Unicode decimal digit. The --no-ucp option suppresses
+ PCRE2_UCP, thus restricting the POSIX classes to ASCII char-
+ acters, as was the case in earlier releases. Note that there
+ are now more fine-grained option settings within patterns
+ that affect individual classes. For example, when in UCP
mode, the sequence (?aP) restricts [:word:] to ASCII letters,
while allowing \w to match Unicode letters and digits.
--posix-pattern-file
- When patterns are provided with the -f option, do not trim
- trailing spaces or ignore empty lines in a similar way than
+ When patterns are provided with the -f option, do not trim
+ trailing spaces or ignore empty lines in a similar way than
other grep tools. To keep the behaviour consistent with older
- versions, if the pattern read was terminated with CRLF (as
+ versions, if the pattern read was terminated with CRLF (as
character literals) then both characters won't be included as
- part of it, so if you really need to have pattern ending in
- '\r', use a escape sequence or provide it by a different
+ part of it, so if you really need to have pattern ending in
+ '\r', use a escape sequence or provide it by a different
method.
-q, --quiet
Work quietly, that is, display nothing except error messages.
- The exit status indicates whether or not any matches were
+ The exit status indicates whether or not any matches were
found.
-r, --recursive
- If any given path is a directory, recursively scan the files
- it contains, taking note of any --include and --exclude set-
- tings. By default, a directory is read as a normal file; in
- some operating systems this gives an immediate end-of-file.
- This option is a shorthand for setting the -d option to "re-
+ If any given path is a directory, recursively scan the files
+ it contains, taking note of any --include and --exclude set-
+ tings. By default, a directory is read as a normal file; in
+ some operating systems this gives an immediate end-of-file.
+ This option is a shorthand for setting the -d option to "re-
curse".
--recursion-limit=number
- This is an obsolete synonym for --depth-limit. See --match-
+ This is an obsolete synonym for --depth-limit. See --match-
limit above for details.
-s, --no-messages
- Suppress error messages about non-existent or unreadable
- files. Such files are quietly skipped. However, the return
+ Suppress error messages about non-existent or unreadable
+ files. Such files are quietly skipped. However, the return
code is still 2, even if matches were found in other files.
-t, --total-count
- This option is useful when scanning more than one file. If
- used on its own, -t suppresses all output except for a grand
- total number of matching lines (or non-matching lines if -v
+ This option is useful when scanning more than one file. If
+ used on its own, -t suppresses all output except for a grand
+ total number of matching lines (or non-matching lines if -v
is used) in all the files. If -t is used with -c, a grand to-
- tal is output except when the previous output is just one
- line. In other words, it is not output when just one file's
- count is listed. If file names are being output, the grand
- total is preceded by "TOTAL:". Otherwise, it appears as just
- another number. The -t option is ignored when used with -L
- (list files without matches), because the grand total would
+ tal is output except when the previous output is just one
+ line. In other words, it is not output when just one file's
+ count is listed. If file names are being output, the grand
+ total is preceded by "TOTAL:". Otherwise, it appears as just
+ another number. The -t option is ignored when used with -L
+ (list files without matches), because the grand total would
always be zero.
-u, --utf Operate in UTF/Unicode mode. This option is available only if
PCRE2 has been compiled with UTF-8 support. All patterns (in-
- cluding those for any --exclude and --include options) and
- all lines that are scanned must be valid strings of UTF-8
+ cluding those for any --exclude and --include options) and
+ all lines that are scanned must be valid strings of UTF-8
characters. If an invalid UTF-8 string is encountered, an er-
ror occurs.
-U, --utf-allow-invalid
- As --utf, but in addition subject lines may contain invalid
- UTF-8 code unit sequences. These can never form part of any
- pattern match. Patterns themselves, however, must still be
+ As --utf, but in addition subject lines may contain invalid
+ UTF-8 code unit sequences. These can never form part of any
+ pattern match. Patterns themselves, however, must still be
valid UTF-8 strings. This facility allows valid UTF-8 strings
to be sought within arbitrary byte sequences in executable or
- other binary files. For more details about matching in non-
+ other binary files. For more details about matching in non-
valid UTF-8 strings, see the pcre2unicode(3) documentation.
-V, --version
- Write the version numbers of pcre2grep and the PCRE2 library
- to the standard output and then exit. Anything else on the
+ Write the version numbers of pcre2grep and the PCRE2 library
+ to the standard output and then exit. Anything else on the
command line is ignored.
-v, --invert-match
- Invert the sense of the match, so that lines which do not
- match any of the patterns are the ones that are found. When
- this option is set, options such as --only-matching and
- --output, which specify parts of a match that are to be out-
+ Invert the sense of the match, so that lines which do not
+ match any of the patterns are the ones that are found. When
+ this option is set, options such as --only-matching and
+ --output, which specify parts of a match that are to be out-
put, are ignored.
-w, --word-regex, --word-regexp
Force the patterns only to match "words". That is, there must
- be a word boundary at the start and end of each matched
- string. This is equivalent to having "\b(?:" at the start of
- each pattern, and ")\b" at the end. This option applies only
- to the patterns that are matched against the contents of
- files; it does not apply to patterns specified by any of the
+ be a word boundary at the start and end of each matched
+ string. This is equivalent to having "\b(?:" at the start of
+ each pattern, and ")\b" at the end. This option applies only
+ to the patterns that are matched against the contents of
+ files; it does not apply to patterns specified by any of the
--include or --exclude options.
-x, --line-regex, --line-regexp
- Force the patterns to start matching only at the beginnings
- of lines, and in addition, require them to match entire
+ Force the patterns to start matching only at the beginnings
+ of lines, and in addition, require them to match entire
lines. In multiline mode the match may be more than one line.
This is equivalent to having "^(?:" at the start of each pat-
- tern and ")$" at the end. This option applies only to the
- patterns that are matched against the contents of files; it
- does not apply to patterns specified by any of the --include
+ tern and ")$" at the end. This option applies only to the
+ patterns that are matched against the contents of files; it
+ does not apply to patterns specified by any of the --include
or --exclude options.
-Z, --null
- Terminate files names in the regular output with a zero byte
- (the NUL character) instead of what would normally appear.
- This is useful when file names contain unusual characters
- such as colons, hyphens, or even newlines. The option does
+ Terminate files names in the regular output with a zero byte
+ (the NUL character) instead of what would normally appear.
+ This is useful when file names contain unusual characters
+ such as colons, hyphens, or even newlines. The option does
not apply to file names in error messages.
@@ -897,141 +901,141 @@ ENVIRONMENT VARIABLES
NEWLINES
- The -N (--newline) option allows pcre2grep to scan files with newline
- conventions that differ from the default. This option affects only the
- way scanned files are processed. It does not affect the interpretation
- of files specified by the -f, --file-list, --exclude-from, or --in-
+ The -N (--newline) option allows pcre2grep to scan files with newline
+ conventions that differ from the default. This option affects only the
+ way scanned files are processed. It does not affect the interpretation
+ of files specified by the -f, --file-list, --exclude-from, or --in-
clude-from options.
- Any parts of the scanned input files that are written to the standard
- output are copied with whatever newline sequences they have in the in-
- put. However, if the final line of a file is output, and it does not
- end with a newline sequence, a newline sequence is added. If the new-
- line setting is CR, LF, CRLF or NUL, that line ending is output; for
+ Any parts of the scanned input files that are written to the standard
+ output are copied with whatever newline sequences they have in the in-
+ put. However, if the final line of a file is output, and it does not
+ end with a newline sequence, a newline sequence is added. If the new-
+ line setting is CR, LF, CRLF or NUL, that line ending is output; for
the other settings (ANYCRLF or ANY) a single NL is used.
- The newline setting does not affect the way in which pcre2grep writes
- newlines in informational messages to the standard output and error
- streams. Under Windows, the standard output is set to be binary, so
- that "\r\n" at the ends of output lines that are copied from the input
- is not converted to "\r\r\n" by the C I/O library. This means that any
- messages written to the standard output must end with "\r\n". For all
- other operating systems, and for all messages to the standard error
+ The newline setting does not affect the way in which pcre2grep writes
+ newlines in informational messages to the standard output and error
+ streams. Under Windows, the standard output is set to be binary, so
+ that "\r\n" at the ends of output lines that are copied from the input
+ is not converted to "\r\r\n" by the C I/O library. This means that any
+ messages written to the standard output must end with "\r\n". For all
+ other operating systems, and for all messages to the standard error
stream, "\n" is used.
OPTIONS COMPATIBILITY WITH GNU GREP
Many of the short and long forms of pcre2grep's options are the same as
- in the GNU grep program. Any long option of the form --xxx-regexp (GNU
- terminology) is also available as --xxx-regex (PCRE2 terminology).
- However, the --case-restrict, --depth-limit, -E, --file-list, --file-
- offsets, --heap-limit, --include-dir, --line-offsets, --locale,
- --match-limit, -M, --multiline, -N, --newline, --no-ucp, --om-separa-
- tor, --output, -P, -u, --utf, -U, and --utf-allow-invalid options are
+ in the GNU grep program. Any long option of the form --xxx-regexp (GNU
+ terminology) is also available as --xxx-regex (PCRE2 terminology).
+ However, the --case-restrict, --depth-limit, -E, --file-list, --file-
+ offsets, --heap-limit, --include-dir, --lf, --line-offsets, --locale,
+ --match-limit, -M, --multiline, -N, --newline, --no-ucp, --om-separa-
+ tor, --output, -P, -u, --utf, -U, and --utf-allow-invalid options are
specific to pcre2grep, as is the use of the --only-matching option with
a capturing parentheses number.
- Although most of the common options work the same way, a few are dif-
- ferent in pcre2grep. For example, the --include option's argument is a
+ Although most of the common options work the same way, a few are dif-
+ ferent in pcre2grep. For example, the --include option's argument is a
glob for GNU grep, but in pcre2grep it is a regular expression to which
- the -i option applies. If both the -c and -l options are given, GNU
- grep lists only file names, without counts, but pcre2grep gives the
+ the -i option applies. If both the -c and -l options are given, GNU
+ grep lists only file names, without counts, but pcre2grep gives the
counts as well.
OPTIONS WITH DATA
There are four different ways in which an option with data can be spec-
- ified. If a short form option is used, the data may follow immedi-
+ ified. If a short form option is used, the data may follow immedi-
ately, or (with one exception) in the next command line item. For exam-
ple:
-f/some/file
-f /some/file
- The exception is the -o option, which may appear with or without data.
- Because of this, if data is present, it must follow immediately in the
+ The exception is the -o option, which may appear with or without data.
+ Because of this, if data is present, it must follow immediately in the
same item, for example -o3.
- If a long form option is used, the data may appear in the same command
- line item, separated by an equals character, or (with two exceptions)
+ If a long form option is used, the data may appear in the same command
+ line item, separated by an equals character, or (with two exceptions)
it may appear in the next command line item. For example:
--file=/some/file
--file /some/file
- Note, however, that if you want to supply a file name beginning with ~
- as data in a shell command, and have the shell expand ~ to a home di-
- rectory, you must separate the file name from the option, because the
+ Note, however, that if you want to supply a file name beginning with ~
+ as data in a shell command, and have the shell expand ~ to a home di-
+ rectory, you must separate the file name from the option, because the
shell does not treat ~ specially unless it is at the start of an item.
- The exceptions to the above are the --colour (or --color) and --only-
- matching options, for which the data is optional. If one of these op-
- tions does have data, it must be given in the first form, using an
+ The exceptions to the above are the --colour (or --color) and --only-
+ matching options, for which the data is optional. If one of these op-
+ tions does have data, it must be given in the first form, using an
equals character. Otherwise pcre2grep will assume that it has no data.
USING PCRE2'S CALLOUT FACILITY
- pcre2grep has, by default, support for calling external programs or
- scripts or echoing specific strings during matching by making use of
- PCRE2's callout facility. However, this support can be completely or
- partially disabled when pcre2grep is built. You can find out whether
- your binary has support for callouts by running it with the --help op-
- tion. If callout support is completely disabled, callouts in patterns
- are forbidden by pcre2grep. If the facility is partially disabled,
- calling external programs is not supported, and callouts that request
+ pcre2grep has, by default, support for calling external programs or
+ scripts or echoing specific strings during matching by making use of
+ PCRE2's callout facility. However, this support can be completely or
+ partially disabled when pcre2grep is built. You can find out whether
+ your binary has support for callouts by running it with the --help op-
+ tion. If callout support is completely disabled, callouts in patterns
+ are forbidden by pcre2grep. If the facility is partially disabled,
+ calling external programs is not supported, and callouts that request
it are ignored.
- A callout in a PCRE2 pattern is of the form (?C) where the argu-
- ment is either a number or a quoted string (see the pcre2callout docu-
- mentation for details). Numbered callouts are ignored by pcre2grep;
+ A callout in a PCRE2 pattern is of the form (?C) where the argu-
+ ment is either a number or a quoted string (see the pcre2callout docu-
+ mentation for details). Numbered callouts are ignored by pcre2grep;
only callouts with string arguments are useful.
Echoing a specific string
- Starting the callout string with a pipe character invokes an echoing
+ Starting the callout string with a pipe character invokes an echoing
facility that avoids calling an external program or script. This facil-
- ity is always available, provided that callouts were not completely
- disabled when pcre2grep was built. The rest of the callout string is
- processed as a zero-terminated string, which means it should not con-
- tain any internal binary zeros. It is written to the output, having
- first been passed through the same escape processing as text from the
- --output (-O) option (see above). However, $0 or $& cannot be used to
- insert a matched substring because the match is still in progress. In-
- stead, the single character '0' is inserted. Any syntax errors in the
+ ity is always available, provided that callouts were not completely
+ disabled when pcre2grep was built. The rest of the callout string is
+ processed as a zero-terminated string, which means it should not con-
+ tain any internal binary zeros. It is written to the output, having
+ first been passed through the same escape processing as text from the
+ --output (-O) option (see above). However, $0 or $& cannot be used to
+ insert a matched substring because the match is still in progress. In-
+ stead, the single character '0' is inserted. Any syntax errors in the
string (for example, a dollar not followed by another character) causes
the callout to be ignored. No terminator is added to the output string,
- so if you want a newline, you must include it explicitly using the es-
+ so if you want a newline, you must include it explicitly using the es-
cape $n. For example:
pcre2grep '(.)(..(.))(?C"|[$1] [$2] [$3]$n")'
- Matching continues normally after the string is output. If you want to
- see only the callout output but not any output from an actual match,
+ Matching continues normally after the string is output. If you want to
+ see only the callout output but not any output from an actual match,
you should end the pattern with (*FAIL).
Calling external programs or scripts
This facility can be independently disabled when pcre2grep is built. It
- is supported for Windows, where a call to _spawnvp() is used, for VMS,
- where lib$spawn() is used, and for any Unix-like environment where
+ is supported for Windows, where a call to _spawnvp() is used, for VMS,
+ where lib$spawn() is used, and for any Unix-like environment where
fork() and execv() are available.
If the callout string does not start with a pipe (vertical bar) charac-
- ter, it is parsed into a list of substrings separated by pipe charac-
- ters. The first substring must be an executable name, with the follow-
+ ter, it is parsed into a list of substrings separated by pipe charac-
+ ters. The first substring must be an executable name, with the follow-
ing substrings specifying arguments:
executable_name|arg1|arg2|...
- Any substring (including the executable name) may contain escape se-
- quences started by a dollar character. These are the same as for the
- --output (-O) option documented above, except that $0 or $& cannot in-
- sert the matched string because the match is still in progress. In-
- stead, the character '0' is inserted. If you need a literal dollar or
- pipe character in any substring, use $$ or $| respectively. Here is an
+ Any substring (including the executable name) may contain escape se-
+ quences started by a dollar character. These are the same as for the
+ --output (-O) option documented above, except that $0 or $& cannot in-
+ sert the matched string because the match is still in progress. In-
+ stead, the character '0' is inserted. If you need a literal dollar or
+ pipe character in any substring, use $$ or $| respectively. Here is an
example:
echo -e "abcde\n12345" | pcre2grep \
@@ -1045,43 +1049,43 @@ USING PCRE2'S CALLOUT FACILITY
Arg1: [1] [234] [4] Arg2: |1| ()
12345
- The parameters for the system call that is used to run the program or
+ The parameters for the system call that is used to run the program or
script are zero-terminated strings. This means that binary zero charac-
- ters in the callout argument will cause premature termination of their
- substrings, and therefore should not be present. Any syntax errors in
- the string (for example, a dollar not followed by another character)
+ ters in the callout argument will cause premature termination of their
+ substrings, and therefore should not be present. Any syntax errors in
+ the string (for example, a dollar not followed by another character)
causes the callout to be ignored. If running the program fails for any
- reason (including the non-existence of the executable), a local match-
+ reason (including the non-existence of the executable), a local match-
ing failure occurs and the matcher backtracks in the normal way.
MATCHING ERRORS
- It is possible to supply a regular expression that takes a very long
- time to fail to match certain lines. Such patterns normally involve
- nested indefinite repeats, for example: (a+)*\d when matched against a
- line of a's with no final digit. The PCRE2 matching function has a re-
- source limit that causes it to abort in these circumstances. If this
- happens, pcre2grep outputs an error message and the line that caused
- the problem to the standard error stream. If there are more than 20
+ It is possible to supply a regular expression that takes a very long
+ time to fail to match certain lines. Such patterns normally involve
+ nested indefinite repeats, for example: (a+)*\d when matched against a
+ line of a's with no final digit. The PCRE2 matching function has a re-
+ source limit that causes it to abort in these circumstances. If this
+ happens, pcre2grep outputs an error message and the line that caused
+ the problem to the standard error stream. If there are more than 20
such errors, pcre2grep gives up.
- The --match-limit option of pcre2grep can be used to set the overall
- resource limit. There are also other limits that affect the amount of
- memory used during matching; see the discussion of --heap-limit and
+ The --match-limit option of pcre2grep can be used to set the overall
+ resource limit. There are also other limits that affect the amount of
+ memory used during matching; see the discussion of --heap-limit and
--depth-limit above.
DIAGNOSTICS
Exit status is 0 if any matches were found, 1 if no matches were found,
- and 2 for syntax errors, overlong lines, non-existent or inaccessible
- files (even if matches were found in other files) or too many matching
+ and 2 for syntax errors, overlong lines, non-existent or inaccessible
+ files (even if matches were found in other files) or too many matching
errors. Using the -s option to suppress error messages about inaccessi-
ble files does not affect the return code.
- When run under VMS, the return code is placed in the symbol
- PCRE2GREP_RC because VMS does not distinguish between exit(0) and
+ When run under VMS, the return code is placed in the symbol
+ PCRE2GREP_RC because VMS does not distinguish between exit(0) and
exit(1).
diff --git a/maint/UpdateAlways b/maint/UpdateAlways
index 99cccbc3d..99bf24b57 100755
--- a/maint/UpdateAlways
+++ b/maint/UpdateAlways
@@ -218,9 +218,8 @@ echo Documentation done
if [ "$1" = "doc" ] ; then exit; fi
# These files are detrailed; do not detrail the test data because there may be
-# significant trailing spaces. Do not detrail RunTest.bat, because it has CRLF
-# line endings and the detrail script removes all trailing white space. The
-# configure files are also omitted from the detrailing.
+# significant trailing spaces. The configure files are also omitted from the
+# detrailing.
txt_files=(
AUTHORS.md
@@ -237,7 +236,9 @@ txt_files=(
NON-AUTOTOOLS-BUILD
README
RunGrepTest
+ RunGrepTest.py
RunTest
+ RunTest.py
SECURITY.md
SUPPORT-LIFECYCLE.md
build.zig
@@ -250,7 +251,7 @@ txt_files=(
pcre2-config.in
perltest.sh
cmake/COPYING-CMAKE-SCRIPTS
- cmake/{*.cmake,*.cmake.in}
+ cmake/{*.cmake,*.in}
m4/ax_pthread.m4
m4/pcre2_check_vscript.m4
m4/pcre2_visibility.m4
@@ -261,8 +262,6 @@ txt_files=(
)
crlf_files=(
- RunGrepTest.bat
- RunTest.bat
)
c_files=(
diff --git a/maint/formatting.yapf b/maint/formatting.yapf
new file mode 100644
index 000000000..85f5abaaa
--- /dev/null
+++ b/maint/formatting.yapf
@@ -0,0 +1,5 @@
+[style]
+based_on_style = pep8
+column_limit = 120
+indent_width = 2
+continuation_indent_width = 4
diff --git a/maint/manifest-tarball b/maint/manifest-tarball
index 71fbfd811..01d98eac1 100644
--- a/maint/manifest-tarball
+++ b/maint/manifest-tarball
@@ -15,9 +15,9 @@ drwxr-xr-x tarball-dir/pcre2-SNAPSHOT
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/NON-AUTOTOOLS-BUILD
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/README
-rwxr-xr-x tarball-dir/pcre2-SNAPSHOT/RunGrepTest
--rw-r--r-- tarball-dir/pcre2-SNAPSHOT/RunGrepTest.bat
+-rwxr-xr-x tarball-dir/pcre2-SNAPSHOT/RunGrepTest.py
-rwxr-xr-x tarball-dir/pcre2-SNAPSHOT/RunTest
--rw-r--r-- tarball-dir/pcre2-SNAPSHOT/RunTest.bat
+-rwxr-xr-x tarball-dir/pcre2-SNAPSHOT/RunTest.py
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/SECURITY.md
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/SUPPORT-LIFECYCLE.md
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/aclocal.m4
@@ -482,7 +482,10 @@ drwxr-xr-x tarball-dir/pcre2-SNAPSHOT/testdata
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput3
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput3A
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput3B
+-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput3C
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput3D
+-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput3E
+-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput3F
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput4
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput5
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutput6
@@ -498,8 +501,6 @@ drwxr-xr-x tarball-dir/pcre2-SNAPSHOT/testdata
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutputheap-32
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/testoutputheap-8
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/valgrind-jit.supp
--rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/wintestinput3
--rw-r--r-- tarball-dir/pcre2-SNAPSHOT/testdata/wintestoutput3
drwxr-xr-x tarball-dir/pcre2-SNAPSHOT/vms
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/vms/configure.com
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/vms/openvms_readme.txt
diff --git a/src/pcre2grep.c b/src/pcre2grep.c
index 0afdfd221..77c294be4 100644
--- a/src/pcre2grep.c
+++ b/src/pcre2grep.c
@@ -192,12 +192,11 @@ handled by using STDOUT_NL as the newline string. We also use a normal double
quote for the example, as single quotes aren't usually available. */
#ifdef WIN32
-#define STDOUT_NL "\r\n"
-#define STDOUT_NL_LEN 2
+#define DEFAULT_STDOUT_IS_CRLF
+#define DEFAULT_STDOUT_NL "\r\n"
#define QUOT "\""
#else
-#define STDOUT_NL "\n"
-#define STDOUT_NL_LEN 1
+#define DEFAULT_STDOUT_NL "\n"
#define QUOT "'"
#endif
@@ -226,9 +225,10 @@ static const char *output_text = NULL;
static char *main_buffer = NULL;
-static const char *printname_nl = STDOUT_NL; // Changed to NULL for -Z
-static int printname_colon = ':'; // Changed to 0 for -Z
-static int printname_hyphen = '-'; // Changed to 0 for -Z
+static const char *stdout_nl = DEFAULT_STDOUT_NL;
+static const char *printname_nl = DEFAULT_STDOUT_NL; // Changed to NULL for -Z
+static int printname_colon = ':'; // Changed to 0 for -Z
+static int printname_hyphen = '-'; // Changed to 0 for -Z
static int after_context = 0;
static int before_context = 0;
@@ -438,6 +438,7 @@ used to identify them. */
#define N_GROUP_SEPARATOR (-27)
#define N_NO_GROUP_SEPARATOR (-28)
#define N_POSIX_PATFILE (-29)
+#define N_LF (-30)
static option_item optionlist[] = {
{ OP_NODATA, N_NULL, NULL, "", "terminate options" },
@@ -471,6 +472,11 @@ static option_item optionlist[] = {
{ OP_NODATA, 'L', NULL, "files-without-match","print only FILE names not containing matches" },
{ OP_STRING, N_LABEL, &stdin_name, "label=name", "set name for standard input" },
{ OP_NODATA, N_LBUFFER, NULL, "line-buffered", "use line buffering" },
+#ifdef DEFAULT_STDOUT_IS_CRLF
+ { OP_NODATA, N_LF, NULL, "lf", "use LF line endings in output" },
+#else
+ { OP_NODATA, N_LF, NULL, "lf", "ignored: this pcre2grep always use LF line endings" },
+#endif
{ OP_NODATA, N_LOFFSETS, NULL, "line-offsets", "output line numbers and offsets, not text" },
{ OP_STRING, N_LOCALE, &locale, "locale=locale", "use the named locale" },
{ OP_U32NUMBER, N_H_LIMIT, &heap_limit, "heap-limit=number", "set PCRE2 heap limit option (kibibytes)" },
@@ -1167,38 +1173,38 @@ help(void)
{
option_item *op;
-printf("Usage: pcre2grep [OPTION]... [PATTERN] [FILE1 FILE2 ...]" STDOUT_NL);
-printf("Search for PATTERN in each FILE or standard input." STDOUT_NL);
-printf("PATTERN must be present if neither -e nor -f is used." STDOUT_NL);
+printf("Usage: pcre2grep [OPTION]... [PATTERN] [FILE1 FILE2 ...]%s", stdout_nl);
+printf("Search for PATTERN in each FILE or standard input.%s", stdout_nl);
+printf("PATTERN must be present if neither -e nor -f is used.%s", stdout_nl);
#ifdef SUPPORT_PCRE2GREP_CALLOUT
#ifdef SUPPORT_PCRE2GREP_CALLOUT_FORK
-printf("All callout scripts in patterns are supported." STDOUT_NL);
+printf("All callout scripts in patterns are supported.%s", stdout_nl);
#else
-printf("Non-fork callout scripts in patterns are supported." STDOUT_NL);
+printf("Non-fork callout scripts in patterns are supported.%s", stdout_nl);
#endif
#else
-printf("Callout scripts are not supported in this pcre2grep." STDOUT_NL);
+printf("Callout scripts are not supported in this pcre2grep.%s", stdout_nl);
#endif
-printf("\"-\" can be used as a file name to mean STDIN." STDOUT_NL);
+printf("\"-\" can be used as a file name to mean STDIN.%s", stdout_nl);
#ifdef SUPPORT_LIBZ
-printf("Files whose names end in .gz are read using zlib." STDOUT_NL);
+printf("Files whose names end in .gz are read using zlib.%s", stdout_nl);
#endif
#ifdef SUPPORT_LIBBZ2
-printf("Files whose names end in .bz2 are read using bzlib2." STDOUT_NL);
+printf("Files whose names end in .bz2 are read using bzlib2.%s", stdout_nl);
#endif
#if defined SUPPORT_LIBZ || defined SUPPORT_LIBBZ2
-printf("Other files and the standard input are read as plain files." STDOUT_NL STDOUT_NL);
+printf("Other files and the standard input are read as plain files.%s%s", stdout_nl, stdout_nl);
#else
-printf("All files are read as plain files, without any interpretation." STDOUT_NL STDOUT_NL);
+printf("All files are read as plain files, without any interpretation.%s%s", stdout_nl, stdout_nl);
#endif
-printf("Example: pcre2grep -i " QUOT "hello.*world" QUOT " menu.h main.c" STDOUT_NL STDOUT_NL);
-printf("Options:" STDOUT_NL);
+printf("Example: pcre2grep -i " QUOT "hello.*world" QUOT " menu.h main.c%s%s", stdout_nl, stdout_nl);
+printf("Options:%s", stdout_nl);
for (op = optionlist; op->one_char != 0; op++)
{
@@ -1215,18 +1221,18 @@ for (op = optionlist; op->one_char != 0; op++)
}
if (n < 1) n = 1;
- printf("%.*s%s" STDOUT_NL, n, " ", op->help_text);
+ printf("%.*s%s%s", n, " ", op->help_text, stdout_nl);
}
-printf(STDOUT_NL "Numbers may be followed by K or M, e.g. --max-buffer-size=100K." STDOUT_NL);
-printf("The default value for --buffer-size is %d." STDOUT_NL, PCRE2GREP_BUFSIZE);
-printf("The default value for --max-buffer-size is %d." STDOUT_NL, PCRE2GREP_MAX_BUFSIZE);
-printf("When reading patterns or file names from a file, trailing white" STDOUT_NL);
-printf("space is removed and blank lines are ignored." STDOUT_NL);
-printf("The maximum size of any pattern is %d bytes." STDOUT_NL, MAXPATLEN);
+printf("%sNumbers may be followed by K or M, e.g. --max-buffer-size=100K.%s", stdout_nl, stdout_nl);
+printf("The default value for --buffer-size is %d.%s", PCRE2GREP_BUFSIZE, stdout_nl);
+printf("The default value for --max-buffer-size is %d.%s", PCRE2GREP_MAX_BUFSIZE, stdout_nl);
+printf("When reading patterns or file names from a file, trailing white%s", stdout_nl);
+printf("space is removed and blank lines are ignored.%s", stdout_nl);
+printf("The maximum size of any pattern is %d bytes.%s", MAXPATLEN, stdout_nl);
-printf(STDOUT_NL "With no FILEs, read standard input. If fewer than two FILEs given, assume -h." STDOUT_NL);
-printf("Exit status is 0 if any matches, 1 if no matches, and 2 if trouble." STDOUT_NL);
+printf("%sWith no FILEs, read standard input. If fewer than two FILEs given, assume -h.%s", stdout_nl, stdout_nl);
+printf("Exit status is 0 if any matches, 1 if no matches, and 2 if trouble.%s", stdout_nl);
}
@@ -2200,7 +2206,7 @@ for (; *string != 0; string++)
case DDE_CHAR:
if (value == STDOUT_NL_CODE)
{
- fprintf(stdout, STDOUT_NL);
+ fprintf(stdout, "%s", stdout_nl);
printed = FALSE;
continue;
}
@@ -2380,7 +2386,7 @@ while (length > 0)
break;
case DDE_CHAR:
- if (value == STDOUT_NL_CODE) argslen += STDOUT_NL_LEN - 1;
+ if (value == STDOUT_NL_CODE) argslen += strlen(stdout_nl) - 1;
else if (utf && value > 127) argslen += ord2utf8(value) - 1;
break;
@@ -2467,8 +2473,8 @@ while (length > 0)
case DDE_CHAR:
if (value == STDOUT_NL_CODE)
{
- memcpy(argsptr, STDOUT_NL, STDOUT_NL_LEN);
- argsptr += STDOUT_NL_LEN;
+ memcpy(argsptr, stdout_nl, strlen(stdout_nl));
+ argsptr += strlen(stdout_nl);
}
else if (utf && value > 127)
{
@@ -2850,7 +2856,7 @@ while (ptr < endptr)
else if (binary)
{
- fprintf(stdout, "Binary file %s matches" STDOUT_NL, filename);
+ fprintf(stdout, "Binary file %s matches%s", filename, stdout_nl);
return 0;
}
@@ -2901,10 +2907,10 @@ while (ptr < endptr)
}
if (line_offsets)
- fprintf(stdout, "%d,%d" STDOUT_NL, (int)start, (int)(end - start));
+ fprintf(stdout, "%d,%d%s", (int)start, (int)(end - start), stdout_nl);
else
- fprintf(stdout, "%d,%d" STDOUT_NL, (int)(filepos + start),
- (int)(end - start));
+ fprintf(stdout, "%d,%d%s", (int)(filepos + start),
+ (int)(end - start), stdout_nl);
}
/* Handle --output (which has already been syntax checked) */
@@ -2913,7 +2919,7 @@ while (ptr < endptr)
{
(void)display_output_text((PCRE2_SPTR)output_text, FALSE,
(PCRE2_SPTR)ptr, offsets, mrc);
- fprintf(stdout, STDOUT_NL);
+ fprintf(stdout, "%s", stdout_nl);
}
/* Handle --only-matching, which may occur many times */
@@ -2953,7 +2959,7 @@ while (ptr < endptr)
}
}
if (printed || printname != NULL || number)
- fprintf(stdout, STDOUT_NL);
+ fprintf(stdout, "%s", stdout_nl);
}
/* Prepare to repeat to find the next match in the line. */
@@ -3045,7 +3051,7 @@ while (ptr < endptr)
else if (hyphenpending)
{
if (group_separator != NULL)
- fprintf(stdout, "%s%s", group_separator, STDOUT_NL);
+ fprintf(stdout, "%s%s", group_separator, stdout_nl);
hyphenpending = FALSE;
hyphenprinted = TRUE;
}
@@ -3068,7 +3074,7 @@ while (ptr < endptr)
if (lastmatchnumber > 0 && p > lastmatchrestart && !hyphenprinted &&
group_separator != NULL)
- fprintf(stdout, "%s%s", group_separator, STDOUT_NL);
+ fprintf(stdout, "%s%s", group_separator, stdout_nl);
hyphenpending = FALSE;
while (p < ptr)
@@ -3090,7 +3096,7 @@ while (ptr < endptr)
else if (hyphenpending)
{
if (group_separator != NULL)
- fprintf(stdout, "%s%s", group_separator, STDOUT_NL);
+ fprintf(stdout, "%s%s", group_separator, stdout_nl);
hyphenpending = FALSE;
}
@@ -3341,7 +3347,7 @@ if (count_only && !quiet)
{
if (printname != NULL && filenames != FN_NONE)
fprintf(stdout, "%s%c", printname, printname_colon);
- fprintf(stdout, "%lu" STDOUT_NL, count);
+ fprintf(stdout, "%lu%s", count, stdout_nl);
counts_printed++;
}
}
@@ -3736,6 +3742,7 @@ switch (letter)
case N_FOFFSETS: file_offsets = TRUE; break;
case N_HELP: help(); pcre2grep_exit(0); break; // Stops compiler warning
case N_LBUFFER: line_buffered = TRUE; break;
+ case N_LF: stdout_nl = "\n"; printname_nl = stdout_nl; break;
case N_LOFFSETS: line_offsets = number = TRUE; break;
case N_NOJIT: use_jit = FALSE; break;
case N_ALLABSK: extra_options |= PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK; break;
@@ -3774,7 +3781,7 @@ switch (letter)
{
unsigned char buffer[128];
(void)pcre2_config(PCRE2_CONFIG_VERSION, buffer);
- fprintf(stdout, "pcre2grep version %s" STDOUT_NL, buffer);
+ fprintf(stdout, "pcre2grep version %s%s", buffer, stdout_nl);
}
pcre2grep_exit(0);
break; // LCOV_EXCL_LINE - statement kept to avoid compiler warning
@@ -4028,14 +4035,13 @@ const char *locale_from = "--locale";
pcre2_jit_stack *jit_stack = NULL;
#endif
-/* In Windows, stdout is set up as a text stream, which means that \n is
-converted to \r\n. This causes output lines that are copied from the input to
-change from ....\r\n to ....\r\r\n, which is not right. We therefore ensure
-that stdout is a binary stream. Note that this means all other output to stdout
-must use STDOUT_NL to terminate lines. */
+/* In Windows, text streams convert \n to \r\n. Use binary streams so copied
+input lines are not changed. Output on stdout uses stdout_nl explicitly. */
#ifdef WIN32
+_setmode(_fileno(stdin), _O_BINARY);
_setmode(_fileno(stdout), _O_BINARY);
+_setmode(_fileno(stderr), _O_BINARY);
#endif
/* Process the options */
@@ -4735,7 +4741,7 @@ if (show_total_count && counts_printed != 1 && filenames != FN_NOMATCH_ONLY)
{
if (counts_printed != 0 && filenames >= FN_DEFAULT)
fprintf(stdout, "TOTAL:");
- fprintf(stdout, "%lu" STDOUT_NL, total_count);
+ fprintf(stdout, "%lu%s", total_count, stdout_nl);
}
EXIT:
diff --git a/src/pcre2test.c b/src/pcre2test.c
index 08abb4bda..864935b6e 100644
--- a/src/pcre2test.c
+++ b/src/pcre2test.c
@@ -116,19 +116,12 @@ required for different environments. */
/* ---------------------- System-specific definitions ---------------------- */
-/* A number of things vary for Windows builds. Originally, pcretest opened its
-input and output without "b"; then I was told that "b" was needed in some
-environments, so it was added for release 5.0 to both the input and output. (It
-makes no difference on Unix-like systems.) Later I was told that it is wrong
-for the input on Windows. I've now abstracted the modes into macros that are
-set here, to make it easier to fiddle with them, and removed "b" from the input
-mode under Windows. The BINARY versions are used when saving/restoring compiled
-patterns. */
+/* The BINARY modes are used when saving/restoring compiled patterns. */
#if defined(_WIN32) || defined(WIN32)
#include /* For _setmode() */
#include /* For _O_BINARY */
-#define INPUT_MODE "r"
+#define INPUT_MODE "rb"
#define OUTPUT_MODE "wb"
#define BINARY_INPUT_MODE "rb"
#define BINARY_OUTPUT_MODE "wb"
@@ -3150,6 +3143,7 @@ printf(" show output in colour\n");
printf(" -d set default pattern modifier 'debug'\n");
printf(" -dfa set default subject modifier 'dfa'\n");
printf(" -E preprocess input only (#if ... #endif)\n");
+printf(" -echo write the arguments separated by spaces, then exit\n");
printf(" -error show messages for error numbers, then exit\n");
printf(" -help show usage information\n");
printf(" -i set default pattern modifier 'info'\n");
@@ -3658,218 +3652,6 @@ display_selected_modifiers(FALSE, "SUBJECT");
-/*************************************************
-* Helpers for the grep test scripts *
-*************************************************/
-
-/* RunGrepTest and RunGrepTest.bat have to create input files that contain
-exact byte sequences, including bytes that cannot start a UTF-8 character, and
-they also have to filter a stream, changing one byte value into another. On
-Unix-like systems printf(1) and tr(1) do this, but Windows has no dependable
-equivalent: the obvious candidates all translate what they write according to
-the current code page, which mangles any byte greater than 0x7f. As both
-scripts are checked against the same expected output, they need the same
-facilities, so these options provide just enough of printf and tr for
-RunGrepTest.bat to produce exactly the same bytes as RunGrepTest does.
-
-They are needed only by RunGrepTest.bat, so they are built only on Windows.
-They are deliberately undocumented, are not part of pcre2test's interface, and
-may change whenever the test scripts need something different. */
-
-#if defined(_WIN32) || defined(WIN32)
-
-/* Standard input and output are put into binary mode, because the Windows
-default is to turn every LF that passes through into CRLF. */
-
-static void
-helper_binary_io(void)
-{
-_setmode(_fileno(stdin), _O_BINARY);
-_setmode(_fileno(stdout), _O_BINARY);
-}
-
-
-/* Decode an argument that represents a single byte, either as itself or as a
-backslash followed by up to three octal digits. The result is the byte value,
-or -1 if the argument is not one of those things. */
-
-static int
-helper_byte(const char *s)
-{
-if (s[0] == '\\' && s[1] >= '0' && s[1] <= '7')
- {
- int value = 0;
- int i = 0;
- int n = 0;
- while (n < 3 && s[i+1] >= '0' && s[i+1] <= '7')
- {
- value = value * 8 + (s[++i] - '0');
- n++;
- }
- return (s[i+1] == 0 && value <= 255)? value : -1;
- }
-
-return (s[0] != 0 && s[1] == 0)? (unsigned char)s[0] : -1;
-}
-
-
-/* Write the format argument to the standard output, interpreting the escape
-sequences that the test scripts use, and replacing every occurrence of %s with
-the second argument. The escapes are \n, \r, \\ and an octal escape of up to
-three digits. Anything else is written out unchanged, backslash and all, but
-the scripts should not rely on that: a literal backslash, as in a Windows file
-name, is written as \\ so that the format does not depend on which escapes
-happen to be implemented here. */
-
-static int
-helper_printf(int argc, char **argv)
-{
-const char *fmt;
-const char *arg;
-size_t i;
-
-if (argc < 1)
- {
- fprintf(stderr, "pcre2test: -printf needs a format argument\n");
- return 1;
- }
-
-fmt = argv[0];
-arg = (argc > 1)? argv[1] : "";
-
-helper_binary_io();
-
-for (i = 0; fmt[i] != 0; i++)
- {
- if (fmt[i] == '%' && fmt[i+1] == 's')
- {
- fputs(arg, stdout);
- i++;
- }
-
- /* An octal escape of up to three digits, so that \0 gives a binary zero and
- \200 gives a byte that cannot start a UTF-8 character. */
-
- else if (fmt[i] == '\\' && fmt[i+1] >= '0' && fmt[i+1] <= '7')
- {
- int value = 0;
- int n = 0;
- while (n < 3 && fmt[i+1] >= '0' && fmt[i+1] <= '7')
- {
- value = value * 8 + (fmt[++i] - '0');
- n++;
- }
- if (value > 255)
- {
- fprintf(stderr, "pcre2test: -printf octal escape is greater than \\377\n");
- return 1;
- }
- fputc(value, stdout);
- }
-
- else if (fmt[i] == '\\' && fmt[i+1] == 'n') { fputc('\n', stdout); i++; }
- else if (fmt[i] == '\\' && fmt[i+1] == 'r') { fputc('\r', stdout); i++; }
- else if (fmt[i] == '\\' && fmt[i+1] == '\\') { fputc('\\', stdout); i++; }
- else fputc(fmt[i], stdout);
- }
-
-if (fflush(stdout) != 0)
- {
- fprintf(stderr, "pcre2test: -printf write failed: %s\n", strerror(errno));
- return 1;
- }
-
-return 0;
-}
-
-
-/* Copy the standard input to the standard output, changing every occurrence of
-one byte value into another. Both bytes are given in the form that helper_byte()
-accepts. */
-
-static int
-helper_tr(int argc, char **argv)
-{
-int from, to, c;
-
-if (argc < 2)
- {
- fprintf(stderr, "pcre2test: -tr needs two arguments\n");
- return 1;
- }
-
-from = helper_byte(argv[0]);
-to = helper_byte(argv[1]);
-
-if (from < 0 || to < 0)
- {
- fprintf(stderr, "pcre2test: -tr arguments must each be a single byte\n");
- return 1;
- }
-
-helper_binary_io();
-
-while ((c = getchar()) != EOF) putchar((c == from)? to : c);
-
-if (ferror(stdin) || fflush(stdout) != 0)
- {
- fprintf(stderr, "pcre2test: -tr copy failed: %s\n", strerror(errno));
- return 1;
- }
-
-return 0;
-}
-
-
-
-/* Copy the standard input to the standard output, changing every occurrence of
-the three bytes CR, CR, LF into the two bytes CR, LF.
-
-pcre2grep ends each line that it writes with STDOUT_NL, which is CRLF on
-Windows but LF elsewhere, so a line whose own text ends with CR comes out as
-CR CR LF on Windows and as CR LF everywhere else. Comparison normally copes
-with the difference between the two line endings, but not with the extra CR
-that this case produces. Both test scripts are checked against the same
-expected output, so RunGrepTest.bat passes the output of the few tests that
-match a CR at the end of a line through this, and leaves everything else alone.
-A run of CRs that is not at the end of a line is not touched, so a CR that the
-pattern matched in the middle of a line still shows up. */
-
-static int
-helper_fixcrlf(void)
-{
-unsigned long crcount = 0;
-int c;
-
-helper_binary_io();
-
-while ((c = getchar()) != EOF)
- {
- if (c == '\r') { crcount++; continue; }
-
- /* A run of CRs that ends the line has one CR removed; any other run is
- written out unchanged. */
-
- if (c == '\n' && crcount >= 2) crcount--;
- while (crcount > 0) { putchar('\r'); crcount--; }
- putchar(c);
- }
-
-while (crcount > 0) { putchar('\r'); crcount--; }
-
-if (ferror(stdin) || fflush(stdout) != 0)
- {
- fprintf(stderr, "pcre2test: -fixcrlf copy failed: %s\n", strerror(errno));
- return 1;
- }
-
-return 0;
-}
-
-#endif /* Windows */
-
-
-
/*************************************************
* Main Program *
*************************************************/
@@ -3889,18 +3671,6 @@ char *arg_pattern = NULL;
char *arg_error = NULL;
char *env_no_color = getenv("NO_COLOR");
-/* The undocumented helpers for the grep test scripts do none of the work that
-follows, so deal with them before anything is set up. */
-
-#if defined(_WIN32) || defined(WIN32)
-if (argc > 2 && strcmp(argv[1], "-printf") == 0)
- return helper_printf(argc - 2, argv + 2);
-if (argc > 2 && strcmp(argv[1], "-tr") == 0)
- return helper_tr(argc - 2, argv + 2);
-if (argc == 2 && strcmp(argv[1], "-fixcrlf") == 0)
- return helper_fixcrlf();
-#endif
-
/* Get buffers from malloc() so that valgrind will check their misuse when
debugging. They grow automatically when very long lines are read. The 16-
and 32-bit buffers (pbuffer16, pbuffer32) are obtained only if needed. */
@@ -3914,7 +3684,8 @@ I've been told: never having used Windows I take this all on trust. Originally
it set 0x8000, but then I was advised that _O_BINARY was better. */
#if defined(_WIN32) || defined(WIN32)
-_setmode( _fileno( stdout ), _O_BINARY );
+_setmode(_fileno(stdin), _O_BINARY);
+_setmode(_fileno(stdout), _O_BINARY);
#endif
/* Initialization that does not depend on the running mode. */
@@ -3969,6 +3740,17 @@ while (argc > 1 && argv[op][0] == '-' && argv[op][1] != 0)
goto EXIT;
}
+ /* Echo the remaining arguments. This provides a byte-preserving command for
+ testing pcre2grep callout scripts on platforms without a suitable echo. */
+
+ if (strcmp(arg, "-echo") == 0)
+ {
+ for (uint32_t i = op + 1; i < (uint32_t)argc; i++)
+ printf("%s%s", (i == op + 1)? "" : " ", argv[i]);
+ putchar('\n');
+ goto EXIT;
+ }
+
/* Display and/or set return code for configuration options. */
if (strcmp(arg, "-C") == 0)
diff --git a/testdata/grepoutput b/testdata/grepoutput
index 3c8b2f48c..7325c5363 100644
--- a/testdata/grepoutput
+++ b/testdata/grepoutput
@@ -1,21 +1,21 @@
----------------------------- Test 1 ------------------------------
+---------------------------- Test 1 -----------------------------
PATTERN at the start of a line.
In the middle of a line, PATTERN appears.
Check up on PATTERN near the end.
RC=0
----------------------------- Test 2 ------------------------------
+---------------------------- Test 2 -----------------------------
PATTERN at the start of a line.
RC=0
----------------------------- Test 3 ------------------------------
+---------------------------- Test 3 -----------------------------
7:PATTERN at the start of a line.
8:In the middle of a line, PATTERN appears.
10:This pattern is in lower case.
642:Check up on PATTERN near the end.
RC=0
----------------------------- Test 4 ------------------------------
+---------------------------- Test 4 -----------------------------
4
RC=0
----------------------------- Test 5 ------------------------------
+---------------------------- Test 5 -----------------------------
./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.
@@ -24,7 +24,7 @@ RC=0
./testdata/grepinputx:5:Pattern
./testdata/grepinputx:42:This line contains pattern not on a line by itself.
RC=0
----------------------------- Test 6 ------------------------------
+---------------------------- Test 6 -----------------------------
7:PATTERN at the start of a line.
8:In the middle of a line, PATTERN appears.
10:This pattern is in lower case.
@@ -33,14 +33,14 @@ RC=0
5:Pattern
42:This line contains pattern not on a line by itself.
RC=0
----------------------------- Test 7 ------------------------------
+---------------------------- Test 7 -----------------------------
./testdata/grepinput
./testdata/grepinputx
RC=0
----------------------------- Test 8 ------------------------------
+---------------------------- Test 8 -----------------------------
./testdata/grepinput
RC=0
----------------------------- Test 9 ------------------------------
+---------------------------- Test 9 -----------------------------
RC=0
---------------------------- Test 10 -----------------------------
RC=1
@@ -395,46 +395,46 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
pcre2grep: Error -46, -47, -53 or -63 means that a resource limit was exceeded.
pcre2grep: Check your regex for nested unlimited loops.
----------------------------- Test 38 ------------------------------
+---------------------------- Test 38 -----------------------------
This line contains a binary zero here > < for testing.
RC=0
----------------------------- Test 39 ------------------------------
+---------------------------- Test 39 -----------------------------
This is a line before the binary zero.
This line contains a binary zero here > < for testing.
RC=0
----------------------------- Test 40 ------------------------------
+---------------------------- Test 40 -----------------------------
This line contains a binary zero here > < for testing.
This is a line after the binary zero.
RC=0
----------------------------- Test 41 ------------------------------
+---------------------------- Test 41 -----------------------------
before the binary zero
after the binary zero
RC=0
----------------------------- Test 42 ------------------------------
+---------------------------- Test 42 -----------------------------
./testdata/grepinput:595:before the binary zero
./testdata/grepinput:597:after the binary zero
RC=0
----------------------------- Test 43 ------------------------------
+---------------------------- Test 43 -----------------------------
595:before
595:zero
596:zero
597:after
597:zero
RC=0
----------------------------- Test 44 ------------------------------
+---------------------------- Test 44 -----------------------------
595:before
595:zero
596:zero
597:after
597:zero
RC=0
----------------------------- Test 45 ------------------------------
+---------------------------- Test 45 -----------------------------
10:pattern
595:binary
596:binary
597:binary
RC=0
----------------------------- Test 46 ------------------------------
+---------------------------- Test 46 -----------------------------
pcre2grep: Error in 1st command-line regex at offset 9: unmatched closing parenthesis
RC=2
pcre2grep: Error in 2nd command-line regex at offset 9: missing closing parenthesis
@@ -443,23 +443,23 @@ pcre2grep: Error in 3rd command-line regex at offset 9: missing terminating ] fo
RC=2
pcre2grep: Error in 4th command-line regex at offset 9: missing terminating ] for character class
RC=2
----------------------------- Test 47 ------------------------------
+---------------------------- Test 47 -----------------------------
AB.VE
RC=0
----------------------------- Test 48 ------------------------------
+---------------------------- Test 48 -----------------------------
ABOVE the elephant
AB.VE
AB.VE the turtle
RC=0
----------------------------- Test 49 ------------------------------
+---------------------------- Test 49 -----------------------------
ABOVE the elephant
AB.VE
AB.VE the turtle
PUT NEW DATA ABOVE THIS LINE.
RC=0
----------------------------- Test 50 ------------------------------
+---------------------------- Test 50 -----------------------------
RC=1
----------------------------- Test 51 ------------------------------
+---------------------------- Test 51 -----------------------------
over the lazy dog.
This time it jumps and jumps and jumps.
This line contains \E and (regex) *meta* [characters].
@@ -469,18 +469,18 @@ The snowcat is not an animal
A buried feline in the syndicate
trailing spaces
RC=0
----------------------------- Test 52 ------------------------------
+---------------------------- Test 52 -----------------------------
fox [1;31mjumps[0m
This time it [1;31mjumps[0m and [1;31mjumps[0m and [1;31mjumps[0m.
RC=0
----------------------------- Test 53 ------------------------------
+---------------------------- Test 53 -----------------------------
36976,6
36994,4
37028,4
37070,5
37087,4
RC=0
----------------------------- Test 54 ------------------------------
+---------------------------- Test 54 -----------------------------
595:15,6
595:33,4
596:28,4
@@ -547,17 +547,17 @@ that the pcregrep command is working correctly. The file must be more than
pcre2grep: Error -46, -47, -53 or -63 means that a resource limit was exceeded.
pcre2grep: Check your regex for nested unlimited loops.
RC=1
----------------------------- Test 64 ------------------------------
+---------------------------- Test 64 -----------------------------
appears
RC=0
----------------------------- Test 65 ------------------------------
+---------------------------- Test 65 -----------------------------
pear
RC=0
----------------------------- Test 66 ------------------------------
+---------------------------- Test 66 -----------------------------
RC=0
----------------------------- Test 67 ------------------------------
+---------------------------- Test 67 -----------------------------
RC=0
----------------------------- Test 68 ------------------------------
+---------------------------- Test 68 -----------------------------
pear
RC=0
---------------------------- Test 69 -----------------------------
@@ -743,12 +743,12 @@ RC=0
./testdata/grepinput3
./testdata/grepinputx
RC=0
----------------------------- Test 100 ------------------------------
+---------------------------- Test 100 -----------------------------
./testdata/grepinput:zerothe.
./testdata/grepinput:zeroa
./testdata/grepinput:zerothe.
RC=0
----------------------------- Test 101 ------------------------------
+---------------------------- Test 101 -----------------------------
./testdata/grepinput:[1;31m.[0m|[1;31mzero[0m|[1;31mthe[0m|[1;31m.[0m
./testdata/grepinput:[1;31mzero[0m|[1;31ma[0m
./testdata/grepinput:[1;31m.[0m|[1;31mzero[0m|[1;31mthe[0m|[1;31m.[0m
@@ -799,7 +799,7 @@ RC=0
2:3,1
2:4,1
RC=0
----------------------------- Test 108 ------------------------------
+---------------------------- Test 108 -----------------------------
RC=0
---------------------------- Test 109 -----------------------------
RC=0
@@ -888,7 +888,7 @@ def
xyz
---
RC=0
----------------------------- Test 120 ------------------------------
+---------------------------- Test 120 -----------------------------
./testdata/grepinput:the binary zero.:zerothe.
./testdata/grepinput:a binary zero:zeroa
./testdata/grepinput:the binary zero.:zerothe.
@@ -1016,6 +1016,7 @@ match 1:
a
match 2:
b
+RC=0
---
a
RC=0
@@ -1024,6 +1025,7 @@ match 1:
a
match 2:
b
+RC=0
---
match 2:
b
diff --git a/testdata/grepoutput8 b/testdata/grepoutput8
index bc34d8ec8..b8579a1d4 100644
--- a/testdata/grepoutput8
+++ b/testdata/grepoutput8
@@ -1,16 +1,16 @@
----------------------------- Test U1 ------------------------------
+---------------------------- Test U1 -----------------------------
1:X one
2:X two3:X three4:X four
5:X five
6:X six
7:X seven
8:X eight
9:X nine
10:X ten
RC=0
----------------------------- Test U2 ------------------------------
+---------------------------- Test U2 -----------------------------
12-Before 111
13-Before 222
14-Before 333
15:Match
16-After 111
17-After 222
18-After 333
RC=0
----------------------------- Test U3 ------------------------------
+---------------------------- Test U3 -----------------------------
21:0,2
22:0,2
22:2,2
@@ -18,7 +18,7 @@ RC=0
22:6,2
22:8,2
RC=0
----------------------------- Test U4 ------------------------------
+---------------------------- Test U4 -----------------------------
pcre2grep: pcre2_match() gave error -22 while matching this text:
AကCD Z
@@ -26,33 +26,33 @@ Aက
UTF-8 error: isolated byte with 0x80 bit set at offset 4
RC=1
----------------------------- Test U5 ------------------------------
+---------------------------- Test U5 -----------------------------
CD Z
RC=0
---------------------------- Test U6 -----------------------------
=ǓǤ=
RC=0
----------------------------- Test U7 ------------------------------
+---------------------------- Test U7 -----------------------------
ÁabcÁ [1;31mKkK[0m
RC=0
----------------------------- Test U8 ------------------------------
+---------------------------- Test U8 -----------------------------
Á[1;31mabc[0mÁ [1;31mKk[0mK
RC=0
----------------------------- Test U9 ------------------------------
+---------------------------- Test U9 -----------------------------
[1;31mA1[0m
[1;31mA1[0m
RC=0
----------------------------- Test U10 ------------------------------
+---------------------------- Test U10 -----------------------------
[1;31mA1[0m
RC=0
----------------------------- Test U11 ------------------------------
+---------------------------- Test U11 -----------------------------
x
only-matching RC=0
x
multiline RC=0
[1;31mx[0m
colour RC=0
----------------------------- Test U12 ------------------------------
+---------------------------- Test U12 -----------------------------
1:abc
colour-empty-at-end RC=0
1:[1;31ma[0m[1;31mb[0m[1;31mc[0m
@@ -118,7 +118,7 @@ b[0m
3:
multiline-colour-utf-trailing-spanning RC=0
----------------------------- Test U13 ------------------------------
+---------------------------- Test U13 -----------------------------
1:[1;31ma[0m[1;31mb[0m[1;31mc[0m
colour-bsk RC=0
1:a
@@ -131,7 +131,7 @@ multiline-bsk-utf-scan-to-end RC=0
1:[1;31ma[0m
2:[1;31mx[0m
multiline-colour-bsk-utf-trailing RC=0
----------------------------- Test U14 ------------------------------
+---------------------------- Test U14 -----------------------------
1:ab
1:ab
control-progress RC=0
diff --git a/testdata/grepoutputN b/testdata/grepoutputN
index 4ee87e66e..05beae9b3 100644
--- a/testdata/grepoutputN
+++ b/testdata/grepoutputN
@@ -1,7 +1,7 @@
----------------------------- Test N1 ------------------------------
+---------------------------- Test N1 -----------------------------
1:abc
2:def
RC=0
1-abc
2:def
RC=0
----------------------------- Test N2 ------------------------------
+---------------------------- Test N2 -----------------------------
1:abc
def
2:ghi
jkl
@@ -10,22 +10,22 @@ RC=0
2:ghi
jkl
RC=0
----------------------------- Test N3 ------------------------------
+---------------------------- Test N3 -----------------------------
2:def
3:
ghi
jkl
RC=0
----------------------------- Test N4 ------------------------------
+---------------------------- Test N4 -----------------------------
2:ghi
jkl
RC=0
----------------------------- Test N5 ------------------------------
+---------------------------- Test N5 -----------------------------
1:abc
2:def
3:ghi
4:jkl
RC=0
1-abc
2:def
RC=0
----------------------------- Test N6 ------------------------------
+---------------------------- Test N6 -----------------------------
1:abc
2:def
3:ghi
4:jkl
@@ -33,10 +33,10 @@ RC=0
3-ghi
4:jkl
RC=0
----------------------------- Test N7 ------------------------------
+---------------------------- Test N7 -----------------------------
2:abc@3:def@RC=0
1-xyz@2:abc@3:def@RC=0
----------------------------- Test N8 ------------------------------
+---------------------------- Test N8 -----------------------------
1:abc
RC=0
diff --git a/testdata/grepoutputUN b/testdata/grepoutputUN
index ff318cc15..09c915846 100644
--- a/testdata/grepoutputUN
+++ b/testdata/grepoutputUN
@@ -1,4 +1,7 @@
----------------------------- Test UN2 ------------------------------
+---------------------------- Test UN1 -----------------------------
+1:abcሴdef
+RC=0
+---------------------------- Test UN2 -----------------------------
1:abc
RC=0
diff --git a/testdata/testinput2 b/testdata/testinput2
index 55b5c7289..413214ca6 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -8384,12 +8384,4 @@ a)"xI
abc\=ps,substitute_replacement_only,replace=>$_<
abc\=ps,substitute_replacement_only,replace=>$'<
-# 'getall' must not walk the substring list past its NULL terminator when
-# 'allcaptures' or 'allvector' has widened the reported capture count beyond the
-# number of pairs the match actually returned.
-
-/(a)|(b)/
- a\=getall,allcaptures
- a\=getall,allvector,ovector=4
-
# End of testinput2
diff --git a/testdata/testinput8 b/testdata/testinput8
index 64eeded52..550631db6 100644
--- a/testdata/testinput8
+++ b/testdata/testinput8
@@ -186,9 +186,4 @@
/\[()]{65535}/expand
-# This expansion fills pbuffer8 to exactly its default size, checking that the
-# growth loop leaves room for the terminating zero written after it.
-
-/\[a]{50000}/expand
-
# End of testinput8
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 76fb2b724..897c026d9 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -23769,25 +23769,6 @@ Failed: error -76 at offset 3 in replacement: replacement $' or $_ not supported
Failed: error -76 at offset 3 in replacement: replacement $' or $_ not supported with partial match
here: >$' |<--| <
-# 'getall' must not walk the substring list past its NULL terminator when
-# 'allcaptures' or 'allvector' has widened the reported capture count beyond the
-# number of pairs the match actually returned.
-
-/(a)|(b)/
- a\=getall,allcaptures
- 0: a
- 1: a
- 2:
- 0L a
- 1L a
- a\=getall,allvector,ovector=4
- 0: a
- 1: a
- 2:
- 3:
- 0L a
- 1L a
-
# End of testinput2
Error -80: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data
diff --git a/testdata/testoutput3D b/testdata/testoutput3D
index c2242efe4..f78b129ae 100644
--- a/testdata/testoutput3D
+++ b/testdata/testoutput3D
@@ -82,11 +82,12 @@ Subject length lower bound = 1
Capture group count = 0
Starting code units: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
- \xb5 \xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd
- \xce \xcf \xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd8 \xd9 \xda \xdb \xdc \xdd
- \xde \xdf \xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec
- \xed \xee \xef \xf0 \xf1 \xf2 \xf3 \xf4 \xf5 \xf6 \xf8 \xf9 \xfa \xfb \xfc
- \xfd \xfe \xff
+ \x83 \x8a \x8c \x8e \x9a \x9c \x9e \x9f \xaa \xb2 \xb3 \xb5 \xb9 \xba \xc0
+ \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf
+ \xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf
+ \xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee
+ \xef \xf0 \xf1 \xf2 \xf3 \xf4 \xf5 \xf6 \xf8 \xf9 \xfa \xfb \xfc \xfd \xfe
+ \xff
Subject length lower bound = 1
# All remaining tests are in the fr_FR locale, so set the default.
@@ -127,56 +128,57 @@ No match
/\W+/
>>>\xaa<<<
- 0: >>>\xaa<<<
+ 0: >>>
>>>\xba<<<
- 0: >>>\xba<<<
+ 0: >>>
/[\W]+/
>>>\xaa<<<
- 0: >>>\xaa<<<
+ 0: >>>
>>>\xba<<<
- 0: >>>\xba<<<
+ 0: >>>
/[^[:alpha:]]+/
>>>\xaa<<<
- 0: >>>\xaa<<<
+ 0: >>>
>>>\xba<<<
- 0: >>>\xba<<<
+ 0: >>>
/\w+/
>>>\xaa<<<
-No match
+ 0: \xaa
>>>\xba<<<
-No match
+ 0: \xba
/[\w]+/
>>>\xaa<<<
-No match
+ 0: \xaa
>>>\xba<<<
-No match
+ 0: \xba
/[[:alpha:]]+/
>>>\xaa<<<
-No match
+ 0: \xaa
>>>\xba<<<
-No match
+ 0: \xba
/[[:alpha:]][[:lower:]][[:upper:]]/IB
------------------------------------------------------------------
Bra
- [A-Za-z\xb5\xc0-\xd6\xd8-\xf6\xf8-\xff]
- [a-z\xb5\xdf-\xf6\xf8-\xff]
- [A-Z\xc0-\xd6\xd8-\xde]
+ [A-Za-z\x83\x8a\x8c\x8e\x9a\x9c\x9e\x9f\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\xff]
+ [a-z\x83\x9a\x9c\x9e\xaa\xb5\xba\xdf-\xf6\xf8-\xff]
+ [A-Z\x8a\x8c\x8e\x9f\xc0-\xd6\xd8-\xde]
Ket
End
------------------------------------------------------------------
Capture group count = 0
Starting code units: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
- a b c d e f g h i j k l m n o p q r s t u v w x y z \xb5 \xc0 \xc1 \xc2 \xc3
- \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf \xd0 \xd1 \xd2
- \xd3 \xd4 \xd5 \xd6 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf \xe0 \xe1 \xe2
- \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee \xef \xf0 \xf1
- \xf2 \xf3 \xf4 \xf5 \xf6 \xf8 \xf9 \xfa \xfb \xfc \xfd \xfe \xff
+ a b c d e f g h i j k l m n o p q r s t u v w x y z \x83 \x8a \x8c \x8e \x9a
+ \x9c \x9e \x9f \xaa \xb5 \xba \xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8
+ \xc9 \xca \xcb \xcc \xcd \xce \xcf \xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd8
+ \xd9 \xda \xdb \xdc \xdd \xde \xdf \xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7
+ \xe8 \xe9 \xea \xeb \xec \xed \xee \xef \xf0 \xf1 \xf2 \xf3 \xf4 \xf5 \xf6
+ \xf8 \xf9 \xfa \xfb \xfc \xfd \xfe \xff
Subject length lower bound = 3
# End of testinput3
diff --git a/testdata/wintestoutput3 b/testdata/testoutput3E
similarity index 79%
rename from testdata/wintestoutput3
rename to testdata/testoutput3E
index 28cb3889c..e857c901c 100644
--- a/testdata/wintestoutput3
+++ b/testdata/testoutput3E
@@ -12,7 +12,7 @@
cole
No match
-/^[\w]+/locale=french
+/^[\w]+/locale=fr_FR
cole
0: \xc9cole
@@ -20,7 +20,7 @@ No match
cole
0: \xc9
-/^[\W]+/locale=french
+/^[\W]+/locale=fr_FR
\= Expect no match
cole
No match
@@ -32,7 +32,7 @@ No match
a
No match
-/[\b]/locale=french
+/[\b]/locale=fr_FR
\b
0: \x08
\= Expect no match
@@ -44,7 +44,7 @@ No match
cole
No match
-/^\w+/locale=french
+/^\w+/locale=fr_FR
cole
0: \xc9cole
@@ -54,7 +54,7 @@ No match
1: \xc9
2: cole
-/(.+)\b(.+)/locale=french
+/(.+)\b(.+)/locale=fr_FR
\= Expect no match
cole
No match
@@ -66,7 +66,7 @@ No match
cole
No match
-/cole/i,locale=french
+/cole/i,locale=fr_FR
cole
0: \xc9cole
cole
@@ -78,7 +78,7 @@ Starting code units: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
Subject length lower bound = 1
-/\w/I,locale=french
+/\w/I,locale=fr_FR
Capture group count = 0
Starting code units: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
@@ -90,9 +90,9 @@ Starting code units: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
\xff
Subject length lower bound = 1
-# All remaining tests are in the french locale, so set the default.
+# All remaining tests are in the fr_FR locale, so set the default.
-#pattern locale=french
+#pattern locale=fr_FR
/^[\xc8-\xc9]/i
cole
@@ -103,7 +103,7 @@ Subject length lower bound = 1
/^[\xc8-\xc9]/
cole
0: \xc9
-\= Expect no match
+\= Expect no match
cole
No match
@@ -165,7 +165,7 @@ No match
/[[:alpha:]][[:lower:]][[:upper:]]/IB
------------------------------------------------------------------
Bra
- [A-Za-z\x83\x8a\x8c\x8e\x9a\x9c\x9e\x9f\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\xff]
+ [A-Za-z\x83\x8a\x8c\x8e\x9a\x9c\x9e\x9f\xaa\xb2\xb3\xb5\xb9\xba\xc0-\xd6\xd8-\xf6\xf8-\xff]
[a-z\x83\x9a\x9c\x9e\xaa\xb5\xba\xdf-\xf6\xf8-\xff]
[A-Z\x8a\x8c\x8e\x9f\xc0-\xd6\xd8-\xde]
Ket
@@ -174,11 +174,11 @@ No match
Capture group count = 0
Starting code units: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z \x83 \x8a \x8c \x8e \x9a
- \x9c \x9e \x9f \xaa \xb5 \xba \xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8
- \xc9 \xca \xcb \xcc \xcd \xce \xcf \xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd8
- \xd9 \xda \xdb \xdc \xdd \xde \xdf \xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7
- \xe8 \xe9 \xea \xeb \xec \xed \xee \xef \xf0 \xf1 \xf2 \xf3 \xf4 \xf5 \xf6
- \xf8 \xf9 \xfa \xfb \xfc \xfd \xfe \xff
+ \x9c \x9e \x9f \xaa \xb2 \xb3 \xb5 \xb9 \xba \xc0 \xc1 \xc2 \xc3 \xc4 \xc5
+ \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf \xd0 \xd1 \xd2 \xd3 \xd4
+ \xd5 \xd6 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf \xe0 \xe1 \xe2 \xe3 \xe4
+ \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee \xef \xf0 \xf1 \xf2 \xf3
+ \xf4 \xf5 \xf6 \xf8 \xf9 \xfa \xfb \xfc \xfd \xfe \xff
Subject length lower bound = 3
-# End of wintestinput3
+# End of testinput3
diff --git a/testdata/testoutput3F b/testdata/testoutput3F
new file mode 100644
index 000000000..c2242efe4
--- /dev/null
+++ b/testdata/testoutput3F
@@ -0,0 +1,182 @@
+# This set of tests checks local-specific features, using the "fr_FR" locale.
+# It is almost Perl-compatible. When run via RunTest, the locale is edited to
+# be whichever of "fr_FR", "french", or "fr" is found to exist. There is
+# different version of this file called wintestinput3 for use on Windows,
+# where the locale is called "french" and the tests are run using
+# RunTest.bat.
+
+#forbid_utf
+
+/^[\w]+/
+\= Expect no match
+ cole
+No match
+
+/^[\w]+/locale=fr_FR
+ cole
+ 0: \xc9cole
+
+/^[\W]+/
+ cole
+ 0: \xc9
+
+/^[\W]+/locale=fr_FR
+\= Expect no match
+ cole
+No match
+
+/[\b]/
+ \b
+ 0: \x08
+\= Expect no match
+ a
+No match
+
+/[\b]/locale=fr_FR
+ \b
+ 0: \x08
+\= Expect no match
+ a
+No match
+
+/^\w+/
+\= Expect no match
+ cole
+No match
+
+/^\w+/locale=fr_FR
+ cole
+ 0: \xc9cole
+
+/(.+)\b(.+)/
+ cole
+ 0: \xc9cole
+ 1: \xc9
+ 2: cole
+
+/(.+)\b(.+)/locale=fr_FR
+\= Expect no match
+ cole
+No match
+
+/cole/i
+ cole
+ 0: \xc9cole
+\= Expect no match
+ cole
+No match
+
+/cole/i,locale=fr_FR
+ cole
+ 0: \xc9cole
+ cole
+ 0: \xe9cole
+
+/\w/I
+Capture group count = 0
+Starting code units: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
+ Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
+Subject length lower bound = 1
+
+/\w/I,locale=fr_FR
+Capture group count = 0
+Starting code units: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
+ Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
+ \xb5 \xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd
+ \xce \xcf \xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd8 \xd9 \xda \xdb \xdc \xdd
+ \xde \xdf \xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec
+ \xed \xee \xef \xf0 \xf1 \xf2 \xf3 \xf4 \xf5 \xf6 \xf8 \xf9 \xfa \xfb \xfc
+ \xfd \xfe \xff
+Subject length lower bound = 1
+
+# All remaining tests are in the fr_FR locale, so set the default.
+
+#pattern locale=fr_FR
+
+/^[\xc8-\xc9]/i
+ cole
+ 0: \xc9
+ cole
+ 0: \xe9
+
+/^[\xc8-\xc9]/
+ cole
+ 0: \xc9
+\= Expect no match
+ cole
+No match
+
+/\xb5/i
+
+ 0: \xb5
+\= Expect no match
+ \x9c
+No match
+
+//i
+ \xff
+ 0: \xff
+\= Expect no match
+ y
+No match
+
+/(.)\1/i
+ \xfe\xde
+ 0: \xfe\xde
+ 1: \xfe
+
+/\W+/
+ >>>\xaa<<<
+ 0: >>>\xaa<<<
+ >>>\xba<<<
+ 0: >>>\xba<<<
+
+/[\W]+/
+ >>>\xaa<<<
+ 0: >>>\xaa<<<
+ >>>\xba<<<
+ 0: >>>\xba<<<
+
+/[^[:alpha:]]+/
+ >>>\xaa<<<
+ 0: >>>\xaa<<<
+ >>>\xba<<<
+ 0: >>>\xba<<<
+
+/\w+/
+ >>>\xaa<<<
+No match
+ >>>\xba<<<
+No match
+
+/[\w]+/
+ >>>\xaa<<<
+No match
+ >>>\xba<<<
+No match
+
+/[[:alpha:]]+/
+ >>>\xaa<<<
+No match
+ >>>\xba<<<
+No match
+
+/[[:alpha:]][[:lower:]][[:upper:]]/IB
+------------------------------------------------------------------
+ Bra
+ [A-Za-z\xb5\xc0-\xd6\xd8-\xf6\xf8-\xff]
+ [a-z\xb5\xdf-\xf6\xf8-\xff]
+ [A-Z\xc0-\xd6\xd8-\xde]
+ Ket
+ End
+------------------------------------------------------------------
+Capture group count = 0
+Starting code units: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
+ a b c d e f g h i j k l m n o p q r s t u v w x y z \xb5 \xc0 \xc1 \xc2 \xc3
+ \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf \xd0 \xd1 \xd2
+ \xd3 \xd4 \xd5 \xd6 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf \xe0 \xe1 \xe2
+ \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee \xef \xf0 \xf1
+ \xf2 \xf3 \xf4 \xf5 \xf6 \xf8 \xf9 \xfa \xfb \xfc \xfd \xfe \xff
+Subject length lower bound = 3
+
+# End of testinput3
diff --git a/testdata/testoutput8-16-2 b/testdata/testoutput8-16-2
index 3f0222bd7..c16e46640 100644
--- a/testdata/testoutput8-16-2
+++ b/testdata/testoutput8-16-2
@@ -1022,10 +1022,4 @@ Failed: error 114 at offset 509: missing closing parenthesis
/\[()]{65535}/expand
Failed: error 120 at offset 0: regular expression is too large
-# This expansion fills pbuffer8 to exactly its default size, checking that the
-# growth loop leaves room for the terminating zero written after it.
-
-/\[a]{50000}/expand
-Failed: error 120 at offset 0: regular expression is too large
-
# End of testinput8
diff --git a/testdata/testoutput8-16-4 b/testdata/testoutput8-16-4
index 38696c245..e3f30dfa1 100644
--- a/testdata/testoutput8-16-4
+++ b/testdata/testoutput8-16-4
@@ -1019,9 +1019,4 @@ Failed: error 114 at offset 509: missing closing parenthesis
/\[()]{65535}/expand
-# This expansion fills pbuffer8 to exactly its default size, checking that the
-# growth loop leaves room for the terminating zero written after it.
-
-/\[a]{50000}/expand
-
# End of testinput8
diff --git a/testdata/testoutput8-32-4 b/testdata/testoutput8-32-4
index 8ea942755..76486540b 100644
--- a/testdata/testoutput8-32-4
+++ b/testdata/testoutput8-32-4
@@ -1019,9 +1019,4 @@ Failed: error 114 at offset 509: missing closing parenthesis
/\[()]{65535}/expand
-# This expansion fills pbuffer8 to exactly its default size, checking that the
-# growth loop leaves room for the terminating zero written after it.
-
-/\[a]{50000}/expand
-
# End of testinput8
diff --git a/testdata/testoutput8-8-2 b/testdata/testoutput8-8-2
index 176489d2e..23da6cbb7 100644
--- a/testdata/testoutput8-8-2
+++ b/testdata/testoutput8-8-2
@@ -1022,10 +1022,4 @@ Failed: error 114 at offset 509: missing closing parenthesis
/\[()]{65535}/expand
Failed: error 120 at offset 0: regular expression is too large
-# This expansion fills pbuffer8 to exactly its default size, checking that the
-# growth loop leaves room for the terminating zero written after it.
-
-/\[a]{50000}/expand
-Failed: error 120 at offset 0: regular expression is too large
-
# End of testinput8
diff --git a/testdata/testoutput8-8-3 b/testdata/testoutput8-8-3
index aa4674560..0fa59f95a 100644
--- a/testdata/testoutput8-8-3
+++ b/testdata/testoutput8-8-3
@@ -1019,9 +1019,4 @@ Failed: error 114 at offset 509: missing closing parenthesis
/\[()]{65535}/expand
-# This expansion fills pbuffer8 to exactly its default size, checking that the
-# growth loop leaves room for the terminating zero written after it.
-
-/\[a]{50000}/expand
-
# End of testinput8
diff --git a/testdata/testoutput8-8-4 b/testdata/testoutput8-8-4
index d24af60db..c6adb1650 100644
--- a/testdata/testoutput8-8-4
+++ b/testdata/testoutput8-8-4
@@ -1019,9 +1019,4 @@ Failed: error 114 at offset 509: missing closing parenthesis
/\[()]{65535}/expand
-# This expansion fills pbuffer8 to exactly its default size, checking that the
-# growth loop leaves room for the terminating zero written after it.
-
-/\[a]{50000}/expand
-
# End of testinput8
diff --git a/testdata/wintestinput3 b/testdata/wintestinput3
deleted file mode 100644
index 15580cfb3..000000000
--- a/testdata/wintestinput3
+++ /dev/null
@@ -1,113 +0,0 @@
-# This set of tests checks local-specific features, using the "fr_FR" locale.
-# It is almost Perl-compatible. When run via RunTest, the locale is edited to
-# be whichever of "fr_FR", "french", or "fr" is found to exist. There is
-# different version of this file called wintestinput3 for use on Windows,
-# where the locale is called "french" and the tests are run using
-# RunTest.bat.
-
-#forbid_utf
-
-/^[\w]+/
-\= Expect no match
- cole
-
-/^[\w]+/locale=french
- cole
-
-/^[\W]+/
- cole
-
-/^[\W]+/locale=french
-\= Expect no match
- cole
-
-/[\b]/
- \b
-\= Expect no match
- a
-
-/[\b]/locale=french
- \b
-\= Expect no match
- a
-
-/^\w+/
-\= Expect no match
- cole
-
-/^\w+/locale=french
- cole
-
-/(.+)\b(.+)/
- cole
-
-/(.+)\b(.+)/locale=french
-\= Expect no match
- cole
-
-/cole/i
- cole
-\= Expect no match
- cole
-
-/cole/i,locale=french
- cole
- cole
-
-/\w/I
-
-/\w/I,locale=french
-
-# All remaining tests are in the french locale, so set the default.
-
-#pattern locale=french
-
-/^[\xc8-\xc9]/i
- cole
- cole
-
-/^[\xc8-\xc9]/
- cole
-\= Expect no match
- cole
-
-/\xb5/i
-
-\= Expect no match
- \x9c
-
-//i
- \xff
-\= Expect no match
- y
-
-/(.)\1/i
- \xfe\xde
-
-/\W+/
- >>>\xaa<<<
- >>>\xba<<<
-
-/[\W]+/
- >>>\xaa<<<
- >>>\xba<<<
-
-/[^[:alpha:]]+/
- >>>\xaa<<<
- >>>\xba<<<
-
-/\w+/
- >>>\xaa<<<
- >>>\xba<<<
-
-/[\w]+/
- >>>\xaa<<<
- >>>\xba<<<
-
-/[[:alpha:]]+/
- >>>\xaa<<<
- >>>\xba<<<
-
-/[[:alpha:]][[:lower:]][[:upper:]]/IB
-
-# End of wintestinput3