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