1 1.1 christos #! /bin/sh 2 1.1 christos 3 1.1 christos # Test recognition of Perl brace 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-pb-1.data" 9 1.1 christos cat <<\EOF > f-pb-1.data 10 1.1 christos # Invalid: no argument 11 1.1 christos "abc" 12 1.1 christos # Valid: a named argument 13 1.1 christos "abc{value}" 14 1.1 christos # Invalid: an empty name 15 1.1 christos "abc{}" 16 1.1 christos # Invalid: unterminated name 17 1.1 christos "abc{value" 18 1.1 christos # Valid: three arguments, two with equal names 19 1.1 christos "abc{addr},{char},{addr}" 20 1.1 christos # Invalid: place-holder contains a space. 21 1.1 christos "{foo bar}" 22 1.1 christos # Invalid: missing right angle bracket. 23 1.1 christos "{foo bar" 24 1.1 christos # Valid: not nested, but one single place-holder. 25 1.1 christos "{foo{bar}baz}" 26 1.1 christos # Valid: no nesting error, but one single place-holder. 27 1.1 christos "{foo{bar}baz" 28 1.1 christos # Valid: place-holder with spaces must be ignored, but still one remaining. 29 1.1 christos "{foo bar} {baz}" 30 1.1 christos # Invalid: percent sign not allowed. 31 1.1 christos "{foo%bar}" 32 1.1 christos EOF 33 1.1 christos 34 1.1 christos : ${XGETTEXT=xgettext} 35 1.1 christos n=0 36 1.1 christos while read comment; do 37 1.1 christos read string 38 1.1 christos n=`expr $n + 1` 39 1.1 christos tmpfiles="$tmpfiles f-pb-1-$n.in f-pb-1-$n.po" 40 1.1 christos cat <<EOF > f-pb-1-$n.in 41 1.1 christos gettext(${string}); 42 1.1 christos EOF 43 1.1 christos ${XGETTEXT} -L Perl -o f-pb-1-$n.po f-pb-1-$n.in || exit 1 44 1.1 christos test -f f-pb-1-$n.po || exit 1 45 1.1 christos fail= 46 1.1 christos if echo "$comment" | grep 'Valid:' > /dev/null; then 47 1.1 christos if grep perl-brace-format f-pb-1-$n.po > /dev/null; then 48 1.1 christos : 49 1.1 christos else 50 1.1 christos fail=yes 51 1.1 christos fi 52 1.1 christos else 53 1.1 christos if grep perl-brace-format f-pb-1-$n.po > /dev/null; then 54 1.1 christos fail=yes 55 1.1 christos else 56 1.1 christos : 57 1.1 christos fi 58 1.1 christos fi 59 1.1 christos if test -n "$fail"; then 60 1.1 christos echo "Format string recognition error:" 1>&2 61 1.1 christos cat f-pb-1-$n.in 1>&2 62 1.1 christos echo "Got:" 1>&2 63 1.1 christos cat f-pb-1-$n.po 1>&2 64 1.1 christos exit 1 65 1.1 christos fi 66 1.1 christos rm -f f-pb-1-$n.in f-pb-1-$n.po 67 1.1 christos done < f-pb-1.data 68 1.1 christos 69 1.1 christos rm -fr $tmpfiles 70 1.1 christos 71 1.1 christos exit 0 72