1#! /bin/sh 2 3# Test recognition of Tcl format strings. 4 5tmpfiles="" 6trap 'rm -fr $tmpfiles' 1 2 3 15 7 8tmpfiles="$tmpfiles f-t-1.data" 9cat <<\EOF > f-t-1.data 10# Valid: no argument 11"abc%%" 12# Valid: one character argument 13"abc%c" 14# Valid: one string argument 15"abc%s" 16# Valid: one integer argument 17"abc%i" 18# Valid: one integer argument 19"abc%d" 20# Valid: one integer argument 21"abc%o" 22# Valid: one integer argument 23"abc%u" 24# Valid: one integer argument 25"abc%x" 26# Valid: one integer argument 27"abc%X" 28# Valid: one floating-point argument 29"abc%e" 30# Valid: one floating-point argument 31"abc%E" 32# Valid: one floating-point argument 33"abc%f" 34# Valid: one floating-point argument 35"abc%g" 36# Valid: one floating-point argument 37"abc%G" 38# Valid: one argument with flags 39"abc%0#g" 40# Valid: one argument with width 41"abc%2g" 42# Valid: one argument with width 43"abc%*g" 44# Valid: one argument with precision 45"abc%.4g" 46# Valid: one argument with precision 47"abc%.*g" 48# Valid: one argument with width and precision 49"abc%14.4g" 50# Valid: one argument with width and precision 51"abc%14.*g" 52# Valid: one argument with width and precision 53"abc%*.4g" 54# Valid: one argument with width and precision 55"abc%*.*g" 56# Invalid: unterminated 57"abc%" 58# Invalid: unknown format specifier 59"abc%y" 60# Invalid: unknown format specifier 61"abc%F" 62# Invalid: flags after width 63"abc%*0g" 64# Invalid: twice precision 65"abc%.4.2g" 66# Valid: three arguments 67"abc%d%u%u" 68# Valid: a numbered argument 69"abc%1$d" 70# Invalid: zero 71"abc%0$d" 72# Valid: two-digit numbered arguments 73"abc%11$def%10$dgh%9$dij%8$dkl%7$dmn%6$dop%5$dqr%4$dst%3$duv%2$dwx%1$dyz" 74# Invalid: unterminated number 75"abc%1" 76# Invalid: flags before number 77"abc%+1$d" 78# Valid: three arguments, two with same number 79"abc%1$4x,%2$c,%1$u" 80# Invalid: argument with conflicting types 81"abc%1$4x,%2$c,%1$s" 82# Valid: no conflict 83"abc%1$4x,%2$c,%1$u" 84# Invalid: mixing of numbered and unnumbered arguments 85"abc%d%2$x" 86# Valid: numbered argument with constant precision 87"abc%1$.9x" 88# Valid: * does mix with numbered arguments 89"abc%1$.*x" 90# Valid: missing non-final argument 91"abc%2$x%3$s" 92# Valid: permutation 93"abc%2$ddef%1$d" 94# Valid: multiple uses of same argument 95"abc%2$xdef%1$sghi%2$x" 96# Valid: one argument with width 97"abc%2$#*g" 98# Valid: one argument with width and precision 99"abc%3$*.*g" 100# Invalid: zero 101"abc%0$*.*g" 102EOF 103 104: ${XGETTEXT=xgettext} 105n=0 106while read comment; do 107 read string 108 n=`expr $n + 1` 109 tmpfiles="$tmpfiles f-t-1-$n.in f-t-1-$n.po" 110 escape_dollars='s/\$/\\\$/g' 111 string=`echo "$string" | sed -e "$escape_dollars"` 112 cat <<EOF > f-t-1-$n.in 113[msgcat::mc ${string}]; 114EOF 115 ${XGETTEXT} -L Tcl -o f-t-1-$n.po f-t-1-$n.in || exit 1 116 test -f f-t-1-$n.po || exit 1 117 fail= 118 if echo "$comment" | grep 'Valid:' > /dev/null; then 119 if grep tcl-format f-t-1-$n.po > /dev/null; then 120 : 121 else 122 fail=yes 123 fi 124 else 125 if grep tcl-format f-t-1-$n.po > /dev/null; then 126 fail=yes 127 else 128 : 129 fi 130 fi 131 if test -n "$fail"; then 132 echo "Format string recognition error:" 1>&2 133 cat f-t-1-$n.in 1>&2 134 echo "Got:" 1>&2 135 cat f-t-1-$n.po 1>&2 136 exit 1 137 fi 138 rm -f f-t-1-$n.in f-t-1-$n.po 139done < f-t-1.data 140 141rm -fr $tmpfiles 142 143exit 0 144