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