• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test checking of Boost format strings.
5
6cat <<\EOF > f-bo-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%gdef"
15msgstr "xyz%s%g"
16# Valid: same arguments, despite different syntax
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: same arguments but in numbered syntax
26msgid  "abc%s%gdef"
27msgstr "xyz%1%%2$g"
28# Valid: permutation
29msgid  "abc%s%g%cdef"
30msgstr "xyz%3$c%2$g%1$s"
31# Invalid: too few arguments
32msgid  "abc%2$udef%1$s"
33msgstr "xyz%1$s"
34# Invalid: too few arguments
35msgid  "abc%sdef%u"
36msgstr "xyz%s"
37# Invalid: too many arguments
38msgid  "abc%udef"
39msgstr "xyz%uvw%c"
40# Valid: same numbered arguments, with different widths
41msgid  "abc%2$5s%1$4s"
42msgstr "xyz%2$4s%1$5s"
43# Invalid: missing argument
44msgid  "abc%2$sdef%1$u"
45msgstr "xyz%1$u"
46# Invalid: missing argument
47msgid  "abc%1$sdef%2$u"
48msgstr "xyz%2$u"
49# Invalid: added argument
50msgid  "abc%1$udef"
51msgstr "xyz%1$uvw%2$c"
52# Valid: type compatibility
53msgid  "abc%i"
54msgstr "xyz%d"
55# Valid: type compatibility
56msgid  "abc%i"
57msgstr "xyz%o"
58# Valid: type compatibility
59msgid  "abc%i"
60msgstr "xyz%u"
61# Valid: type compatibility
62msgid  "abc%i"
63msgstr "xyz%x"
64# Valid: type compatibility
65msgid  "abc%i"
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%g"
76# Valid: type compatibility
77msgid  "abc%e"
78msgstr "xyz%G"
79# Invalid: type incompatibility
80msgid  "abc%c"
81msgstr "xyz%s"
82# Invalid: type incompatibility
83msgid  "abc%c"
84msgstr "xyz%i"
85# Invalid: type incompatibility
86msgid  "abc%c"
87msgstr "xyz%e"
88# Invalid: type incompatibility
89msgid  "abc%c"
90msgstr "xyz%p"
91# Invalid: different argument count
92msgid  "abc%c"
93msgstr "xyz%n"
94# Invalid: type incompatibility
95msgid  "abc%s"
96msgstr "xyz%i"
97# Invalid: type incompatibility
98msgid  "abc%s"
99msgstr "xyz%e"
100# Invalid: type incompatibility
101msgid  "abc%s"
102msgstr "xyz%p"
103# Invalid: different argument count
104msgid  "abc%s"
105msgstr "xyz%n"
106# Invalid: type incompatibility
107msgid  "abc%i"
108msgstr "xyz%e"
109# Invalid: type incompatibility
110msgid  "abc%i"
111msgstr "xyz%p"
112# Invalid: different argument count
113msgid  "abc%i"
114msgstr "xyz%n"
115# Invalid: type incompatibility
116msgid  "abc%e"
117msgstr "xyz%p"
118# Invalid: different argument count
119msgid  "abc%e"
120msgstr "xyz%n"
121# Invalid: different argument count
122msgid  "abc%p"
123msgstr "xyz%n"
124# Valid: size is ignored
125msgid  "abc%i"
126msgstr "xyz%hhi"
127# Valid: size is ignored
128msgid  "abc%i"
129msgstr "xyz%hi"
130# Valid: size is ignored
131msgid  "abc%i"
132msgstr "xyz%li"
133# Valid: size is ignored
134msgid  "abc%i"
135msgstr "xyz%lli"
136# Valid: size is ignored
137msgid  "abc%i"
138msgstr "xyz%Li"
139# Valid: size is ignored
140msgid  "abc%hhi"
141msgstr "xyz%hi"
142# Valid: size is ignored
143msgid  "abc%hhi"
144msgstr "xyz%li"
145# Valid: size is ignored
146msgid  "abc%hhi"
147msgstr "xyz%lli"
148# Valid: size is ignored
149msgid  "abc%hhi"
150msgstr "xyz%Li"
151# Valid: size is ignored
152msgid  "abc%hi"
153msgstr "xyz%li"
154# Valid: size is ignored
155msgid  "abc%hi"
156msgstr "xyz%lli"
157# Valid: size is ignored
158msgid  "abc%hi"
159msgstr "xyz%Li"
160# Valid: size is ignored
161msgid  "abc%li"
162msgstr "xyz%lli"
163# Valid: size is ignored
164msgid  "abc%li"
165msgstr "xyz%Li"
166# Invalid: type incompatibility for width
167msgid  "abc%g%*g"
168msgstr "xyz%*g%g"
169EOF
170
171: ${MSGFMT=msgfmt}
172n=0
173while read comment; do
174  read msgid_line
175  read msgstr_line
176  n=`expr $n + 1`
177  cat <<EOF > f-bo-2-$n.po
178#, boost-format
179${msgid_line}
180${msgstr_line}
181EOF
182  fail=
183  if echo "$comment" | grep 'Valid:' > /dev/null; then
184    if ${MSGFMT} --check-format -o f-bo-2-$n.mo f-bo-2-$n.po; then
185      :
186    else
187      fail=yes
188    fi
189  else
190    ${MSGFMT} --check-format -o f-bo-2-$n.mo f-bo-2-$n.po 2> /dev/null
191    if test $? = 1; then
192      :
193    else
194      fail=yes
195    fi
196  fi
197  if test -n "$fail"; then
198    echo "Format string checking error:" 1>&2
199    cat f-bo-2-$n.po 1>&2
200    Exit 1
201  fi
202  rm -f f-bo-2-$n.po f-bo-2-$n.mo
203done < f-bo-2.data
204
205Exit 0
206