diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2010-03-05 11:42:41 +0100 |
---|---|---|
committer | Paolo Bonzini <bonzini@gnu.org> | 2010-03-06 10:16:01 +0100 |
commit | dfc952df53977580b545c4f0a901542d8db1ac91 (patch) | |
tree | ab7dc2e9d0150783f1aed8ab94d2fe3ed0f8e36e /tests/pcre-z | |
parent | a14685c2833f7c28a427fecfaf146e0a861d94ba (diff) | |
download | grep-dfc952df53977580b545c4f0a901542d8db1ac91.tar.gz |
allow grep -Pz
* NEWS: Document grep -P improvements.
* src/search.c (Pcompile): Remove restriction on grep -Pz.
* tests/pcre-z: New.
* tests/Makefile.am (TESTS): Add pcre-z.
Diffstat (limited to 'tests/pcre-z')
-rwxr-xr-x | tests/pcre-z | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/pcre-z b/tests/pcre-z new file mode 100755 index 00000000..17d9f955 --- /dev/null +++ b/tests/pcre-z @@ -0,0 +1,25 @@ +#!/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_ 'PCRE not available.' +compare err /dev/null || fail_ 'PCRE available, but stderr not empty.' + +REGEX=a + +printf "%s\n0" abc def ghi aaa gah | tr 0 \\0 > in + +grep -z "$REGEX" in > exp 2>err || fail_ 'Cannot do BRE (grep -z) match.' +compare err /dev/null || fail_ 'stderr not empty on grep -z.' + +# Sanity check the output +test `grep -cz "$REGEX" in` 2>err = 3 || fail_ 'Incorrect BRE (grep -cz) match.' +compare err /dev/null || fail_ 'stderr not empty on grep -cz.' + +fail=0 +grep -Pz "$REGEX" in > out 2>err || fail=1 +compare out exp || fail=1 +compare err /dev/null || fail=1 + +Exit $fail |