1#! /bin/sh 2. "${srcdir=.}/init.sh"; path_prepend_ . ../src 3 4# Test recognition of awk format strings. 5 6cat <<\EOF > f-a-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# Invalid: mixing of numbered and unnumbered 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$#*1$g" 95# Valid: one argument with width and precision 96"abc%3$*2$.*1$g" 97# Invalid: zero 98"abc%2$*0$.*1$g" 99EOF 100 101: ${XGETTEXT=xgettext} 102n=0 103while read comment; do 104 read string 105 n=`expr $n + 1` 106 cat <<EOF > f-a-1-$n.in 107dcgettext(${string}); 108EOF 109 ${XGETTEXT} -L awk -o f-a-1-$n.po f-a-1-$n.in || Exit 1 110 test -f f-a-1-$n.po || Exit 1 111 fail= 112 if echo "$comment" | grep 'Valid:' > /dev/null; then 113 if grep awk-format f-a-1-$n.po > /dev/null; then 114 : 115 else 116 fail=yes 117 fi 118 else 119 if grep awk-format f-a-1-$n.po > /dev/null; then 120 fail=yes 121 else 122 : 123 fi 124 fi 125 if test -n "$fail"; then 126 echo "Format string recognition error:" 1>&2 127 cat f-a-1-$n.in 1>&2 128 echo "Got:" 1>&2 129 cat f-a-1-$n.po 1>&2 130 Exit 1 131 fi 132 rm -f f-a-1-$n.in f-a-1-$n.po 133done < f-a-1.data 134 135Exit 0 136