1#! /bin/sh 2. "${srcdir=.}/init.sh"; path_prepend_ . ../src 3 4# Test checking of JavaScript format strings. 5 6cat <<\EOF > f-js-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%d" 18msgstr "xyz%s" 19# Invalid: too many arguments 20msgid "abc%ddef" 21msgstr "xyz%dvw%c" 22# Valid: type compatibility 23msgid "abc%o" 24msgstr "xyz%d" 25# Valid: type compatibility 26msgid "abc%o" 27msgstr "xyz%x" 28# Valid: type compatibility 29msgid "abc%o" 30msgstr "xyz%X" 31# Valid: type compatibility 32msgid "abc%d" 33msgstr "xyz%x" 34# Valid: type compatibility 35msgid "abc%d" 36msgstr "xyz%X" 37# Invalid: type incompatibility 38msgid "abc%c" 39msgstr "xyz%s" 40# Invalid: type incompatibility 41msgid "abc%c" 42msgstr "xyz%d" 43# Invalid: type incompatibility 44msgid "abc%s" 45msgstr "xyz%d" 46EOF 47 48: ${MSGFMT=msgfmt} 49n=0 50while read comment; do 51 read msgid_line 52 read msgstr_line 53 n=`expr $n + 1` 54 cat <<EOF > f-js-2-$n.po 55#, javascript-format 56${msgid_line} 57${msgstr_line} 58EOF 59 fail= 60 if echo "$comment" | grep 'Valid:' > /dev/null; then 61 if ${MSGFMT} --check-format -o f-js-2-$n.mo f-js-2-$n.po; then 62 : 63 else 64 fail=yes 65 fi 66 else 67 ${MSGFMT} --check-format -o f-js-2-$n.mo f-js-2-$n.po 2> /dev/null 68 if test $? = 1; then 69 : 70 else 71 fail=yes 72 fi 73 fi 74 if test -n "$fail"; then 75 echo "Format string checking error:" 1>&2 76 cat f-js-2-$n.po 1>&2 77 Exit 1 78 fi 79 rm -f f-js-2-$n.po f-js-2-$n.mo 80done < f-js-2.data 81 82Exit 0 83