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