• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test recognition of Java printf format strings.
5
6cat <<\EOF > f-jp-1.data
7# Valid: no argument
8"abc%%"
9# Valid: one general argument
10"abc%b"
11# Valid: one general argument
12"abc%B"
13# Valid: one general argument
14"abc%h"
15# Valid: one general argument
16"abc%H"
17# Valid: one general argument
18"abc%s"
19# Valid: one general argument
20"abc%S"
21# Valid: one character argument
22"abc%c"
23# Valid: one character argument
24"abc%C"
25# Valid: one integer argument
26"abc%d"
27# Valid: one integer argument
28"abc%o"
29# Valid: one integer argument
30"abc%x"
31# Valid: one integer argument
32"abc%X"
33# Valid: one floating-point argument
34"abc%e"
35# Valid: one floating-point argument
36"abc%E"
37# Valid: one floating-point argument
38"abc%f"
39# Valid: one floating-point argument
40"abc%g"
41# Valid: one floating-point argument
42"abc%G"
43# Valid: one floating-point argument
44"abc%a"
45# Valid: one floating-point argument
46"abc%A"
47# Valid: one argument with flags
48"abc%0#g"
49# Valid: one argument with width
50"abc%2g"
51# Invalid: variable width
52"abc%*g"
53# Valid: one argument with precision
54"abc%.4g"
55# Invalid: missing precision
56"abc%.g"
57# Invalid: variable precision
58"abc%.*g"
59# Valid: one argument with width and precision
60"abc%14.4g"
61# Invalid: unterminated
62"abc%"
63# Invalid: unterminated
64"abc%t"
65# Invalid: unknown format specifier
66"abc%y"
67# Invalid: flags after width
68"abc%2#d"
69# Invalid: twice precision
70"abc%.4.2g"
71# Valid: three arguments
72"abc%d%x%x"
73# Valid: a numbered argument
74"abc%1$d"
75# Invalid: zero
76"abc%0$d"
77# Valid: two-digit numbered arguments
78"abc%11$def%10$dgh%9$dij%8$dkl%7$dmn%6$dop%5$dqr%4$dst%3$duv%2$dwx%1$dyz"
79# Invalid: unterminated number
80"abc%1"
81# Invalid: flags before number
82"abc%#1$g"
83# Valid: three arguments, two with same number
84"abc%1$4x,%2$c,%1$X"
85# Invalid: argument with conflicting types
86"abc%1$4x,%2$c,%1$s"
87# Valid: no conflict
88"abc%1$4x,%2$c,%1$d"
89# Valid: mixing of numbered and unnumbered arguments
90"abc%d%2$x"
91# Valid: mixing of numbered and unnumbered arguments
92"abc%5$d%x"
93# Valid: mixing of numbered and unnumbered arguments, no type conflict
94"abc%2$c%x%c%g"
95# Invalid: mixing of numbered and unnumbered arguments, argument with conflicting types
96"abc%2$c%x%g%c"
97# Valid: numbered argument with width
98"abc%2$#5g"
99# Valid: numbered argument with precision
100"abc%1$.9g"
101# Valid: numbered argument with width and precision
102"abc%3$5.2g"
103# Valid: missing non-final argument
104"abc%2$x%3$s"
105# Valid: permutation
106"abc%2$ddef%1$d"
107# Valid: multiple uses of same argument
108"abc%2$xdef%1$Sghi%2$x"
109# Valid: reference to last argument
110"abc%x%<o"
111# Valid: reference to last argument
112"abc%2$x%<o"
113# Invalid: reference to last argument when there was none
114"abc%%%<d"
115# Invalid: last argument refers to argument 3, conflicting types
116"abc%x%3$g%<d"
117# Invalid: last argument refers to argument 1, conflicting types
118"abc%3$g%x%<g"
119# Invalid: conflicting types
120"abc%s%<c"
121# Invalid: conflicting types
122"abc%s%<d"
123# Invalid: conflicting types
124"abc%s%<f"
125# Invalid: conflicting types
126"abc%s%<tF"
127# Invalid: conflicting types
128"abc%c%<d"
129# Invalid: conflicting types
130"abc%c%<f"
131# Invalid: conflicting types
132"abc%c%<tF"
133# Invalid: conflicting types
134"abc%d%<f"
135# Invalid: conflicting types
136"abc%d%<tF"
137# Invalid: conflicting types
138"abc%f%<tF"
139# Valid: combination of flag and conversion
140"abc%-%"
141# Invalid: combination of flag and conversion
142"abc%#%"
143# Invalid: combination of flag and conversion
144"abc%+%"
145# Invalid: combination of flag and conversion
146"abc% %"
147# Invalid: combination of flag and conversion
148"abc%0%"
149# Invalid: combination of flag and conversion
150"abc%,%"
151# Invalid: combination of flag and conversion
152"abc%(%"
153# Valid: combination of width and conversion
154"abc%5%"
155# Invalid: combination of precision and conversion
156"abc%.2%"
157# Invalid: combination of flag and conversion
158"abc%-n"
159# Invalid: combination of flag and conversion
160"abc%#n"
161# Invalid: combination of flag and conversion
162"abc%+n"
163# Invalid: combination of flag and conversion
164"abc% n"
165# Invalid: combination of flag and conversion
166"abc%0n"
167# Invalid: combination of flag and conversion
168"abc%,n"
169# Invalid: combination of flag and conversion
170"abc%(n"
171# Invalid: combination of width and conversion
172"abc%5n"
173# Invalid: combination of precision and conversion
174"abc%.2n"
175# Valid: combination of flag and conversion
176"abc%-s"
177# Valid: combination of flag and conversion
178"abc%#s"
179# Invalid: combination of flag and conversion
180"abc%+s"
181# Invalid: combination of flag and conversion
182"abc% s"
183# Invalid: combination of flag and conversion
184"abc%0s"
185# Invalid: combination of flag and conversion
186"abc%,s"
187# Invalid: combination of flag and conversion
188"abc%(s"
189# Valid: combination of width and conversion
190"abc%5s"
191# Valid: combination of precision and conversion
192"abc%.2s"
193# Valid: combination of flag and conversion
194"abc%-c"
195# Invalid: combination of flag and conversion
196"abc%#c"
197# Invalid: combination of flag and conversion
198"abc%+c"
199# Invalid: combination of flag and conversion
200"abc% c"
201# Invalid: combination of flag and conversion
202"abc%0c"
203# Invalid: combination of flag and conversion
204"abc%,c"
205# Invalid: combination of flag and conversion
206"abc%(c"
207# Valid: combination of width and conversion
208"abc%5c"
209# Invalid: combination of precision and conversion
210"abc%.2c"
211# Valid: combination of flag and conversion
212"abc%-d"
213# Invalid: combination of flag and conversion
214"abc%#d"
215# Valid: combination of flag and conversion
216"abc%+d"
217# Valid: combination of flag and conversion
218"abc% d"
219# Valid: combination of flag and conversion
220"abc%0d"
221# Valid: combination of flag and conversion
222"abc%,d"
223# Valid: combination of flag and conversion
224"abc%(d"
225# Valid: combination of width and conversion
226"abc%5d"
227# Invalid: combination of precision and conversion
228"abc%.2d"
229# Valid: combination of flag and conversion
230"abc%-o"
231# Valid: combination of flag and conversion
232"abc%#o"
233# Valid: combination of flag and conversion
234"abc%+o"
235# Valid: combination of flag and conversion
236"abc% o"
237# Valid: combination of flag and conversion
238"abc%0o"
239# Invalid: combination of flag and conversion
240"abc%,o"
241# Valid: combination of flag and conversion
242"abc%(o"
243# Valid: combination of width and conversion
244"abc%5o"
245# Invalid: combination of precision and conversion
246"abc%.2o"
247# Valid: combination of flag and conversion
248"abc%-e"
249# Valid: combination of flag and conversion
250"abc%#e"
251# Valid: combination of flag and conversion
252"abc%+e"
253# Valid: combination of flag and conversion
254"abc% e"
255# Valid: combination of flag and conversion
256"abc%0e"
257# Valid: combination of flag and conversion
258"abc%,e"
259# Valid: combination of flag and conversion
260"abc%(e"
261# Valid: combination of width and conversion
262"abc%5e"
263# Valid: combination of precision and conversion
264"abc%.2e"
265# Valid: combination of flag and conversion
266"abc%-a"
267# Valid: combination of flag and conversion
268"abc%#a"
269# Valid: combination of flag and conversion
270"abc%+a"
271# Valid: combination of flag and conversion
272"abc% a"
273# Valid: combination of flag and conversion
274"abc%0a"
275# Invalid: combination of flag and conversion
276"abc%,a"
277# Invalid: combination of flag and conversion
278"abc%(a"
279# Valid: combination of width and conversion
280"abc%5a"
281# Valid: combination of precision and conversion
282"abc%.2a"
283# Valid: combination of flag and conversion
284"abc%-tF"
285# Invalid: combination of flag and conversion
286"abc%#tF"
287# Invalid: combination of flag and conversion
288"abc%+tF"
289# Invalid: combination of flag and conversion
290"abc% tF"
291# Invalid: combination of flag and conversion
292"abc%0tF"
293# Invalid: combination of flag and conversion
294"abc%,tF"
295# Invalid: combination of flag and conversion
296"abc%(tF"
297# Valid: combination of width and conversion
298"abc%5tF"
299# Invalid: combination of precision and conversion
300"abc%.2tF"
301EOF
302
303: ${XGETTEXT=xgettext}
304n=0
305while read comment; do
306  read string
307  n=`expr $n + 1`
308  cat <<EOF > f-jp-1-$n.in
309gettext(${string});
310EOF
311  ${XGETTEXT} -L Java -o f-jp-1-$n.po f-jp-1-$n.in || Exit 1
312  test -f f-jp-1-$n.po || Exit 1
313  fail=
314  if echo "$comment" | grep 'Valid:' > /dev/null; then
315    if grep java-printf-format f-jp-1-$n.po > /dev/null; then
316      :
317    else
318      fail=yes
319    fi
320  else
321    if grep java-printf-format f-jp-1-$n.po > /dev/null; then
322      fail=yes
323    else
324      :
325    fi
326  fi
327  if test -n "$fail"; then
328    echo "Format string recognition error:" 1>&2
329    cat f-jp-1-$n.in 1>&2
330    echo "Got:" 1>&2
331    cat f-jp-1-$n.po 1>&2
332    Exit 1
333  fi
334  rm -f f-jp-1-$n.in f-jp-1-$n.po
335done < f-jp-1.data
336
337Exit 0
338