diff options
author | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2021-02-07 16:43:00 +0000 |
---|---|---|
committer | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2021-02-07 16:43:00 +0000 |
commit | ca7130d4206da26d8655a3630f7b782399f01a47 (patch) | |
tree | f620fdf10a43e2143ea64f3fd1529fca9d32f55b | |
parent | 6ed9cb2f9e9b0f87f9d2823e0ed8c1911f43cd39 (diff) | |
download | pcre2-ca7130d4206da26d8655a3630f7b782399f01a47.tar.gz |
Fix RunGrepTest's handling of binary zeros on Solaris by using /usr/xpg4/bin/tr
instead of tr if /usr/xpg4/bin/tr exists.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1299 6239d852-aaf2-0410-a92c-79f79f948069
-rw-r--r-- | ChangeLog | 5 | ||||
-rwxr-xr-x | RunGrepTest | 23 |
2 files changed, 20 insertions, 8 deletions
@@ -7,7 +7,10 @@ Version 10.37-RC1 04-January-2021 1. Change RunGrepTest to use tr instead of sed when testing with binary zero bytes, because sed varies a lot from system to system and has problems with binary zeros. This is from Bugzilla #2681. Patch from Jeremie -Courreges-Anglas via Nam Nguyen. This fixes RunGrepTest for OpenBSD. +Courreges-Anglas via Nam Nguyen. This fixes RunGrepTest for OpenBSD. Later: +it broke it for at least one version of Solaris, where tr can't handle binary +zeros. However, that system had /usr/xpg4/bin/tr installed, which works OK, so +RunGrepTest now checks for that command and use it if found. 2. Compiling with gcc 10.2's -fanalyzer option showed up a hypothetical problem with a NULL dereference. I don't think this case could ever occur in practice, diff --git a/RunGrepTest b/RunGrepTest index 1e319c9..78206ba 100755 --- a/RunGrepTest +++ b/RunGrepTest @@ -755,16 +755,25 @@ $valgrind $vjs $pcre2grep -n --newline=any "^(abc|def|ghi|jkl)" testNinputgrep > printf '%c--------------------------- Test N6 ------------------------------\r\n' - >>testtrygrep $valgrind $vjs $pcre2grep -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep -# It seems impossible to handle NUL characters easily in many operating -# systems, including Solaris (aka SunOS), where the version of sed explicitly -# doesn't like them, and also MacOS (Darwin), OpenBSD, FreeBSD, NetBSD, and -# some Linux distributions like Alpine, even when using GNU sed, so test for -# a usable sed and fudge the output so that the comparison works when sed -# doesn't. +# This next test involves NUL characters. It seems impossible to handle them +# easily in many operating systems. An earlier version of this script used sed +# to translate NUL into the string ZERO, but this didn't work on Solaris (aka +# SunOS), where the version of sed explicitly doesn't like them, and also MacOS +# (Darwin), OpenBSD, FreeBSD, NetBSD, and some Linux distributions like Alpine, +# even when using GNU sed. A user suggested using tr instead, which +# necessitates translating to a single character (@). However, on (some +# versions of?) Solaris, the normal "tr" cannot handle binary zeros, but if +# /usr/xpg4/bin/tr is available, it can do so, so test for that. + +if [ -x /usr/xpg4/bin/tr ] ; then + tr=/usr/xpg4/bin/tr +else + tr=tr +fi printf '%c--------------------------- Test N7 ------------------------------\r\n' - >>testtrygrep printf 'abc\0def' >testNinputgrep -$valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep | tr '\000' '@' >>testtrygrep +$valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep | $tr '\000' '@' >>testtrygrep echo "" >>testtrygrep $cf $srcdir/testdata/grepoutputN testtrygrep |