On Thu, May 02 2019, Jeremie Courreges-Anglas <j...@wxcvbn.org> wrote:
[...] >> 23. The RunGrepTest script used to cut out the test of NUL characters for >> Solaris and MacOS as printf and sed can't handle them. It seems that the *BSD >> systems can't either. I've inverted the test so that only those OS that are >> known to work (currently only Linux) try to run this test. >> >> comment: Now that the test checks for Linux, I am proposing to >> s/Linux/OpenBSD/ in the patch that jca@ added. This seems to be the >> easiest way to run this test now. >> >> previous version: >> uname=`uname` >> if [ "$uname" != "SunOS" -a "$uname" != "Darwin" ] ; then >> ... >> >> newest version: >> uname=`uname` >> case $uname in >> Linux) >> ... > > This is just badly implemented, portability-wise. sed can't portably > handle NUL characters, so sed shouldn't be used here. Your change > looks fine as a workaround for our ports tree, though. If you'd like to get rid of that patch, here's another approach using tr(1) that could be pushed upstream (I'm not volunteering). I'd expect all tr(1) implementations to support NUL bytes now. See APPLICATION USAGE and RATIONALE: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/tr.html I did not add a patch for testdata/grepoutputN because it contains CR bytes, hence the sed -i hack. Index: Makefile =================================================================== RCS file: /cvs/ports/devel/pcre2/Makefile,v retrieving revision 1.10 diff -u -p -r1.10 Makefile --- Makefile 1 May 2019 21:47:27 -0000 1.10 +++ Makefile 1 May 2019 22:47:11 -0000 @@ -39,4 +39,7 @@ CONFIGURE_ARGS += --disable-jit CONFIGURE_ENV = CPPFLAGS="-I${LOCALBASE}/include" \ LDFLAGS="-L${LOCALBASE}/lib" +post-extract: + sed -i 's/1:abcZERO/1:abc@/' ${WRKSRC}/testdata/grepoutputN + .include <bsd.port.mk> Index: patches/patch-RunGrepTest =================================================================== RCS file: /cvs/ports/devel/pcre2/patches/patch-RunGrepTest,v retrieving revision 1.2 diff -u -p -r1.2 patch-RunGrepTest --- patches/patch-RunGrepTest 1 May 2019 21:47:27 -0000 1.2 +++ patches/patch-RunGrepTest 1 May 2019 22:47:11 -0000 @@ -1,19 +1,35 @@ $OpenBSD: patch-RunGrepTest,v 1.2 2019/05/01 21:47:27 jca Exp $ Our sed(1) doesn't cope with NUL bytes and \x00-style notation. +Use tr(1) instead. Index: RunGrepTest --- RunGrepTest.orig +++ RunGrepTest -@@ -723,9 +723,9 @@ $valgrind $vjs $pcre2grep -n --newline=anycrlf "^(abc| +@@ -714,24 +714,9 @@ $valgrind $vjs $pcre2grep -n --newline=any "^(abc|def| + 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, and NetBSD. So +-# now we run this test only on OS that are known to work. For the rest, we +-# fudge the output so that the comparison works. +- printf '%c--------------------------- Test N7 ------------------------------\r\n' - >>testtrygrep - uname=`uname` - case $uname in +-uname=`uname` +-case $uname in - Linux) -+ OpenBSD) - printf 'abc\0def' >testNinputgrep +- printf 'abc\0def' >testNinputgrep - $valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep | sed 's/\x00/ZERO/' >>testtrygrep -+ $valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep | gsed 's/\x00/ZERO/' >>testtrygrep - echo "" >>testtrygrep - ;; - *) +- echo "" >>testtrygrep +- ;; +- *) +- echo '1:abcZERO2:def' >>testtrygrep +- ;; +-esac ++printf 'abc\0def' >testNinputgrep ++$valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep | tr '\000' '@' >>testtrygrep + + $cf $srcdir/testdata/grepoutputN testtrygrep + if [ $? != 0 ] ; then exit 1; fi -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE