1#! /bin/sh 2. "${srcdir=.}/init.sh"; path_prepend_ . ../src 3 4# Test checking of Java format strings. 5 6cat <<\EOF > f-j-2.data 7# Invalid: invalid msgstr 8msgid "abc{0}def" 9msgstr "abc{" 10# Valid: same arguments 11msgid "abc{1}def" 12msgstr "xyz{1}" 13# Valid: same arguments, differently written 14msgid "abc{1}def" 15msgstr "xyz{01}" 16# Valid: permutation 17msgid "abc{2}{0}{1}def" 18msgstr "xyz{1}{0}{2}" 19# Invalid: too few arguments 20msgid "abc{1}def{0}" 21msgstr "xyz{0}" 22# Invalid: too many arguments 23msgid "abc{0}def" 24msgstr "xyz{0}uvw{1}" 25# Invalid: missing non-final argument 26msgid "abc{1}def{0}" 27msgstr "xyz{1}" 28# Invalid: added non-final argument 29msgid "abc{1}def" 30msgstr "xyz{0}{1}" 31# Invalid: different number of arguments 32msgid "abc{500000000}def" 33msgstr "xyz{500000001}" 34# Valid: type compatibility 35msgid "abc{1,number}" 36msgstr "xyz{1,choice,0#zero|1#{1,number}}" 37# Valid: type compatibility 38msgid "abc{1,number}" 39msgstr "xyz{1,number,currency}" 40# Valid: type compatibility 41msgid "abc{1,number}" 42msgstr "xyz{1,number,percent}" 43# Valid: type compatibility 44msgid "abc{1,number}" 45msgstr "xyz{1,number,integer}" 46# Valid: type compatibility 47msgid "abc{1,number}" 48msgstr "xyz{1,number,###,##0}" 49# Valid: type compatibility 50msgid "abc{1,date}" 51msgstr "xyz{1,time}" 52# Valid: type compatibility 53msgid "abc{1,date}" 54msgstr "xyz{1,date,short}" 55# Valid: type compatibility 56msgid "abc{1,date}" 57msgstr "xyz{1,date,medium}" 58# Valid: type compatibility 59msgid "abc{1,date}" 60msgstr "xyz{1,date,long}" 61# Valid: type compatibility 62msgid "abc{1,date}" 63msgstr "xyz{1,date,full}" 64# Valid: type compatibility 65msgid "abc{1,date}" 66msgstr "xyz{1,date,yyyy-MM-dd}" 67# Valid: type compatibility 68msgid "abc{1,time}" 69msgstr "xyz{1,time,short}" 70# Valid: type compatibility 71msgid "abc{1,time}" 72msgstr "xyz{1,time,medium}" 73# Valid: type compatibility 74msgid "abc{1,time}" 75msgstr "xyz{1,time,long}" 76# Valid: type compatibility 77msgid "abc{1,time}" 78msgstr "xyz{1,time,full}" 79# Valid: type compatibility 80msgid "abc{1,time}" 81msgstr "xyz{1,time,}" 82# Valid: type compatibility 83msgid "abc{1,time}" 84msgstr "xyz{1,time,hh:mm:ss}" 85# Invalid: type incompatibility 86msgid "abc{1}" 87msgstr "xyz{1,number}" 88# Invalid: type incompatibility 89msgid "abc{1}" 90msgstr "xyz{1,date}" 91# Invalid: type incompatibility 92msgid "abc{1,time}" 93msgstr "xyz{1,number}" 94# Invalid: type incompatibility 95msgid "abc{1,number}" 96msgstr "xyz{1,date}" 97# Invalid: type incompatibility 98msgid "abc{1}" 99msgstr "xyz{1,choice,0#zero|1#{1,number}}" 100# Invalid: type incompatibility 101msgid "abc{1}" 102msgstr "xyz{1,choice,0#zero|1#{0,number}}" 103# Invalid: type incompatibility 104msgid "abc{0,number}{1}" 105msgstr "xyz{0,choice,0#zero|1#{1,number}}" 106EOF 107 108: ${MSGFMT=msgfmt} 109n=0 110while read comment; do 111 read msgid_line 112 read msgstr_line 113 n=`expr $n + 1` 114 cat <<EOF > f-j-2-$n.po 115#, java-format 116${msgid_line} 117${msgstr_line} 118EOF 119 fail= 120 if echo "$comment" | grep 'Valid:' > /dev/null; then 121 if ${MSGFMT} --check-format -o f-j-2-$n.mo f-j-2-$n.po; then 122 : 123 else 124 fail=yes 125 fi 126 else 127 ${MSGFMT} --check-format -o f-j-2-$n.mo f-j-2-$n.po 2> /dev/null 128 if test $? = 1; then 129 : 130 else 131 fail=yes 132 fi 133 fi 134 if test -n "$fail"; then 135 echo "Format string checking error:" 1>&2 136 cat f-j-2-$n.po 1>&2 137 Exit 1 138 fi 139 rm -f f-j-2-$n.po f-j-2-$n.mo 140done < f-j-2.data 141 142Exit 0 143