1 1.1 christos #! /bin/sh 2 1.1 christos 3 1.1 christos # Test recognition of C# 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-cs-1.data" 9 1.1 christos cat <<\EOF > f-cs-1.data 10 1.1 christos # Valid: one argument 11 1.1 christos "abc{0}def" 12 1.1 christos # Valid: ten arguments 13 1.1 christos "abc{9}def" 14 1.1 christos # Valid: two-digit argument numbers 15 1.1 christos "abc{00}def" 16 1.1 christos # Valid: huge argument numbers 17 1.1 christos "abc{500000000}def" 18 1.1 christos # Invalid: unterminated 19 1.1 christos "abc{" 20 1.1 christos # Invalid: unterminated 21 1.1 christos "abc{0" 22 1.1 christos # Invalid: missing number 23 1.1 christos "abc{}def" 24 1.1 christos # Invalid: non-digit 25 1.1 christos "abc{number}def" 26 1.1 christos # Invalid: non-digit 27 1.1 christos "abc{-0}def" 28 1.1 christos # Valid: two arguments 29 1.1 christos "abc{1}def{0}" 30 1.1 christos # Valid: multiple uses of same argument 31 1.1 christos "abc{1}def{0}ghi{1}" 32 1.1 christos # Invalid: invalid width 33 1.1 christos "abc{0,}def" 34 1.1 christos # Invalid: invalid width 35 1.1 christos "abc{0,-}def" 36 1.1 christos # Valid: valid width 37 1.1 christos "abc{1,-7}def" 38 1.1 christos # Valid: format specifiers 39 1.1 christos "abc{1:Gx N}def" 40 1.1 christos # Valid: width and format specifiers 41 1.1 christos "abc{1,3:Gx N}def" 42 1.1 christos # Invalid: missing opening brace 43 1.1 christos "abc1}def{0}" 44 1.1 christos # Invalid: quoted brace 45 1.1 christos "abc1'}'def{0}" 46 1.1 christos # Valid: doubled brace 47 1.1 christos "abc1}}def{0}" 48 1.1 christos # Invalid: doubled brace doesn't start a directive 49 1.1 christos "abc{{0}def" 50 1.1 christos EOF 51 1.1 christos 52 1.1 christos : ${XGETTEXT=xgettext} 53 1.1 christos n=0 54 1.1 christos while read comment; do 55 1.1 christos read string 56 1.1 christos n=`expr $n + 1` 57 1.1 christos tmpfiles="$tmpfiles f-cs-1-$n.in f-cs-1-$n.po" 58 1.1 christos cat <<EOF > f-cs-1-$n.in 59 1.1 christos GetString(${string}); 60 1.1 christos EOF 61 1.1 christos ${XGETTEXT} -L C# -o f-cs-1-$n.po f-cs-1-$n.in || exit 1 62 1.1 christos test -f f-cs-1-$n.po || exit 1 63 1.1 christos fail= 64 1.1 christos if echo "$comment" | grep 'Valid:' > /dev/null; then 65 1.1 christos if grep csharp-format f-cs-1-$n.po > /dev/null; then 66 1.1 christos : 67 1.1 christos else 68 1.1 christos fail=yes 69 1.1 christos fi 70 1.1 christos else 71 1.1 christos if grep csharp-format f-cs-1-$n.po > /dev/null; then 72 1.1 christos fail=yes 73 1.1 christos else 74 1.1 christos : 75 1.1 christos fi 76 1.1 christos fi 77 1.1 christos if test -n "$fail"; then 78 1.1 christos echo "Format string recognition error:" 1>&2 79 1.1 christos cat f-cs-1-$n.in 1>&2 80 1.1 christos echo "Got:" 1>&2 81 1.1 christos cat f-cs-1-$n.po 1>&2 82 1.1 christos exit 1 83 1.1 christos fi 84 1.1 christos rm -f f-cs-1-$n.in f-cs-1-$n.po 85 1.1 christos done < f-cs-1.data 86 1.1 christos 87 1.1 christos rm -fr $tmpfiles 88 1.1 christos 89 1.1 christos exit 0 90