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