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