1#! /bin/sh 2. "${srcdir=.}/init.sh"; path_prepend_ . ../src 3 4# Test checking of librep format strings. 5 6cat <<\EOF > f-lr-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 14msgid "abc%s%xdef" 15msgstr "xyz%s%x" 16# Valid: same arguments, with different widths 17msgid "abc%2sdef" 18msgstr "xyz%3s" 19# Valid: same arguments but in numbered syntax 20msgid "abc%s%xdef" 21msgstr "xyz%1$s%2$x" 22# Valid: permutation 23msgid "abc%s%x%cdef" 24msgstr "xyz%3$c%2$x%1$s" 25# Invalid: too few arguments 26msgid "abc%2$xdef%1$s" 27msgstr "xyz%1$s" 28# Invalid: too few arguments 29msgid "abc%sdef%x" 30msgstr "xyz%s" 31# Invalid: too many arguments 32msgid "abc%xdef" 33msgstr "xyz%xvw%c" 34# Valid: same numbered arguments, with different widths 35msgid "abc%2$5s%1$4s" 36msgstr "xyz%2$4s%1$5s" 37# Invalid: missing argument 38msgid "abc%2$sdef%1$x" 39msgstr "xyz%1$x" 40# Invalid: missing argument 41msgid "abc%1$sdef%2$x" 42msgstr "xyz%2$x" 43# Invalid: added argument 44msgid "abc%1$xdef" 45msgstr "xyz%1$xvw%2$c" 46# Valid: type compatibility 47msgid "abc%d" 48msgstr "xyz%x" 49# Valid: type compatibility 50msgid "abc%d" 51msgstr "xyz%X" 52# Valid: type compatibility 53msgid "abc%d" 54msgstr "xyz%o" 55# Valid: type compatibility 56msgid "abc%x" 57msgstr "xyz%X" 58# Valid: type compatibility 59msgid "abc%x" 60msgstr "xyz%o" 61# Valid: type compatibility 62msgid "abc%X" 63msgstr "xyz%o" 64# Invalid: type incompatibility 65msgid "abc%c" 66msgstr "xyz%d" 67# Invalid: type incompatibility 68msgid "abc%c" 69msgstr "xyz%x" 70# Invalid: type incompatibility 71msgid "abc%c" 72msgstr "xyz%X" 73# Invalid: type incompatibility 74msgid "abc%c" 75msgstr "xyz%o" 76# Invalid: type incompatibility 77msgid "abc%c" 78msgstr "xyz%s" 79# Invalid: type incompatibility 80msgid "abc%c" 81msgstr "xyz%S" 82# Invalid: type incompatibility 83msgid "abc%d" 84msgstr "xyz%s" 85# Invalid: type incompatibility 86msgid "abc%d" 87msgstr "xyz%S" 88# Invalid: type incompatibility 89msgid "abc%x" 90msgstr "xyz%s" 91# Invalid: type incompatibility 92msgid "abc%x" 93msgstr "xyz%S" 94# Invalid: type incompatibility 95msgid "abc%X" 96msgstr "xyz%s" 97# Invalid: type incompatibility 98msgid "abc%X" 99msgstr "xyz%S" 100# Invalid: type incompatibility 101msgid "abc%o" 102msgstr "xyz%s" 103# Invalid: type incompatibility 104msgid "abc%o" 105msgstr "xyz%S" 106# Invalid: type incompatibility 107msgid "abc%s" 108msgstr "xyz%S" 109EOF 110 111: ${MSGFMT=msgfmt} 112n=0 113while read comment; do 114 read msgid_line 115 read msgstr_line 116 n=`expr $n + 1` 117 cat <<EOF > f-lr-2-$n.po 118#, librep-format 119${msgid_line} 120${msgstr_line} 121EOF 122 fail= 123 if echo "$comment" | grep 'Valid:' > /dev/null; then 124 if ${MSGFMT} --check-format -o f-lr-2-$n.mo f-lr-2-$n.po; then 125 : 126 else 127 fail=yes 128 fi 129 else 130 ${MSGFMT} --check-format -o f-lr-2-$n.mo f-lr-2-$n.po 2> /dev/null 131 if test $? = 1; then 132 : 133 else 134 fail=yes 135 fi 136 fi 137 if test -n "$fail"; then 138 echo "Format string checking error:" 1>&2 139 cat f-lr-2-$n.po 1>&2 140 Exit 1 141 fi 142 rm -f f-lr-2-$n.po f-lr-2-$n.mo 143done < f-lr-2.data 144 145Exit 0 146