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