| #! /bin/sh |
| . "${srcdir=.}/init.sh"; path_prepend_ . ../src |
| |
| # Test checking of GFC internal format strings. |
| |
| cat <<\EOF > f-gf-2.data |
| # Valid: %% doesn't count |
| msgid "abc%%def" |
| msgstr "xyz" |
| # Invalid: %C consumes currentloc |
| msgid "abc%Cdef" |
| msgstr "xyz" |
| # Invalid: %C consumes currentloc |
| msgid "abc" |
| msgstr "xyz%Cuvw" |
| # Invalid: invalid msgstr |
| msgid "abc%%def" |
| msgstr "xyz%" |
| # Valid: same arguments |
| msgid "abc%s%udef" |
| msgstr "xyz%s%u" |
| # Valid: same arguments but in numbered syntax |
| msgid "abc%s%ddef" |
| msgstr "xyz%1$s%2$d" |
| # Valid: permutation |
| msgid "abc%s%d%cdef" |
| msgstr "xyz%3$c%2$d%1$s" |
| # Invalid: too few arguments |
| msgid "abc%sdef%u" |
| msgstr "xyz%s" |
| # Invalid: too many arguments |
| msgid "abc%udef" |
| msgstr "xyz%uvw%c" |
| # Invalid: missing argument |
| msgid "abc%2$sdef%1$u" |
| msgstr "xyz%1$u" |
| # Invalid: missing argument |
| msgid "abc%1$sdef%2$u" |
| msgstr "xyz%2$u" |
| # Invalid: added argument |
| msgid "abc%1$udef" |
| msgstr "xyz%1$uvw%2$c" |
| # Valid: type compatibility |
| msgid "abc%i" |
| msgstr "xyz%d" |
| # Invalid: type incompatibility |
| msgid "abc%c" |
| msgstr "xyz%s" |
| # Invalid: type incompatibility |
| msgid "abc%c" |
| msgstr "xyz%i" |
| # Invalid: type incompatibility |
| msgid "abc%c" |
| msgstr "xyz%u" |
| # Invalid: type incompatibility |
| msgid "abc%c" |
| msgstr "xyz%li" |
| # Invalid: type incompatibility |
| msgid "abc%c" |
| msgstr "xyz%lu" |
| # Invalid: type incompatibility |
| msgid "abc%c" |
| msgstr "xyz%L" |
| # Invalid: type incompatibility |
| msgid "abc%c" |
| msgstr "xyz%C" |
| # Invalid: type incompatibility |
| msgid "abc%s" |
| msgstr "xyz%i" |
| # Invalid: type incompatibility |
| msgid "abc%s" |
| msgstr "xyz%u" |
| # Invalid: type incompatibility |
| msgid "abc%s" |
| msgstr "xyz%li" |
| # Invalid: type incompatibility |
| msgid "abc%s" |
| msgstr "xyz%lu" |
| # Invalid: type incompatibility |
| msgid "abc%s" |
| msgstr "xyz%L" |
| # Invalid: type incompatibility |
| msgid "abc%s" |
| msgstr "xyz%C" |
| # Invalid: type incompatibility |
| msgid "abc%i" |
| msgstr "xyz%u" |
| # Invalid: type incompatibility |
| msgid "abc%i" |
| msgstr "xyz%li" |
| # Invalid: type incompatibility |
| msgid "abc%i" |
| msgstr "xyz%lu" |
| # Invalid: type incompatibility |
| msgid "abc%i" |
| msgstr "xyz%L" |
| # Invalid: type incompatibility |
| msgid "abc%i" |
| msgstr "xyz%C" |
| # Invalid: type incompatibility |
| msgid "abc%u" |
| msgstr "xyz%li" |
| # Invalid: type incompatibility |
| msgid "abc%u" |
| msgstr "xyz%lu" |
| # Invalid: type incompatibility |
| msgid "abc%u" |
| msgstr "xyz%L" |
| # Invalid: type incompatibility |
| msgid "abc%u" |
| msgstr "xyz%C" |
| # Invalid: type incompatibility |
| msgid "abc%li" |
| msgstr "xyz%lu" |
| # Invalid: type incompatibility |
| msgid "abc%li" |
| msgstr "xyz%L" |
| # Invalid: type incompatibility |
| msgid "abc%li" |
| msgstr "xyz%C" |
| # Invalid: type incompatibility |
| msgid "abc%lu" |
| msgstr "xyz%L" |
| # Invalid: type incompatibility |
| msgid "abc%lu" |
| msgstr "xyz%C" |
| # Invalid: type incompatibility |
| msgid "abc%L" |
| msgstr "xyz%C" |
| # Invalid: permutation |
| msgid "abc%sdef%c" |
| msgstr "abc%cdef%s" |
| # Valid: currentloc reference position does not matter |
| msgid "abc%sdef%C" |
| msgstr "abc%Cdef%s" |
| # Valid: currentloc reference may be repeated |
| msgid "abc%sdef%C" |
| msgstr "abc%sdef%Cghi%C" |
| # Valid: currentloc reference may be repeated and permuted |
| msgid "abc%Cdef%Cghi%s" |
| msgstr "abc%sdef%C" |
| EOF |
| |
| : ${MSGFMT=msgfmt} |
| n=0 |
| while read comment; do |
| read msgid_line |
| read msgstr_line |
| n=`expr $n + 1` |
| cat <<EOF > f-gf-2-$n.po |
| #, gfc-internal-format |
| ${msgid_line} |
| ${msgstr_line} |
| EOF |
| fail= |
| if echo "$comment" | grep 'Valid:' > /dev/null; then |
| if ${MSGFMT} --check-format -o f-gf-2-$n.mo f-gf-2-$n.po; then |
| : |
| else |
| fail=yes |
| fi |
| else |
| ${MSGFMT} --check-format -o f-gf-2-$n.mo f-gf-2-$n.po 2> /dev/null |
| if test $? = 1; then |
| : |
| else |
| fail=yes |
| fi |
| fi |
| if test -n "$fail"; then |
| echo "Format string checking error:" 1>&2 |
| cat f-gf-2-$n.po 1>&2 |
| Exit 1 |
| fi |
| rm -f f-gf-2-$n.po f-gf-2-$n.mo |
| done < f-gf-2.data |
| |
| Exit 0 |