• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/tests/
1#! /bin/sh
2
3# Test checking of Perl format strings.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles f-pl-2.data"
9cat <<\EOF > f-pl-2.data
10# Valid: %% doesn't count
11msgid  "abc%%def"
12msgstr "xyz"
13# Invalid: invalid msgstr
14msgid  "abc%%def"
15msgstr "xyz%"
16# Valid: same arguments
17msgid  "abc%s%gdef"
18msgstr "xyz%s%g"
19# Valid: same arguments, with different widths
20msgid  "abc%2sdef"
21msgstr "xyz%3s"
22# Valid: same arguments but in numbered syntax
23msgid  "abc%s%gdef"
24msgstr "xyz%1$s%2$g"
25# Valid: permutation
26msgid  "abc%s%g%cdef"
27msgstr "xyz%3$c%2$g%1$s"
28# Invalid: too few arguments
29msgid  "abc%2$udef%1$s"
30msgstr "xyz%1$s"
31# Invalid: too few arguments
32msgid  "abc%sdef%u"
33msgstr "xyz%s"
34# Invalid: too many arguments
35msgid  "abc%udef"
36msgstr "xyz%uvw%c"
37# Valid: same numbered arguments, with different widths
38msgid  "abc%2$5s%1$4s"
39msgstr "xyz%2$4s%1$5s"
40# Invalid: missing argument
41msgid  "abc%2$sdef%1$u"
42msgstr "xyz%1$u"
43# Invalid: missing argument
44msgid  "abc%1$sdef%2$u"
45msgstr "xyz%2$u"
46# Invalid: added argument
47msgid  "abc%1$udef"
48msgstr "xyz%1$uvw%2$c"
49# Valid: type compatibility
50msgid  "abc%i"
51msgstr "xyz%d"
52# Valid: type compatibility
53msgid  "abc%b"
54msgstr "xyz%o"
55# Valid: type compatibility
56msgid  "abc%o"
57msgstr "xyz%u"
58# Valid: type compatibility
59msgid  "abc%u"
60msgstr "xyz%x"
61# Valid: type compatibility
62msgid  "abc%u"
63msgstr "xyz%X"
64# Valid: type and size compatibility
65msgid  "abc%x"
66msgstr "xyz%X"
67# Valid: type compatibility
68msgid  "abc%e"
69msgstr "xyz%E"
70# Valid: type compatibility
71msgid  "abc%e"
72msgstr "xyz%f"
73# Valid: type compatibility
74msgid  "abc%e"
75msgstr "xyz%F"
76# Valid: type compatibility
77msgid  "abc%e"
78msgstr "xyz%g"
79# Valid: type compatibility
80msgid  "abc%e"
81msgstr "xyz%G"
82# Invalid: type incompatibility
83msgid  "abc%c"
84msgstr "xyz%s"
85# Invalid: type incompatibility
86msgid  "abc%c"
87msgstr "xyz%_"
88# Invalid: type incompatibility
89msgid  "abc%c"
90msgstr "xyz%i"
91# Invalid: type incompatibility
92msgid  "abc%c"
93msgstr "xyz%u"
94# Invalid: type incompatibility
95msgid  "abc%c"
96msgstr "xyz%e"
97# Invalid: type incompatibility
98msgid  "abc%c"
99msgstr "xyz%p"
100# Invalid: type incompatibility
101msgid  "abc%c"
102msgstr "xyz%n"
103# Invalid: type incompatibility
104msgid  "abc%s"
105msgstr "xyz%_"
106# Invalid: type incompatibility
107msgid  "abc%s"
108msgstr "xyz%i"
109# Invalid: type incompatibility
110msgid  "abc%s"
111msgstr "xyz%u"
112# Invalid: type incompatibility
113msgid  "abc%s"
114msgstr "xyz%e"
115# Invalid: type incompatibility
116msgid  "abc%s"
117msgstr "xyz%p"
118# Invalid: type incompatibility
119msgid  "abc%s"
120msgstr "xyz%n"
121# Invalid: type incompatibility
122msgid  "abc%_"
123msgstr "xyz%i"
124# Invalid: type incompatibility
125msgid  "abc%_"
126msgstr "xyz%u"
127# Invalid: type incompatibility
128msgid  "abc%_"
129msgstr "xyz%e"
130# Invalid: type incompatibility
131msgid  "abc%_"
132msgstr "xyz%p"
133# Invalid: type incompatibility
134msgid  "abc%_"
135msgstr "xyz%n"
136# Invalid: type incompatibility
137msgid  "abc%i"
138msgstr "xyz%u"
139# Invalid: type incompatibility
140msgid  "abc%i"
141msgstr "xyz%e"
142# Invalid: type incompatibility
143msgid  "abc%i"
144msgstr "xyz%p"
145# Invalid: type incompatibility
146msgid  "abc%i"
147msgstr "xyz%n"
148# Invalid: type incompatibility
149msgid  "abc%u"
150msgstr "xyz%e"
151# Invalid: type incompatibility
152msgid  "abc%u"
153msgstr "xyz%p"
154# Invalid: type incompatibility
155msgid  "abc%u"
156msgstr "xyz%n"
157# Invalid: type incompatibility
158msgid  "abc%e"
159msgstr "xyz%p"
160# Invalid: type incompatibility
161msgid  "abc%e"
162msgstr "xyz%n"
163# Invalid: type incompatibility
164msgid  "abc%p"
165msgstr "xyz%n"
166# Invalid: size incompatibility
167msgid  "abc%hd"
168msgstr "xyz%d"
169# Invalid: size incompatibility
170msgid  "abc%hd"
171msgstr "xyz%ld"
172# Invalid: size incompatibility
173msgid  "abc%hd"
174msgstr "xyz%Vd"
175# Invalid: size incompatibility
176msgid  "abc%hd"
177msgstr "xyz%qd"
178# Invalid: size incompatibility
179msgid  "abc%d"
180msgstr "xyz%ld"
181# Invalid: size incompatibility
182msgid  "abc%d"
183msgstr "xyz%Vd"
184# Invalid: size incompatibility
185msgid  "abc%d"
186msgstr "xyz%qd"
187# Invalid: size incompatibility
188msgid  "abc%ld"
189msgstr "xyz%Vd"
190# Invalid: size incompatibility
191msgid  "abc%ld"
192msgstr "xyz%qd"
193# Invalid: size incompatibility
194msgid  "abc%Vd"
195msgstr "xyz%qd"
196# Invalid: size incompatibility
197msgid  "abc%d"
198msgstr "xyz%D"
199# Invalid: size incompatibility
200msgid  "abc%u"
201msgstr "xyz%U"
202# Invalid: size incompatibility
203msgid  "abc%o"
204msgstr "xyz%O"
205# Invalid: type incompatibility for width
206msgid  "abc%g%*g"
207msgstr "xyz%*g%g"
208EOF
209
210: ${MSGFMT=msgfmt}
211n=0
212while 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}
221EOF
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
225      :
226    else
227      fail=yes
228    fi
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
232      :
233    else
234      fail=yes
235    fi
236  fi
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
241  fi
242  rm -f f-pl-2-$n.po f-pl-2-$n.mo
243done < f-pl-2.data
244
245rm -fr $tmpfiles
246
247exit 0
248