| 1 | #! /bin/sh
|
|---|
| 2 | # Copyright (C) 2001, 2006, 2009-2012 Free Software Foundation, Inc.
|
|---|
| 3 | #
|
|---|
| 4 | # Copying and distribution of this file, with or without modification,
|
|---|
| 5 | # are permitted in any medium without royalty provided the copyright
|
|---|
| 6 | # notice and this notice are preserved.
|
|---|
| 7 |
|
|---|
| 8 | . "${srcdir=.}/init.sh"; path_prepend_ ../src
|
|---|
| 9 |
|
|---|
| 10 | cz=cs_CZ.UTF-8
|
|---|
| 11 |
|
|---|
| 12 | # If cs_CZ.UTF-8 locale doesn't work, skip this test.
|
|---|
| 13 | LC_ALL=$cz locale -k LC_CTYPE 2>/dev/null | grep -q charmap.*UTF-8 \
|
|---|
| 14 | || skip_ this system lacks the $cz locale
|
|---|
| 15 |
|
|---|
| 16 | # If matching is done in single-byte mode, skip this test too
|
|---|
| 17 | printf 'é\n' | LC_ALL=$cz grep -Eq '^[é]{2}$'
|
|---|
| 18 | case $? in
|
|---|
| 19 | 0) skip_ "built without multi-byte support";;
|
|---|
| 20 | 1) ;;
|
|---|
| 21 | *) fail_ "unexpected exit status: $?";;
|
|---|
| 22 | esac
|
|---|
| 23 |
|
|---|
| 24 | failures=0
|
|---|
| 25 |
|
|---|
| 26 | cat > csinput <<EOF
|
|---|
| 27 | 01 Žluťoučká číše
|
|---|
| 28 | ČíŠE 02
|
|---|
| 29 | 03 Z číší Čiší cosi
|
|---|
| 30 | 04 Čí
|
|---|
| 31 | Še 05
|
|---|
| 32 | 06 ČČČČČČČíšČÍŠčíš
|
|---|
| 33 | 07 ČČČ ČČČČíšČÍŠčíšEEEE
|
|---|
| 34 | čAs 08
|
|---|
| 35 | 09Čapka
|
|---|
| 36 | 10ČaSy se měnÍ
|
|---|
| 37 | ČÍšE11
|
|---|
| 38 | Čas12
|
|---|
| 39 | 𝇕ČÍšE𝇓13
|
|---|
| 40 | ŽČÍšE𝇓14
|
|---|
| 41 | 𝇕ČÍšEŽ15
|
|---|
| 42 | ŽČÍšEŽ16
|
|---|
| 43 | ČÍšE𝇓17
|
|---|
| 44 | ČÍšEŽ18
|
|---|
| 45 | 19𝇕ČÍše
|
|---|
| 46 | 20ŽČÍše
|
|---|
| 47 | EOF
|
|---|
| 48 | cat > cspatfile <<EOF
|
|---|
| 49 | ČÍšE
|
|---|
| 50 | Čas
|
|---|
| 51 | EOF
|
|---|
| 52 |
|
|---|
| 53 | for mode in F G E; do
|
|---|
| 54 |
|
|---|
| 55 | test1="$(echo $(LC_ALL=$cz grep -${mode} -f cspatfile csinput \
|
|---|
| 56 | | LC_ALL=C sed 's/^.*\([0-9][0-9]\).*$/\1/'))"
|
|---|
| 57 | if test "$test1" != "11 12 13 14 15 16 17 18"; then
|
|---|
| 58 | echo "Test #1 ${mode} failed: $test1"
|
|---|
| 59 | failures=1
|
|---|
| 60 | fi
|
|---|
| 61 |
|
|---|
| 62 | test2="$(echo $(LC_ALL=$cz grep -${mode}i -f cspatfile csinput \
|
|---|
| 63 | | LC_ALL=C sed 's/^.*\([0-9][0-9]\).*$/\1/'))"
|
|---|
| 64 | if test "$test2" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
|
|---|
| 65 | echo "Test #2 ${mode} failed: $test2"
|
|---|
| 66 | failures=1
|
|---|
| 67 | fi
|
|---|
| 68 |
|
|---|
| 69 | test3="$(echo $(LC_ALL=$cz grep -${mode}i -e 'ČÍšE' -e 'Čas' csinput \
|
|---|
| 70 | | LC_ALL=C sed 's/^.*\([0-9][0-9]\).*$/\1/'))"
|
|---|
| 71 | if test "$test3" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
|
|---|
| 72 | echo "Test #3 ${mode} failed: $test3"
|
|---|
| 73 | failures=1
|
|---|
| 74 | fi
|
|---|
| 75 |
|
|---|
| 76 | # Skip the next test - known to fail. TAA.
|
|---|
| 77 | #test4="$(echo $(LC_ALL=$cz grep -${mode}iw -f cspatfile csinput \
|
|---|
| 78 | # | LC_ALL=C sed 's/^.*\([0-9][0-9]\).*$/\1/'))"
|
|---|
| 79 | #if test "$test4" != "01 02 08 13 17 19"; then
|
|---|
| 80 | # echo "Test #4 ${mode} failed: $test4"
|
|---|
| 81 | # failures=1
|
|---|
| 82 | #fi
|
|---|
| 83 |
|
|---|
| 84 | # Test that --color=always does not depend on individual pattern order within the pattern
|
|---|
| 85 | # list, and that a longer match is preferred to a shorter one starting at the same point.
|
|---|
| 86 | test6="$(echo 'Cosi tu ČišÍ...' \
|
|---|
| 87 | | LC_ALL=$cz grep --color=always -${mode}i -e 'čiš' -e 'čiší')"
|
|---|
| 88 | if echo "$test6" | LC_ALL=C grep -q 'Cosi tu .*\[.*m\(.\[K\)\?ČišÍ.*\[.*m\(.\[K\)\?\.\.\.'; then
|
|---|
| 89 | :
|
|---|
| 90 | else
|
|---|
| 91 | echo "Test #6 ${mode} failed: $test6"
|
|---|
| 92 | failures=1
|
|---|
| 93 | fi
|
|---|
| 94 |
|
|---|
| 95 | # Test that --color=always does not depend on individual pattern order within the pattern
|
|---|
| 96 | # list, and that a longer match is preferred to a shorter one starting at the same point.
|
|---|
| 97 | test7="$(echo 'Cosi tu ČišÍ...' \
|
|---|
| 98 | | LC_ALL=$cz grep --color=always -${mode}i -e 'čiší' -e 'čiš')"
|
|---|
| 99 | if echo "$test7" | LC_ALL=C grep -q 'Cosi tu .*\[.*m\(.\[K\)\?ČišÍ.*\[.*m\(.\[K\)\?\.\.\.'; then
|
|---|
| 100 | :
|
|---|
| 101 | else
|
|---|
| 102 | echo "Test #7 ${mode} failed: $test7"
|
|---|
| 103 | failures=1
|
|---|
| 104 | fi
|
|---|
| 105 |
|
|---|
| 106 | done
|
|---|
| 107 |
|
|---|
| 108 | for mode in G E; do
|
|---|
| 109 |
|
|---|
| 110 | test8="$(echo $(LC_ALL=$cz grep -${mode}i -e 'Č.šE' -e 'Č[a-f]s' csinput \
|
|---|
| 111 | | LC_ALL=C sed 's/^.*\([0-9][0-9]\).*$/\1/'))"
|
|---|
| 112 | if test "$test8" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
|
|---|
| 113 | echo "Test #8 ${mode} failed: $test8"
|
|---|
| 114 | failures=1
|
|---|
| 115 | fi
|
|---|
| 116 |
|
|---|
| 117 | done
|
|---|
| 118 |
|
|---|
| 119 | Exit $failures
|
|---|