[pcre-dev] [Bug 2681] New: RunGrepTest N7 improvement: use t…

Página superior
Eliminar este mensaje
Autor: admin
Fecha:  
A: pcre-dev
Asunto: [pcre-dev] [Bug 2681] New: RunGrepTest N7 improvement: use tr(1) instead of sed(1)
https://bugs.exim.org/show_bug.cgi?id=2681

            Bug ID: 2681
           Summary: RunGrepTest N7 improvement: use tr(1) instead of
                    sed(1)
           Product: PCRE
           Version: 10.36 (PCRE2)
          Hardware: Other
                OS: OpenBSD
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
          Assignee: Philip.Hazel@???
          Reporter: namtsui@???
                CC: pcre-dev@???


I propose a change that uses tr(1) instead of sed(1) for test N7 in
RunGrepTest.

I see from the comments that there are portability concerns with sed(1).
# It seems impossible to handle NUL characters easily in many operating

This work is from Jeremie Courreges-Anglas, who has suggested that tr
implementations can handle NUL.

source: https://marc.info/?l=openbsd-ports&m=155675121018167&w=2

I am Nam Nguyen, the maintainer of the pcre2 OpenBSD port. With this change N7
test passes on OpenBSD. Tests on other systems are welcome.

The proposed change is in two parts:
1. patch testdata/grepoutputN to use '@' instead of "ZERO" so that tr works:

sed -i 's/1:abcZERO2:defZERO/1:abc@2:def@/' ${WRKSRC}/testdata/grepoutputN

2. patch RunGrepTest

$OpenBSD: patch-RunGrepTest,v 1.4 2020/06/20 06:55:46 kn Exp $

Our sed(1) doesn't cope with NUL bytes and \x00-style notation.
Use tr(1) instead.

Index: RunGrepTest
--- RunGrepTest.orig
+++ RunGrepTest
@@ -763,14 +763,9 @@ $valgrind $vjs $pcre2grep -n --newline=anycrlf "^(abc|
# doesn't.

printf '%c--------------------------- Test N7
------------------------------\r\n' - >>testtrygrep
-Z=`printf '\0' | sed 's/\x00/Z/g'`
-if [ "$Z" = "Z" ]; then
- printf 'abc\0def' >testNinputgrep
- $valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep |
sed 's/\x00/ZERO/g' >>testtrygrep
- echo "" >>testtrygrep
-else
- echo '1:abcZERO2:defZERO' >>testtrygrep
-fi
+printf 'abc\0def' >testNinputgrep
+$valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep | tr
'\000' '@' >>testtrygrep
+echo "" >>testtrygrep

$cf $srcdir/testdata/grepoutputN testtrygrep
if [ $? != 0 ] ; then exit 1; fi

--
You are receiving this mail because:
You are on the CC list for the bug.