No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / format-perl-2
blob9382fd7c0631c83b783a57022a93f68c2418dd12
1 #! /bin/sh
3 # Test checking of Perl format strings.
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles="$tmpfiles f-pl-2.data"
9 cat <<\EOF > f-pl-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%b"
54 msgstr "xyz%o"
55 # Valid: type compatibility
56 msgid "abc%o"
57 msgstr "xyz%u"
58 # Valid: type compatibility
59 msgid "abc%u"
60 msgstr "xyz%x"
61 # Valid: type compatibility
62 msgid "abc%u"
63 msgstr "xyz%X"
64 # Valid: type and size compatibility
65 msgid "abc%x"
66 msgstr "xyz%X"
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%F"
76 # Valid: type compatibility
77 msgid "abc%e"
78 msgstr "xyz%g"
79 # Valid: type compatibility
80 msgid "abc%e"
81 msgstr "xyz%G"
82 # Invalid: type incompatibility
83 msgid "abc%c"
84 msgstr "xyz%s"
85 # Invalid: type incompatibility
86 msgid "abc%c"
87 msgstr "xyz%_"
88 # Invalid: type incompatibility
89 msgid "abc%c"
90 msgstr "xyz%i"
91 # Invalid: type incompatibility
92 msgid "abc%c"
93 msgstr "xyz%u"
94 # Invalid: type incompatibility
95 msgid "abc%c"
96 msgstr "xyz%e"
97 # Invalid: type incompatibility
98 msgid "abc%c"
99 msgstr "xyz%p"
100 # Invalid: type incompatibility
101 msgid "abc%c"
102 msgstr "xyz%n"
103 # Invalid: type incompatibility
104 msgid "abc%s"
105 msgstr "xyz%_"
106 # Invalid: type incompatibility
107 msgid "abc%s"
108 msgstr "xyz%i"
109 # Invalid: type incompatibility
110 msgid "abc%s"
111 msgstr "xyz%u"
112 # Invalid: type incompatibility
113 msgid "abc%s"
114 msgstr "xyz%e"
115 # Invalid: type incompatibility
116 msgid "abc%s"
117 msgstr "xyz%p"
118 # Invalid: type incompatibility
119 msgid "abc%s"
120 msgstr "xyz%n"
121 # Invalid: type incompatibility
122 msgid "abc%_"
123 msgstr "xyz%i"
124 # Invalid: type incompatibility
125 msgid "abc%_"
126 msgstr "xyz%u"
127 # Invalid: type incompatibility
128 msgid "abc%_"
129 msgstr "xyz%e"
130 # Invalid: type incompatibility
131 msgid "abc%_"
132 msgstr "xyz%p"
133 # Invalid: type incompatibility
134 msgid "abc%_"
135 msgstr "xyz%n"
136 # Invalid: type incompatibility
137 msgid "abc%i"
138 msgstr "xyz%u"
139 # Invalid: type incompatibility
140 msgid "abc%i"
141 msgstr "xyz%e"
142 # Invalid: type incompatibility
143 msgid "abc%i"
144 msgstr "xyz%p"
145 # Invalid: type incompatibility
146 msgid "abc%i"
147 msgstr "xyz%n"
148 # Invalid: type incompatibility
149 msgid "abc%u"
150 msgstr "xyz%e"
151 # Invalid: type incompatibility
152 msgid "abc%u"
153 msgstr "xyz%p"
154 # Invalid: type incompatibility
155 msgid "abc%u"
156 msgstr "xyz%n"
157 # Invalid: type incompatibility
158 msgid "abc%e"
159 msgstr "xyz%p"
160 # Invalid: type incompatibility
161 msgid "abc%e"
162 msgstr "xyz%n"
163 # Invalid: type incompatibility
164 msgid "abc%p"
165 msgstr "xyz%n"
166 # Invalid: size incompatibility
167 msgid "abc%hd"
168 msgstr "xyz%d"
169 # Invalid: size incompatibility
170 msgid "abc%hd"
171 msgstr "xyz%ld"
172 # Invalid: size incompatibility
173 msgid "abc%hd"
174 msgstr "xyz%Vd"
175 # Invalid: size incompatibility
176 msgid "abc%hd"
177 msgstr "xyz%qd"
178 # Invalid: size incompatibility
179 msgid "abc%d"
180 msgstr "xyz%ld"
181 # Invalid: size incompatibility
182 msgid "abc%d"
183 msgstr "xyz%Vd"
184 # Invalid: size incompatibility
185 msgid "abc%d"
186 msgstr "xyz%qd"
187 # Invalid: size incompatibility
188 msgid "abc%ld"
189 msgstr "xyz%Vd"
190 # Invalid: size incompatibility
191 msgid "abc%ld"
192 msgstr "xyz%qd"
193 # Invalid: size incompatibility
194 msgid "abc%Vd"
195 msgstr "xyz%qd"
196 # Invalid: size incompatibility
197 msgid "abc%d"
198 msgstr "xyz%D"
199 # Invalid: size incompatibility
200 msgid "abc%u"
201 msgstr "xyz%U"
202 # Invalid: size incompatibility
203 msgid "abc%o"
204 msgstr "xyz%O"
205 # Invalid: type incompatibility for width
206 msgid "abc%g%*g"
207 msgstr "xyz%*g%g"
210 : ${MSGFMT=msgfmt}
212 while read comment; do
213 read msgid_line
214 read msgstr_line
215 n=`expr $n + 1`
216 tmpfiles="$tmpfiles f-pl-2-$n.po f-pl-2-$n.mo"
217 cat <<EOF > f-pl-2-$n.po
218 #, perl-format
219 ${msgid_line}
220 ${msgstr_line}
222 fail=
223 if echo "$comment" | grep 'Valid:' > /dev/null; then
224 if ${MSGFMT} --check-format -o f-pl-2-$n.mo f-pl-2-$n.po; then
226 else
227 fail=yes
229 else
230 ${MSGFMT} --check-format -o f-pl-2-$n.mo f-pl-2-$n.po 2> /dev/null
231 if test $? = 1; then
233 else
234 fail=yes
237 if test -n "$fail"; then
238 echo "Format string checking error:" 1>&2
239 cat f-pl-2-$n.po 1>&2
240 exit 1
242 rm -f f-pl-2-$n.po f-pl-2-$n.mo
243 done < f-pl-2.data
245 rm -fr $tmpfiles
247 exit 0