1#! /bin/sh 2 3# Test recognition of YCP format strings. 4 5tmpfiles="" 6trap 'rm -fr $tmpfiles' 1 2 3 15 7 8tmpfiles="$tmpfiles f-y-1.data" 9cat <<\EOF > f-y-1.data 10# Valid: no argument 11"abc%%def" 12# Valid: one argument 13"abc%1def" 14# Valid: nine arguments 15"abc%9def" 16# Invalid: unterminated 17"abc%%def%" 18# Invalid: non-digit 19"abc%%def%x" 20# Invalid: zero 21"abc%%def%0" 22# Valid: permutation 23"abc%2def%1" 24# Valid: multiple uses of same argument 25"abc%2def%1ghi%2" 26EOF 27 28: ${XGETTEXT=xgettext} 29n=0 30while read comment; do 31 read string 32 n=`expr $n + 1` 33 tmpfiles="$tmpfiles f-y-1-$n.in f-y-1-$n.po" 34 cat <<EOF > f-y-1-$n.in 35_(${string}); 36EOF 37 ${XGETTEXT} -L YCP -o f-y-1-$n.po f-y-1-$n.in || exit 1 38 test -f f-y-1-$n.po || exit 1 39 fail= 40 if echo "$comment" | grep 'Valid:' > /dev/null; then 41 if grep ycp-format f-y-1-$n.po > /dev/null; then 42 : 43 else 44 fail=yes 45 fi 46 else 47 if grep ycp-format f-y-1-$n.po > /dev/null; then 48 fail=yes 49 else 50 : 51 fi 52 fi 53 if test -n "$fail"; then 54 echo "Format string recognition error:" 1>&2 55 cat f-y-1-$n.in 1>&2 56 echo "Got:" 1>&2 57 cat f-y-1-$n.po 1>&2 58 exit 1 59 fi 60 rm -f f-y-1-$n.in f-y-1-$n.po 61done < f-y-1.data 62 63rm -fr $tmpfiles 64 65exit 0 66