Fix binary zero issue (Bugzilla #2628) in RunGrepTest.

This commit is contained in:
Philip.Hazel 2020-10-09 15:25:27 +00:00
parent 6d4936dc29
commit 92554d19aa
2 changed files with 16 additions and 14 deletions

View File

@ -86,6 +86,10 @@ everywhere, which was not previously the case. At the same time, the escape
sequences $x{...} and $o{...} have been introduced, to allow for characters sequences $x{...} and $o{...} have been introduced, to allow for characters
whose code points are greater than 255 in Unicode mode. whose code points are greater than 255 in Unicode mode.
17. Applied the patch from Bugzilla #2628 to RunGrepTest. This does an explicit
test for a version of sed that can handle binary zero, instead of assuming that
any Linux version will work.
Version 10.35 09-May-2020 Version 10.35 09-May-2020
--------------------------- ---------------------------

View File

@ -757,22 +757,20 @@ $valgrind $vjs $pcre2grep -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinputgr
# It seems impossible to handle NUL characters easily in many operating # It seems impossible to handle NUL characters easily in many operating
# systems, including Solaris (aka SunOS), where the version of sed explicitly # systems, including Solaris (aka SunOS), where the version of sed explicitly
# doesn't like them, and also MacOS (Darwin), OpenBSD, FreeBSD, and NetBSD. So # doesn't like them, and also MacOS (Darwin), OpenBSD, FreeBSD, NetBSD, and
# now we run this test only on OS that are known to work. For the rest, we # some Linux distributions like Alpine, even when using GNU sed, so test for
# fudge the output so that the comparison works. # a usable sed and fudge the output so that the comparison works when sed
# doesn't.
printf '%c--------------------------- Test N7 ------------------------------\r\n' - >>testtrygrep printf '%c--------------------------- Test N7 ------------------------------\r\n' - >>testtrygrep
uname=`uname` Z=$(printf '\0' | sed 's/\x00/Z/g')
case $uname in if [ "$Z" = "Z" ]; then
Linux)
printf 'abc\0def' >testNinputgrep printf 'abc\0def' >testNinputgrep
$valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep | sed 's/\x00/ZERO/g' >>testtrygrep $valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep | sed 's/\x00/ZERO/g' >>testtrygrep
echo "" >>testtrygrep echo "" >>testtrygrep
;; else
*)
echo '1:abcZERO2:defZERO' >>testtrygrep echo '1:abcZERO2:defZERO' >>testtrygrep
;; fi
esac
$cf $srcdir/testdata/grepoutputN testtrygrep $cf $srcdir/testdata/grepoutputN testtrygrep
if [ $? != 0 ] ; then exit 1; fi if [ $? != 0 ] ; then exit 1; fi