1 1.1 christos #! /bin/sh 2 1.1 christos 3 1.1 christos # Test checking of YCP format strings. 4 1.1 christos 5 1.1 christos tmpfiles="" 6 1.1 christos trap 'rm -fr $tmpfiles' 1 2 3 15 7 1.1 christos 8 1.1 christos tmpfiles="$tmpfiles f-y-2.data" 9 1.1 christos cat <<\EOF > f-y-2.data 10 1.1 christos # Valid: %% doesn't count 11 1.1 christos msgid "abc%%def" 12 1.1 christos msgstr "xyz" 13 1.1 christos # Invalid: invalid msgstr 14 1.1 christos msgid "abc%%def" 15 1.1 christos msgstr "xyz%" 16 1.1 christos # Valid: same arguments 17 1.1 christos msgid "abc%2def" 18 1.1 christos msgstr "xyz%2" 19 1.1 christos # Valid: permutation 20 1.1 christos msgid "abc%3%1%2def" 21 1.1 christos msgstr "xyz%2%1%3" 22 1.1 christos # Invalid: too few arguments 23 1.1 christos msgid "abc%2def%1" 24 1.1 christos msgstr "xyz%1" 25 1.1 christos # Invalid: too many arguments 26 1.1 christos msgid "abc%1def" 27 1.1 christos msgstr "xyz%1uvw%2" 28 1.1 christos # Invalid: missing non-final argument 29 1.1 christos msgid "abc%2def%1" 30 1.1 christos msgstr "xyz%2" 31 1.1 christos # Invalid: added non-final argument 32 1.1 christos msgid "abc%2def" 33 1.1 christos msgstr "xyz%1%2" 34 1.1 christos EOF 35 1.1 christos 36 1.1 christos : ${MSGFMT=msgfmt} 37 1.1 christos n=0 38 1.1 christos while read comment; do 39 1.1 christos read msgid_line 40 1.1 christos read msgstr_line 41 1.1 christos n=`expr $n + 1` 42 1.1 christos tmpfiles="$tmpfiles f-y-2-$n.po f-y-2-$n.mo" 43 1.1 christos cat <<EOF > f-y-2-$n.po 44 1.1 christos #, ycp-format 45 1.1 christos ${msgid_line} 46 1.1 christos ${msgstr_line} 47 1.1 christos EOF 48 1.1 christos fail= 49 1.1 christos if echo "$comment" | grep 'Valid:' > /dev/null; then 50 1.1 christos if ${MSGFMT} --check-format -o f-y-2-$n.mo f-y-2-$n.po; then 51 1.1 christos : 52 1.1 christos else 53 1.1 christos fail=yes 54 1.1 christos fi 55 1.1 christos else 56 1.1 christos ${MSGFMT} --check-format -o f-y-2-$n.mo f-y-2-$n.po 2> /dev/null 57 1.1 christos if test $? = 1; then 58 1.1 christos : 59 1.1 christos else 60 1.1 christos fail=yes 61 1.1 christos fi 62 1.1 christos fi 63 1.1 christos if test -n "$fail"; then 64 1.1 christos echo "Format string checking error:" 1>&2 65 1.1 christos cat f-y-2-$n.po 1>&2 66 1.1 christos exit 1 67 1.1 christos fi 68 1.1 christos rm -f f-y-2-$n.po f-y-2-$n.mo 69 1.1 christos done < f-y-2.data 70 1.1 christos 71 1.1 christos rm -fr $tmpfiles 72 1.1 christos 73 1.1 christos exit 0 74