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