• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test recognition of Lisp format strings.
5
6cat <<\EOF > f-l-1.data
7# Valid: no argument, ( | . *)
8"abc~~def"
9# Valid: one argument, (* | . *)
10"abc~Sdef"
11# Valid: 11 arguments, (* * * * * * * * * * * | . *)
12"abc~10@*~Sdef"
13# Invalid: unterminated
14"abc~~def~"
15# Invalid: unterminated
16"abc~~def~1"
17# Invalid: unterminated
18"abc~~def~:"
19# Invalid: unterminated
20"abc~~def~@"
21# Valid: colon
22"abc~:Sdef"
23# Valid: atsign
24"abc~@Sdef"
25# Valid: colon and atsign
26"abc~:@Sdef"
27# Valid: atsign and colon
28"abc~@:Sdef"
29# Valid: params before atsign and colon
30"abc~3,-4,,'*@:Sdef"
31# Invalid: params after atsign and colon
32"abc~@:3,-4Sdef"
33# Invalid: params after atsign and colon
34"abc~@:-4Sdef"
35# Invalid: params after atsign and colon
36"abc~@:,-4Sdef"
37# Valid: V and # params, (i() * | . *)
38"abc~#,vSdef"
39# Invalid: wrong type params
40"abc~,'*Sdef"
41# Valid: FORMAT-ASCII, (i() i() i() c() * | . *)
42"abc~v,v,v,vA"
43# Invalid: too many params
44"abc~v,v,v,v,5A"
45# Valid: FORMAT-S-EXPRESSION, (i() i() i() c() * | . *)
46"abc~v,v,v,vS"
47# Invalid: too many params
48"abc~v,v,v,v,5S"
49# Valid: FORMAT-WRITE, (* | . *)
50"abc~W"
51# Invalid: too many params
52"abc~3W"
53# Valid: FORMAT-DECIMAL, (i() c() c() i() i | . *)
54"abc~v,v,v,vD"
55# Invalid: too many params
56"abc~v,v,v,v,5D"
57# Valid: FORMAT-BINARY, (i() c() c() i() i | . *)
58"abc~v,v,v,vB"
59# Invalid: too many params
60"abc~v,v,v,v,5B"
61# Valid: FORMAT-OCTAL, (i() c() c() i() i | . *)
62"abc~v,v,v,vO"
63# Invalid: too many params
64"abc~v,v,v,v,5O"
65# Valid: FORMAT-HEXADECIMAL, (i() c() c() i() i | . *)
66"abc~v,v,v,vX"
67# Invalid: too many params
68"abc~v,v,v,v,5X"
69# Valid: FORMAT-RADIX, (i() i() c() c() i() i | . *)
70"abc~v,v,v,v,vR"
71# Invalid: too many params
72"abc~v,v,v,v,v,5R"
73# Valid: FORMAT-PLURAL, (* | . *)
74"abc~P"
75# Valid: FORMAT-PLURAL, (i | . *)
76"abc~R egg~:P"
77# Invalid: too many params
78"abc~2P"
79# Valid: FORMAT-CHARACTER, (c | . *)
80"abc~C"
81# Invalid: too many params
82"abc~4C"
83# Valid: FORMAT-FIXED-FLOAT, (i() i() i() c() c() r | . *)
84"abc~v,v,v,v,vF"
85# Invalid: too many params
86"abc~v,v,v,v,v,5F"
87# Valid: FORMAT-EXPONENTIAL-FLOAT, (i() i() i() i() c() c() c() r | . *)
88"abc~v,v,v,v,v,v,vE"
89# Invalid: too many params
90"abc~v,v,v,v,v,v,v,5E"
91# Valid: FORMAT-GENERAL-FLOAT, (i() i() i() i() c() c() c() r | . *)
92"abc~v,v,v,v,v,v,vG"
93# Invalid: too many params
94"abc~v,v,v,v,v,v,v,5G"
95# Valid: FORMAT-DOLLARS-FLOAT, (i() i() i() c() r | . *)
96"abc~v,v,v,v$"
97# Invalid: too many params
98"abc~v,v,v,v,5$"
99# Valid: FORMAT-TERPRI, (i() | . *)
100"abc~v%"
101# Invalid: too many params
102"abc~v,5%"
103# Valid: FORMAT-FRESH-LINE, (i() | . *)
104"abc~v&"
105# Invalid: too many params
106"abc~v,5&"
107# Valid: FORMAT-PAGE, (i() | . *)
108"abc~v|"
109# Invalid: too many params
110"abc~v,5|"
111# Valid: FORMAT-TILDE, (i() | . *)
112"abc~v~"
113# Invalid: too many params
114"abc~v,5~"
115# Valid: underscore, ( | . *)
116"abc~_"
117# Invalid: too many params
118"abc~5_"
119# Valid: FORMAT-TABULATE, (i() i() | . *)
120"abc~v,vT"
121# Invalid: too many params
122"abc~v,v,5T"
123# Valid: FORMAT-GOTO absolute, (* r c | . *)
124"abc~S~F~S~2@*~C"
125# Invalid: type incompatibility
126"abc~S~F~S~1@*~C"
127# Valid: FORMAT-GOTO backward, (* c r | . *)
128"abc~S~S~F~2:*~C"
129# Invalid: type incompatibility
130"abc~S~S~F~1:*~C"
131# Invalid: too many params
132"abc~v,4*"
133# Valid: FORMAT-GOTO with large number
134"abc~S~F~S~1000000@*~C"
135# Valid: FORMAT-INDIRECTION, (~ ( | . *) | . *)
136"abc~?"
137# Valid: FORMAT-INDIRECTION, (~ | . *)
138"abc~@?"
139# Invalid: too many params
140"abc~4?"
141# Valid: FORMAT-CALL-USER-FUNCTION, (* | . *)
142"abc~/FOOBAR/"
143# Invalid: too many params
144"abc~4/FOOBAR/"
145# Invalid: unterminated
146"abc~/FOOB"
147# Invalid: nesting mismatch
148"abc~(~/FOOB~)/"
149# Valid: FORMAT-CASE-CONVERSION, (* | . *)
150"abc~(~S~)"
151# Invalid: too many params
152"abc~4(~S~)"
153# Invalid: too many params
154"abc~(~S~4)"
155# Invalid: unterminated
156"abc~(~S"
157# Invalid: separator
158"abc~(~S~;~S~)"
159# Valid: FORMAT-CONDITIONAL, (i() c | . *)
160"abc~@[~D~]~C"
161# Valid: FORMAT-CONDITIONAL, (i() | . *)
162"abc~@[~D~D~]~C"
163# Invalid: separator
164"abc~@[~D~;~D~]~C"
165# Valid: FORMAT-CONDITIONAL, (* i c | . *)
166"abc~:[~X~;~D~]~C"
167# Invalid: missing separator
168"abc~:[~D~]~C"
169# Invalid: too many separators
170"abc~:[~X~;~D~;~E~]~C"
171# Valid: FORMAT-CONDITIONAL, (* | . *)
172"abc~[~D~;~X~]~C"
173# Valid: FORMAT-CONDITIONAL, (* i c | . *)
174"abc~[~D~;~X~:;~R~]~C"
175# Invalid: default clause not last
176"abc~[~D~;~X~:;~R~;~R~]~C"
177# Invalid: too many params
178"abc~4@[~D~]"
179# Invalid: too many params
180"abc~@[~D~4]"
181# Invalid: too many params
182"abc~4:[~D~;~X~]"
183# Invalid: too many params
184"abc~:[~D~4;~X~]"
185# Invalid: too many params
186"abc~:[~D~;~X~4]"
187# Valid: FORMAT-CONDITIONAL, one param, without colon or atsign
188"abc~4[~D~;~X~]"
189# Invalid: too many params
190"abc~4,4[~D~;~X~]"
191# Invalid: too many params
192"abc~[~D~4;~X~]"
193# Invalid: too many params
194"abc~[~D~;~X~4]"
195# Valid: FORMAT-ITERATION, (( | . *) | . *)
196"abc~{~~~}"
197# Valid: FORMAT-ITERATION, (( | . ( | . *)) | . *)
198"abc~:{~~~}"
199# Valid: FORMAT-ITERATION, ( | . *)
200"abc~@{~~~}"
201# Valid: FORMAT-ITERATION, ( | . ( | . *))
202"abc~:@{~~~}"
203# Valid: FORMAT-ITERATION with indirection, (~ ( | . *) | . *)
204"abc~{~}"
205# Valid: FORMAT-ITERATION with indirection, (~ ( | . ( | . *)) | . *)
206"abc~:{~}"
207# Valid: FORMAT-ITERATION with indirection, (~ | . *)
208"abc~@{~}"
209# Valid: FORMAT-ITERATION with indirection, (~ | . ( | . *))
210"abc~:@{~}"
211# Valid: FORMAT-ITERATION with loop, (( | . i c) | . *)
212"abc~{~D ~C~}"
213# Valid: FORMAT-ITERATION with loop, (( | . (i c | . *)) | . *)
214"abc~:{~D ~C~}"
215# Valid: FORMAT-ITERATION with loop, ( | . i c)
216"abc~@{~D ~C~}"
217# Valid: FORMAT-ITERATION with loop, ( | . (i c | . *))
218"abc~:@{~D ~C~}"
219# Valid: FORMAT-ITERATION with variable-advance loop, (( | . *) | . *)
220"abc~{~[~D~]~}"
221# Valid: FORMAT-ITERATION with variable-advance loop, (( | . (* | . *)) | . *)
222"abc~:{~[~D~]~}"
223# Valid: FORMAT-ITERATION with variable-advance loop, ( | . *)
224"abc~@{~[~D~]~}"
225# Valid: FORMAT-ITERATION with variable-advance loop, ( | . (* | . *))
226"abc~:@{~[~D~]~}"
227# Invalid: separator
228"abc~{~D~;~C~}"
229# Valid: FORMAT-JUSTIFICATION, (i() i() i() c() i | . *)
230"abc~v,v,v,v<~D~>"
231# Invalid: too many params
232"abc~v,v,v,v,4<~D~>"
233# Valid: separators
234"abc~<~D~;~X~;def~>"
235# Invalid: wrongly nested
236"abc~<~(~>~)"
237# Invalid: wrongly nested
238"abc~{~(~}~)"
239# Invalid: wrongly nested
240"abc~{~<~}~>"
241# Valid: FORMAT-CALL, (f * | . *)
242"abc~!"
243# Valid: any number of arguments
244"abc~v,v,v,v,v!"
245# Invalid: type incompatibility between integer and list
246"abc~D~:*~{~D~}"
247# Invalid: type incompatibility between real and list
248"abc~{~S~}~:*~F"
249# Valid: list must be empty
250"abc~{~C~}~:*~{~D~}"
251EOF
252
253: ${XGETTEXT=xgettext}
254n=0
255while read comment; do
256  read string
257  n=`expr $n + 1`
258  cat <<EOF > f-l-1-$n.in
259(gettext ${string})
260EOF
261  ${XGETTEXT} -L Lisp -o f-l-1-$n.po f-l-1-$n.in || Exit 1
262  test -f f-l-1-$n.po || Exit 1
263  fail=
264  if echo "$comment" | grep 'Valid:' > /dev/null; then
265    if grep lisp-format f-l-1-$n.po > /dev/null; then
266      :
267    else
268      fail=yes
269    fi
270  else
271    if grep lisp-format f-l-1-$n.po > /dev/null; then
272      fail=yes
273    else
274      :
275    fi
276  fi
277  if test -n "$fail"; then
278    echo "Format string recognition error:" 1>&2
279    cat f-l-1-$n.in 1>&2
280    echo "Got:" 1>&2
281    cat f-l-1-$n.po 1>&2
282    Exit 1
283  fi
284  rm -f f-l-1-$n.in f-l-1-$n.po
285done < f-l-1.data
286
287Exit 0
288