1#! /bin/sh 2. "${srcdir=.}/init.sh"; path_prepend_ . ../src 3 4# Test checking of Python format strings. 5 6cat <<\EOF > f-lu-2.data 7# Valid: %% doesn't count 8msgid "abc%%def" 9msgstr "xyz" 10# Invalid: invalid msgstr 11msgid "abc%%def" 12msgstr "xyz%" 13# Valid: same arguments, with different widths 14msgid "abc%2sdef" 15msgstr "xyz%3s" 16# Invalid: too few arguments 17msgid "abc%sdef%u" 18msgstr "xyz%s" 19# Invalid: too many arguments 20msgid "abc%udef" 21msgstr "xyz%uvw%c" 22# Valid: type compatibility 23msgid "abc%i" 24msgstr "xyz%d" 25# Valid: type compatibility 26msgid "abc%i" 27msgstr "xyz%u" 28# Valid: type compatibility 29msgid "abc%i" 30msgstr "xyz%o" 31# Valid: type compatibility 32msgid "abc%i" 33msgstr "xyz%x" 34# Valid: type compatibility 35msgid "abc%i" 36msgstr "xyz%X" 37# Valid: type compatibility 38msgid "abc%e" 39msgstr "xyz%E" 40# Valid: type compatibility 41msgid "abc%e" 42msgstr "xyz%f" 43# Valid: type compatibility 44msgid "abc%e" 45msgstr "xyz%g" 46# Valid: type compatibility 47msgid "abc%e" 48msgstr "xyz%G" 49# Invalid: type incompatibility 50msgid "abc%c" 51msgstr "xyz%s" 52# Invalid: type incompatibility 53msgid "abc%c" 54msgstr "xyz%.0s" 55# Invalid: type incompatibility 56msgid "abc%c" 57msgstr "xyz%i" 58# Invalid: type incompatibility 59msgid "abc%c" 60msgstr "xyz%e" 61# Invalid: type incompatibility 62msgid "abc%s" 63msgstr "xyz%i" 64# Invalid: type incompatibility 65msgid "abc%.0s" 66msgstr "xyz%i" 67# Invalid: type incompatibility 68msgid "abc%s" 69msgstr "xyz%e" 70# Invalid: type incompatibility 71msgid "abc%.0s" 72msgstr "xyz%e" 73# Invalid: type incompatibility 74msgid "abc%i" 75msgstr "xyz%e" 76# Invalid: type incompatibility 77msgid "abc%s" 78msgstr "xyz%q" 79# Invalid: type incompatibility 80msgid "abc%q" 81msgstr "xyz%s" 82EOF 83 84: ${MSGFMT=msgfmt} 85n=0 86while read comment; do 87 read msgid_line 88 read msgstr_line 89 n=`expr $n + 1` 90 cat <<EOF > f-lu-2-$n.po 91#, lua-format 92${msgid_line} 93${msgstr_line} 94EOF 95 fail= 96 if echo "$comment" | grep 'Valid:' > /dev/null; then 97 if ${MSGFMT} --check-format -o f-lu-2-$n.mo f-lu-2-$n.po; then 98 : 99 else 100 fail=yes 101 fi 102 else 103 ${MSGFMT} --check-format -o f-lu-2-$n.mo f-lu-2-$n.po 2> /dev/null 104 if test $? = 1; then 105 : 106 else 107 fail=yes 108 fi 109 fi 110 if test -n "$fail"; then 111 echo "Format string checking error:" 1>&2 112 cat f-lu-2-$n.po 1>&2 113 Exit 1 114 fi 115 rm -f f-lu-2-$n.po f-lu-2-$n.mo 116done < f-lu-2.data 117 118Exit 0 119