| 1 | #!/bin/sh |
| 2 | # This would mistakenly print a line prior to grep-2.18. |
| 3 | . "${srcdir=.}/init.sh"; path_prepend_ ../src |
| 4 | |
| 5 | require_en_utf8_locale_ |
| 6 | require_compiled_in_MB_support |
| 7 | |
| 8 | encode() { echo "$1" | tr ABC '\357\274\241'; } |
| 9 | |
| 10 | encode ABC >exp1 |
| 11 | encode aABC >exp2 |
| 12 | encode ABCABC >exp3 |
| 13 | encode _____________________ABCABC___ >exp4 |
| 14 | |
| 15 | fail=0 |
| 16 | |
| 17 | for LOC in en_US.UTF-8 $LOCALE_FR_UTF8; do |
| 18 | for pat in A aA BCA; do |
| 19 | for file in exp1 exp2 exp3 exp4; do |
| 20 | for type in regex dfa fgrep; do |
| 21 | case $type in |
| 22 | dfa) opt= prefix= ;; |
| 23 | fgrep) opt=-F prefix= ;; |
| 24 | regex) opt= prefix='\(\)\1' ;; |
| 25 | esac |
| 26 | pattern=$prefix$(encode $pat) |
| 27 | out=out-$type-$LOC |
| 28 | LC_ALL=$LOC grep $opt "$pattern" $file >$out |
| 29 | status=$? |
| 30 | echo $status >$out.status |
| 31 | if test $status -eq 0; then |
| 32 | compare $file $out |
| 33 | elif test $status -eq 1; then |
| 34 | compare_dev_null_ /dev/null $out |
| 35 | else |
| 36 | test $status -eq 2 |
| 37 | fi || fail=1 |
| 38 | compare out-regex-$LOC.status $out.status || fail=1 |
| 39 | done |
| 40 | done |
| 41 | done |
| 42 | done |
| 43 | |
| 44 | Exit $fail |