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