Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / format-gfc-internal-2
1 #! /bin/sh
2
3 # Test checking of GFC internal format strings.
4
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
7
8 tmpfiles="$tmpfiles f-gf-2.data"
9 cat <<\EOF > f-gf-2.data
10 # Valid: %% doesn't count
11 msgid  "abc%%def"
12 msgstr "xyz"
13 # Invalid: %C consumes currentloc
14 msgid  "abc%Cdef"
15 msgstr "xyz"
16 # Invalid: %C consumes currentloc
17 msgid  "abc"
18 msgstr "xyz%Cuvw"
19 # Invalid: invalid msgstr
20 msgid  "abc%%def"
21 msgstr "xyz%"
22 # Valid: same arguments
23 msgid  "abc%s%udef"
24 msgstr "xyz%s%u"
25 # Valid: same arguments but in numbered syntax
26 msgid  "abc%s%ddef"
27 msgstr "xyz%1$s%2$d"
28 # Valid: permutation
29 msgid  "abc%s%d%cdef"
30 msgstr "xyz%3$c%2$d%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 # Invalid: missing argument
38 msgid  "abc%2$sdef%1$u"
39 msgstr "xyz%1$u"
40 # Invalid: missing argument
41 msgid  "abc%1$sdef%2$u"
42 msgstr "xyz%2$u"
43 # Invalid: added argument
44 msgid  "abc%1$udef"
45 msgstr "xyz%1$uvw%2$c"
46 # Valid: type compatibility
47 msgid  "abc%i"
48 msgstr "xyz%d"
49 # Invalid: type incompatibility
50 msgid  "abc%c"
51 msgstr "xyz%s"
52 # Invalid: type incompatibility
53 msgid  "abc%c"
54 msgstr "xyz%i"
55 # Invalid: type incompatibility
56 msgid  "abc%c"
57 msgstr "xyz%u"
58 # Invalid: type incompatibility
59 msgid  "abc%c"
60 msgstr "xyz%li"
61 # Invalid: type incompatibility
62 msgid  "abc%c"
63 msgstr "xyz%lu"
64 # Invalid: type incompatibility
65 msgid  "abc%c"
66 msgstr "xyz%L"
67 # Invalid: type incompatibility
68 msgid  "abc%c"
69 msgstr "xyz%C"
70 # Invalid: type incompatibility
71 msgid  "abc%s"
72 msgstr "xyz%i"
73 # Invalid: type incompatibility
74 msgid  "abc%s"
75 msgstr "xyz%u"
76 # Invalid: type incompatibility
77 msgid  "abc%s"
78 msgstr "xyz%li"
79 # Invalid: type incompatibility
80 msgid  "abc%s"
81 msgstr "xyz%lu"
82 # Invalid: type incompatibility
83 msgid  "abc%s"
84 msgstr "xyz%L"
85 # Invalid: type incompatibility
86 msgid  "abc%s"
87 msgstr "xyz%C"
88 # Invalid: type incompatibility
89 msgid  "abc%i"
90 msgstr "xyz%u"
91 # Invalid: type incompatibility
92 msgid  "abc%i"
93 msgstr "xyz%li"
94 # Invalid: type incompatibility
95 msgid  "abc%i"
96 msgstr "xyz%lu"
97 # Invalid: type incompatibility
98 msgid  "abc%i"
99 msgstr "xyz%L"
100 # Invalid: type incompatibility
101 msgid  "abc%i"
102 msgstr "xyz%C"
103 # Invalid: type incompatibility
104 msgid  "abc%u"
105 msgstr "xyz%li"
106 # Invalid: type incompatibility
107 msgid  "abc%u"
108 msgstr "xyz%lu"
109 # Invalid: type incompatibility
110 msgid  "abc%u"
111 msgstr "xyz%L"
112 # Invalid: type incompatibility
113 msgid  "abc%u"
114 msgstr "xyz%C"
115 # Invalid: type incompatibility
116 msgid  "abc%li"
117 msgstr "xyz%lu"
118 # Invalid: type incompatibility
119 msgid  "abc%li"
120 msgstr "xyz%L"
121 # Invalid: type incompatibility
122 msgid  "abc%li"
123 msgstr "xyz%C"
124 # Invalid: type incompatibility
125 msgid  "abc%lu"
126 msgstr "xyz%L"
127 # Invalid: type incompatibility
128 msgid  "abc%lu"
129 msgstr "xyz%C"
130 # Invalid: type incompatibility
131 msgid  "abc%L"
132 msgstr "xyz%C"
133 # Invalid: permutation
134 msgid "abc%sdef%c"
135 msgstr "abc%cdef%s"
136 # Valid: currentloc reference position does not matter
137 msgid "abc%sdef%C"
138 msgstr "abc%Cdef%s"
139 # Valid: currentloc reference may be repeated
140 msgid "abc%sdef%C"
141 msgstr "abc%sdef%Cghi%C"
142 # Valid: currentloc reference may be repeated and permuted
143 msgid "abc%Cdef%Cghi%s"
144 msgstr "abc%sdef%C"
145 EOF
146
147 : ${MSGFMT=msgfmt}
148 n=0
149 while read comment; do
150   read msgid_line
151   read msgstr_line
152   n=`expr $n + 1`
153   tmpfiles="$tmpfiles f-gf-2-$n.po f-gf-2-$n.mo"
154   cat <<EOF > f-gf-2-$n.po
155 #, gfc-internal-format
156 ${msgid_line}
157 ${msgstr_line}
158 EOF
159   fail=
160   if echo "$comment" | grep 'Valid:' > /dev/null; then
161     if ${MSGFMT} --check-format -o f-gf-2-$n.mo f-gf-2-$n.po; then
162       :
163     else
164       fail=yes
165     fi
166   else
167     ${MSGFMT} --check-format -o f-gf-2-$n.mo f-gf-2-$n.po 2> /dev/null
168     if test $? = 1; then
169       :
170     else
171       fail=yes
172     fi
173   fi
174   if test -n "$fail"; then
175     echo "Format string checking error:" 1>&2
176     cat f-gf-2-$n.po 1>&2
177     exit 1
178   fi
179   rm -f f-gf-2-$n.po f-gf-2-$n.mo
180 done < f-gf-2.data
181
182 rm -fr $tmpfiles
183
184 exit 0