| 1 |
#!/bin/sh |
| 2 |
# Test Perl regex with NUL-separated input |
| 3 |
. "${srcdir=.}/init.sh"; path_prepend_ ../src |
| 4 |
require_pcre_ |
| 5 |
require_en_utf8_locale_ |
| 6 |
|
| 7 |
REGEX=a |
| 8 |
|
| 9 |
printf '%s\n\0' abc def ghi aaa gah > in || framework_failure_ |
| 10 |
|
| 11 |
grep -z "$REGEX" in > exp 2>err || fail_ 'Cannot do BRE (grep -z) match.' |
| 12 |
compare /dev/null err || fail_ 'stderr not empty on grep -z.' |
| 13 |
|
| 14 |
# Sanity check the output |
| 15 |
test "$(grep -cz $REGEX in 2>err)" = 3 \ |
| 16 |
|| fail_ 'Incorrect BRE (grep -cz) match.' |
| 17 |
compare /dev/null err || fail_ 'stderr not empty on grep -cz.' |
| 18 |
|
| 19 |
fail=0 |
| 20 |
grep -Pz "$REGEX" in > out 2>err || fail=1 |
| 21 |
compare exp out || fail=1 |
| 22 |
compare /dev/null err || fail=1 |
| 23 |
|
| 24 |
printf '\303\200\0' >in0 # "À" followed by a NUL. |
| 25 |
LC_ALL=en_US.UTF-8 grep -z . in0 >out || fail=1 |
| 26 |
cmp in0 out || fail=1 |
| 27 |
|
| 28 |
Exit $fail |