Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / format-elisp-2
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test checking of Emacs Lisp format strings.
5
6 cat <<\EOF > f-el-2.data
7 # Valid: %% doesn't count
8 msgid  "abc%%def"
9 msgstr "xyz"
10 # Invalid: invalid msgstr
11 msgid  "abc%%def"
12 msgstr "xyz%"
13 # Valid: same arguments
14 msgid  "abc%s%xdef"
15 msgstr "xyz%s%x"
16 # Valid: same arguments, with different widths
17 msgid  "abc%2sdef"
18 msgstr "xyz%3s"
19 # Valid: same arguments but in numbered syntax
20 msgid  "abc%s%xdef"
21 msgstr "xyz%1$s%2$x"
22 # Valid: permutation
23 msgid  "abc%s%x%cdef"
24 msgstr "xyz%3$c%2$x%1$s"
25 # Invalid: too few arguments
26 msgid  "abc%2$xdef%1$s"
27 msgstr "xyz%1$s"
28 # Invalid: too few arguments
29 msgid  "abc%sdef%x"
30 msgstr "xyz%s"
31 # Invalid: too many arguments
32 msgid  "abc%xdef"
33 msgstr "xyz%xvw%c"
34 # Valid: same numbered arguments, with different widths
35 msgid  "abc%2$5s%1$4s"
36 msgstr "xyz%2$4s%1$5s"
37 # Invalid: missing argument
38 msgid  "abc%2$sdef%1$x"
39 msgstr "xyz%1$x"
40 # Invalid: missing argument
41 msgid  "abc%1$sdef%2$x"
42 msgstr "xyz%2$x"
43 # Invalid: added argument
44 msgid  "abc%1$xdef"
45 msgstr "xyz%1$xvw%2$c"
46 # Valid: type compatibility
47 msgid  "abc%d"
48 msgstr "xyz%i"
49 # Valid: type compatibility
50 msgid  "abc%d"
51 msgstr "xyz%x"
52 # Valid: type compatibility
53 msgid  "abc%d"
54 msgstr "xyz%X"
55 # Valid: type compatibility
56 msgid  "abc%d"
57 msgstr "xyz%o"
58 # Valid: type compatibility
59 msgid  "abc%x"
60 msgstr "xyz%X"
61 # Valid: type compatibility
62 msgid  "abc%x"
63 msgstr "xyz%o"
64 # Valid: type compatibility
65 msgid  "abc%X"
66 msgstr "xyz%o"
67 # Valid: type compatibility
68 msgid  "abc%e"
69 msgstr "xyz%E"
70 # Valid: type compatibility
71 msgid  "abc%e"
72 msgstr "xyz%f"
73 # Valid: type compatibility
74 msgid  "abc%e"
75 msgstr "xyz%g"
76 # Valid: type compatibility
77 msgid  "abc%e"
78 msgstr "xyz%G"
79 # Invalid: type incompatibility
80 msgid  "abc%c"
81 msgstr "xyz%d"
82 # Invalid: type incompatibility
83 msgid  "abc%c"
84 msgstr "xyz%i"
85 # Invalid: type incompatibility
86 msgid  "abc%c"
87 msgstr "xyz%x"
88 # Invalid: type incompatibility
89 msgid  "abc%c"
90 msgstr "xyz%X"
91 # Invalid: type incompatibility
92 msgid  "abc%c"
93 msgstr "xyz%o"
94 # Invalid: type incompatibility
95 msgid  "abc%c"
96 msgstr "xyz%e"
97 # Invalid: type incompatibility
98 msgid  "abc%c"
99 msgstr "xyz%E"
100 # Invalid: type incompatibility
101 msgid  "abc%c"
102 msgstr "xyz%f"
103 # Invalid: type incompatibility
104 msgid  "abc%c"
105 msgstr "xyz%g"
106 # Invalid: type incompatibility
107 msgid  "abc%c"
108 msgstr "xyz%G"
109 # Invalid: type incompatibility
110 msgid  "abc%c"
111 msgstr "xyz%s"
112 # Invalid: type incompatibility
113 msgid  "abc%c"
114 msgstr "xyz%S"
115 # Invalid: type incompatibility
116 msgid  "abc%d"
117 msgstr "xyz%e"
118 # Invalid: type incompatibility
119 msgid  "abc%d"
120 msgstr "xyz%E"
121 # Invalid: type incompatibility
122 msgid  "abc%d"
123 msgstr "xyz%f"
124 # Invalid: type incompatibility
125 msgid  "abc%d"
126 msgstr "xyz%g"
127 # Invalid: type incompatibility
128 msgid  "abc%d"
129 msgstr "xyz%G"
130 # Invalid: type incompatibility
131 msgid  "abc%d"
132 msgstr "xyz%s"
133 # Invalid: type incompatibility
134 msgid  "abc%d"
135 msgstr "xyz%S"
136 # Invalid: type incompatibility
137 msgid  "abc%i"
138 msgstr "xyz%e"
139 # Invalid: type incompatibility
140 msgid  "abc%i"
141 msgstr "xyz%E"
142 # Invalid: type incompatibility
143 msgid  "abc%i"
144 msgstr "xyz%f"
145 # Invalid: type incompatibility
146 msgid  "abc%i"
147 msgstr "xyz%g"
148 # Invalid: type incompatibility
149 msgid  "abc%i"
150 msgstr "xyz%G"
151 # Invalid: type incompatibility
152 msgid  "abc%i"
153 msgstr "xyz%s"
154 # Invalid: type incompatibility
155 msgid  "abc%i"
156 msgstr "xyz%S"
157 # Invalid: type incompatibility
158 msgid  "abc%x"
159 msgstr "xyz%e"
160 # Invalid: type incompatibility
161 msgid  "abc%x"
162 msgstr "xyz%E"
163 # Invalid: type incompatibility
164 msgid  "abc%x"
165 msgstr "xyz%f"
166 # Invalid: type incompatibility
167 msgid  "abc%x"
168 msgstr "xyz%g"
169 # Invalid: type incompatibility
170 msgid  "abc%x"
171 msgstr "xyz%G"
172 # Invalid: type incompatibility
173 msgid  "abc%x"
174 msgstr "xyz%s"
175 # Invalid: type incompatibility
176 msgid  "abc%x"
177 msgstr "xyz%S"
178 # Invalid: type incompatibility
179 msgid  "abc%X"
180 msgstr "xyz%e"
181 # Invalid: type incompatibility
182 msgid  "abc%X"
183 msgstr "xyz%E"
184 # Invalid: type incompatibility
185 msgid  "abc%X"
186 msgstr "xyz%f"
187 # Invalid: type incompatibility
188 msgid  "abc%X"
189 msgstr "xyz%g"
190 # Invalid: type incompatibility
191 msgid  "abc%X"
192 msgstr "xyz%G"
193 # Invalid: type incompatibility
194 msgid  "abc%X"
195 msgstr "xyz%s"
196 # Invalid: type incompatibility
197 msgid  "abc%X"
198 msgstr "xyz%S"
199 # Invalid: type incompatibility
200 msgid  "abc%o"
201 msgstr "xyz%e"
202 # Invalid: type incompatibility
203 msgid  "abc%o"
204 msgstr "xyz%E"
205 # Invalid: type incompatibility
206 msgid  "abc%o"
207 msgstr "xyz%f"
208 # Invalid: type incompatibility
209 msgid  "abc%o"
210 msgstr "xyz%g"
211 # Invalid: type incompatibility
212 msgid  "abc%o"
213 msgstr "xyz%G"
214 # Invalid: type incompatibility
215 msgid  "abc%o"
216 msgstr "xyz%s"
217 # Invalid: type incompatibility
218 msgid  "abc%o"
219 msgstr "xyz%S"
220 # Invalid: type incompatibility
221 msgid  "abc%e"
222 msgstr "xyz%s"
223 # Invalid: type incompatibility
224 msgid  "abc%e"
225 msgstr "xyz%S"
226 # Invalid: type incompatibility
227 msgid  "abc%E"
228 msgstr "xyz%s"
229 # Invalid: type incompatibility
230 msgid  "abc%E"
231 msgstr "xyz%S"
232 # Invalid: type incompatibility
233 msgid  "abc%f"
234 msgstr "xyz%s"
235 # Invalid: type incompatibility
236 msgid  "abc%f"
237 msgstr "xyz%S"
238 # Invalid: type incompatibility
239 msgid  "abc%g"
240 msgstr "xyz%s"
241 # Invalid: type incompatibility
242 msgid  "abc%g"
243 msgstr "xyz%S"
244 # Invalid: type incompatibility
245 msgid  "abc%G"
246 msgstr "xyz%s"
247 # Invalid: type incompatibility
248 msgid  "abc%G"
249 msgstr "xyz%S"
250 # Invalid: type incompatibility
251 msgid  "abc%s"
252 msgstr "xyz%S"
253 EOF
254
255 : ${MSGFMT=msgfmt}
256 n=0
257 while read comment; do
258   read msgid_line
259   read msgstr_line
260   n=`expr $n + 1`
261   cat <<EOF > f-el-2-$n.po
262 #, elisp-format
263 ${msgid_line}
264 ${msgstr_line}
265 EOF
266   fail=
267   if echo "$comment" | grep 'Valid:' > /dev/null; then
268     if ${MSGFMT} --check-format -o f-el-2-$n.mo f-el-2-$n.po; then
269       :
270     else
271       fail=yes
272     fi
273   else
274     ${MSGFMT} --check-format -o f-el-2-$n.mo f-el-2-$n.po 2> /dev/null
275     if test $? = 1; then
276       :
277     else
278       fail=yes
279     fi
280   fi
281   if test -n "$fail"; then
282     echo "Format string checking error:" 1>&2
283     cat f-el-2-$n.po 1>&2
284     exit 1
285   fi
286   rm -f f-el-2-$n.po f-el-2-$n.mo
287 done < f-el-2.data
288
289 exit 0