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