No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / format-c-2
blob4827e34cf311263c3698da4562f64023b0b55f1c
1 #! /bin/sh
3 # Test checking of C format strings.
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles="$tmpfiles f-c-2.data"
9 cat <<\EOF > f-c-2.data
10 # Valid: %% doesn't count
11 msgid "abc%%def"
12 msgstr "xyz"
13 # Invalid: invalid msgstr
14 msgid "abc%%def"
15 msgstr "xyz%"
16 # Valid: same arguments
17 msgid "abc%s%gdef"
18 msgstr "xyz%s%g"
19 # Valid: same arguments, with different widths
20 msgid "abc%2sdef"
21 msgstr "xyz%3s"
22 # Valid: same arguments but in numbered syntax
23 msgid "abc%s%gdef"
24 msgstr "xyz%1$s%2$g"
25 # Valid: permutation
26 msgid "abc%s%g%cdef"
27 msgstr "xyz%3$c%2$g%1$s"
28 # Invalid: too few arguments
29 msgid "abc%2$udef%1$s"
30 msgstr "xyz%1$s"
31 # Invalid: too few arguments
32 msgid "abc%sdef%u"
33 msgstr "xyz%s"
34 # Invalid: too many arguments
35 msgid "abc%udef"
36 msgstr "xyz%uvw%c"
37 # Valid: same numbered arguments, with different widths
38 msgid "abc%2$5s%1$4s"
39 msgstr "xyz%2$4s%1$5s"
40 # Invalid: missing argument
41 msgid "abc%2$sdef%1$u"
42 msgstr "xyz%1$u"
43 # Invalid: missing argument
44 msgid "abc%1$sdef%2$u"
45 msgstr "xyz%2$u"
46 # Invalid: added argument
47 msgid "abc%1$udef"
48 msgstr "xyz%1$uvw%2$c"
49 # Valid: type compatibility
50 msgid "abc%i"
51 msgstr "xyz%d"
52 # Valid: type compatibility
53 msgid "abc%o"
54 msgstr "xyz%u"
55 # Valid: type compatibility
56 msgid "abc%u"
57 msgstr "xyz%x"
58 # Valid: type compatibility
59 msgid "abc%u"
60 msgstr "xyz%X"
61 # Valid: type compatibility
62 msgid "abc%e"
63 msgstr "xyz%E"
64 # Valid: type compatibility
65 msgid "abc%e"
66 msgstr "xyz%f"
67 # Valid: type compatibility
68 msgid "abc%e"
69 msgstr "xyz%F"
70 # Valid: type compatibility
71 msgid "abc%e"
72 msgstr "xyz%g"
73 # Valid: type compatibility
74 msgid "abc%e"
75 msgstr "xyz%G"
76 # Valid: type compatibility
77 msgid "abc%e"
78 msgstr "xyz%a"
79 # Valid: type compatibility
80 msgid "abc%e"
81 msgstr "xyz%A"
82 # Invalid: type incompatibility
83 msgid "abc%c"
84 msgstr "xyz%s"
85 # Invalid: type incompatibility
86 msgid "abc%c"
87 msgstr "xyz%i"
88 # Invalid: type incompatibility
89 msgid "abc%c"
90 msgstr "xyz%o"
91 # Invalid: type incompatibility
92 msgid "abc%c"
93 msgstr "xyz%e"
94 # Invalid: type incompatibility
95 msgid "abc%c"
96 msgstr "xyz%p"
97 # Invalid: type incompatibility
98 msgid "abc%c"
99 msgstr "xyz%n"
100 # Invalid: type incompatibility
101 msgid "abc%s"
102 msgstr "xyz%i"
103 # Invalid: type incompatibility
104 msgid "abc%s"
105 msgstr "xyz%o"
106 # Invalid: type incompatibility
107 msgid "abc%s"
108 msgstr "xyz%e"
109 # Invalid: type incompatibility
110 msgid "abc%s"
111 msgstr "xyz%p"
112 # Invalid: type incompatibility
113 msgid "abc%s"
114 msgstr "xyz%n"
115 # Invalid: type incompatibility
116 msgid "abc%i"
117 msgstr "xyz%o"
118 # Invalid: type incompatibility
119 msgid "abc%i"
120 msgstr "xyz%e"
121 # Invalid: type incompatibility
122 msgid "abc%i"
123 msgstr "xyz%p"
124 # Invalid: type incompatibility
125 msgid "abc%i"
126 msgstr "xyz%n"
127 # Invalid: type incompatibility
128 msgid "abc%u"
129 msgstr "xyz%e"
130 # Invalid: type incompatibility
131 msgid "abc%u"
132 msgstr "xyz%p"
133 # Invalid: type incompatibility
134 msgid "abc%u"
135 msgstr "xyz%n"
136 # Invalid: type incompatibility
137 msgid "abc%e"
138 msgstr "xyz%p"
139 # Invalid: type incompatibility
140 msgid "abc%e"
141 msgstr "xyz%n"
142 # Invalid: type incompatibility
143 msgid "abc%p"
144 msgstr "xyz%n"
145 # Invalid: type incompatibility for width
146 msgid "abc%g%*g"
147 msgstr "xyz%*g%g"
150 : ${MSGFMT=msgfmt}
152 while read comment; do
153 read msgid_line
154 read msgstr_line
155 n=`expr $n + 1`
156 tmpfiles="$tmpfiles f-c-2-$n.po f-c-2-$n.mo"
157 cat <<EOF > f-c-2-$n.po
158 #, c-format
159 ${msgid_line}
160 ${msgstr_line}
162 fail=
163 if echo "$comment" | grep 'Valid:' > /dev/null; then
164 if ${MSGFMT} --check-format -o f-c-2-$n.mo f-c-2-$n.po; then
166 else
167 fail=yes
169 else
170 ${MSGFMT} --check-format -o f-c-2-$n.mo f-c-2-$n.po 2> /dev/null
171 if test $? = 1; then
173 else
174 fail=yes
177 if test -n "$fail"; then
178 echo "Format string checking error:" 1>&2
179 cat f-c-2-$n.po 1>&2
180 exit 1
182 rm -f f-c-2-$n.po f-c-2-$n.mo
183 done < f-c-2.data
185 rm -fr $tmpfiles
187 exit 0