1#! /bin/sh 2. "${srcdir=.}/init.sh"; path_prepend_ . ../src 3 4# Test recognition of Lua format strings. 5 6cat <<\EOF > f-lu-1.data 7# Valid: no argument 8"abc%%" 9# Valid: one string argument 10"abc%s" 11# Valid: one string argument 12"abc%q" 13# Valid: one character argument 14"abc%c" 15# Valid: one integer argument 16"abc%i" 17# Valid: one integer argument 18"abc%d" 19# Valid: one integer argument 20"abc%o" 21# Valid: one integer argument 22"abc%u" 23# Valid: one integer argument 24"abc%X" 25# Valid: one integer argument 26"abc%x" 27# Valid: one float argument 28"abc%e" 29# Valid: one float argument 30"abc%E" 31# Valid: one float argument 32"abc%f" 33# Valid: one float argument 34"abc%g" 35# Valid: one float argument 36"abc%G" 37# Valid: one float argument with width 38"abc%4f" 39# Valid: one float argument with precision 40"abc%.8f" 41# Valid: one float argument with width and precision 42"abc%12.4f" 43# Valid: three arguments 44"abc%c%d%e" 45# Valid: three arguments with width and/or precision 46"abc%4.3s%.3f%0e" 47# Invalid: unterminated 48"abc%" 49# Invalid: unknown format specifier 50"abc%T" 51# Invalid: unknown modifier 52"abc%lf" 53# Invalid: extra precision 54"abc%1.1.1f" 55# Invalid: unterminated 56"abc%3" 57EOF 58: ${XGETTEXT=xgettext} 59n=0 60while read comment; do 61 read string 62 n=`expr $n + 1` 63 echo "gettext.gettext(${string});" > f-lu-1-$n.in 64 ${XGETTEXT} -L Lua -o f-lu-1-$n.po f-lu-1-$n.in || Exit 1 65 test -f f-lu-1-$n.po || Exit 1 66 fail= 67 if echo "$comment" | grep 'Valid:' > /dev/null; then 68 if grep lua-format f-lu-1-$n.po > /dev/null; then 69 : 70 else 71 fail=yes 72 fi 73 else 74 if grep lua-format f-lu-1-$n.po > /dev/null; then 75 fail=yes 76 else 77 : 78 fi 79 fi 80 if test -n "$fail"; then 81 echo "Format string recognition error:" 1>&2 82 cat f-lu-1-$n.in 1>&2 83 echo "Got:" 1>&2 84 cat f-lu-1-$n.po 1>&2 85 Exit 1 86 fi 87 rm -f f-lu-1-$n.in f-lu-1-$n.po 88done < f-lu-1.data 89 90Exit 0 91 92