bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 0/6] *** SUBJECT HERE ***


From: Jim Meyering
Subject: Re: [PATCH 0/6] *** SUBJECT HERE ***
Date: Sat, 06 Mar 2010 10:09:17 +0100

Paolo Bonzini wrote:
> Subject: [PATCH 6/6] allow grep -Pz
>
> * src/search.c (Pcompile): Remove restriction on grep -Pz.
> * tests/pcre-z: New.
> * tests/Makefile.am (TESTS): Add pcre-z.

Thanks for adding another test.
ACK, once you address the nits below.

> diff --git a/src/search.c b/src/search.c
> index 9d7ed98..c4e5149 100644
> --- a/src/search.c
> +++ b/src/search.c
> @@ -677,8 +677,6 @@ COMPILE_FCT(Pcompile)
>    char const *pnul;
>
>    /* FIXME: Remove these restrictions.  */
> -  if (eolbyte != '\n')
> -    error (EXIT_TROUBLE, 0, _("The -P and -z options cannot be combined"));
>    if (memchr(pattern, '\n', size))
>      error (EXIT_TROUBLE, 0, _("The -P option only supports a single 
> pattern"));
>
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index ea108e4..4b08abc 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -31,7 +31,8 @@ TESTS =             \
>    status.sh  \
>    warning.sh \
>    yesno.sh   \
> -  fedora.sh
> +  fedora.sh  \
> +  pcre-z

Please alphabetize these.

>  EXTRA_DIST = \
>    $(TESTS)   \
> diff --git a/tests/pcre-z b/tests/pcre-z
> new file mode 100755
> index 0000000..967ecad
> --- /dev/null
> +++ b/tests/pcre-z
> @@ -0,0 +1,29 @@
> +#!/bin/sh
> +# Test Perl regex with NUL-separated input
> +: ${srcdir=.}
> +. "$srcdir/init.sh"; path_prepend_ ../src
> +
> +echo a | grep -P a >/dev/null 2>err || skip_

Please give skip_ an argument to tell why the test is being skipped.

> +compare err /dev/null || fail_

Same for fail_ here, and below.

> +REGEX=a
> +
> +echo 'abc
> +0def
> +0ghi
> +0aaa
> +0gah' | tr 0 \\0 > in

You could also do it all one line:

  printf 'abc\0def\0ghi\0aaa\0gah\n' > in

either way is ok.

> +grep -z "$REGEX" in > exp 2>err || fail_
> +compare err /dev/null || fail_
> +
> +# Sanity check the output
> +test `grep -cz "$REGEX" in` 2>err = 3 || fail_
> +compare err /dev/null || fail_
> +
> +fail=0
> +grep -Pz "$REGEX" in > out 2>err || fail=1
> +compare out exp || fail=1
> +compare err /dev/null || fail=1
> +
> +Exit $fail




reply via email to

[Prev in Thread] Current Thread [Next in Thread]