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