| 1 | #! /bin/sh | 
|---|
| 2 | # Copyright (C) 2001, 2006, 2009-2021 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 | tr -cs '0-9' '[ *]')) | 
|---|
| 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 | tr -cs '0-9' '[ *]')) | 
|---|
| 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 | tr -cs '0-9' '[ *]')) | 
|---|
| 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; export LC_ALL | 
|---|
| 78 | #               grep -${mode}iw -f cspatfile csinput | | 
|---|
| 79 | #                 sed 's/[^0123456789]/ /g')) | 
|---|
| 80 | #if test "$test4" != "01 02 08 13 17 19"; then | 
|---|
| 81 | #  echo "Test #4 ${mode} failed: $test4" | 
|---|
| 82 | #  failures=1 | 
|---|
| 83 | #fi | 
|---|
| 84 |  | 
|---|
| 85 | # Test that --color=always does not depend on individual pattern order | 
|---|
| 86 | # within the pattern list, and that a longer match is preferred to a | 
|---|
| 87 | # shorter one starting at the same point. | 
|---|
| 88 | test6="$(echo 'Cosi tu ÄiÅ¡Ã...' \ | 
|---|
| 89 | | LC_ALL=$cz grep --color=always -${mode}i -e 'ÄiÅ¡' -e 'ÄiÅ¡Ã')" | 
|---|
| 90 | if echo "$test6" \ | 
|---|
| 91 | | LC_ALL=C grep -q 'Cosi tu .*\[.*m\(.\[K\)\?ÄiÅ¡Ã.*\[.*m\(.\[K\)\?\.\.\.'; \ | 
|---|
| 92 | then | 
|---|
| 93 | : | 
|---|
| 94 | else | 
|---|
| 95 | echo "Test #6 ${mode} failed: $test6" | 
|---|
| 96 | failures=1 | 
|---|
| 97 | fi | 
|---|
| 98 |  | 
|---|
| 99 | # Test that --color=always does not depend on individual pattern order | 
|---|
| 100 | # within the pattern list, and that a longer match is preferred to a | 
|---|
| 101 | # shorter one starting at the same point. | 
|---|
| 102 | test7="$(echo 'Cosi tu ÄiÅ¡Ã...' \ | 
|---|
| 103 | | LC_ALL=$cz grep --color=always -${mode}i -e 'ÄiÅ¡Ã' -e 'ÄiÅ¡')" | 
|---|
| 104 | if echo "$test7" \ | 
|---|
| 105 | | LC_ALL=C grep -q 'Cosi tu .*\[.*m\(.\[K\)\?ÄiÅ¡Ã.*\[.*m\(.\[K\)\?\.\.\.'; \ | 
|---|
| 106 | then | 
|---|
| 107 | : | 
|---|
| 108 | else | 
|---|
| 109 | echo "Test #7 ${mode} failed: $test7" | 
|---|
| 110 | failures=1 | 
|---|
| 111 | fi | 
|---|
| 112 |  | 
|---|
| 113 | done | 
|---|
| 114 |  | 
|---|
| 115 | for mode in G E; do | 
|---|
| 116 |  | 
|---|
| 117 | test8=$(echo $(LC_ALL=$cz grep -${mode}i -e 'Ä.Å¡E' -e 'Ä[a-f]s' csinput | | 
|---|
| 118 | tr -cs '0-9' '[ *]')) | 
|---|
| 119 | if test "$test8" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then | 
|---|
| 120 | echo "Test #8 ${mode} failed: $test8" | 
|---|
| 121 | failures=1 | 
|---|
| 122 | fi | 
|---|
| 123 |  | 
|---|
| 124 | done | 
|---|
| 125 |  | 
|---|
| 126 | Exit $failures | 
|---|