2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test checking of Lisp format strings.
6 cat <<\EOF > f-l-2.data
7 # Valid: ~~ doesn't count
10 # Invalid: invalid msgstr
13 # Valid: same argument
16 # Valid: same arguments
17 msgid "abc~1000000@*~Ddef"
18 msgstr "~1000000@*xyz~D"
21 msgstr "xyz~2@*~F~2:*~C~2:*~D"
22 # Invalid: too few arguments
23 msgid "abc~1@*~Sdef~0@*~S"
25 # Invalid: too many arguments
28 # Invalid: missing non-final argument
29 msgid "abc~1@*~Sdef~0@*~F"
31 # Invalid: added non-final argument
34 # Valid: formatting variations
37 # Valid: formatting variations
40 # Valid: type compatibility
43 # Valid: type compatibility
46 # Valid: type compatibility
49 # Valid: type compatibility
52 # Valid: type compatibility
55 # Valid: optional plural
58 # Valid: type compatibility
61 # Valid: type compatibility
64 # Valid: type compatibility
67 # Invalid: type incompatibility
70 # Invalid: type incompatibility
73 # Invalid: type incompatibility
76 # Invalid: type incompatibility
79 # Invalid: type incompatibility
82 # Invalid: type incompatibility
85 # Valid: extra formatting
87 msgstr "xyz~D~_def~%~S"
88 # Valid: FORMAT-GOTO doesn't consume an argument by itself
89 msgid "abc~5@*~Ddef~C"
90 msgstr "xyz~6@*~C~2@*uvw~5@*~R"
94 # Valid: case conversion is optional
97 # Valid: case conversion is optional
98 msgid "abc~(~D~^ ~D~)"
100 # Invalid: ~^ matters
101 msgid "abc~(~D~^ ~D~)"
102 msgstr "xyz~(~D ~D~)"
103 # Valid: case conversion is optional, and it doesn't catch ~^
104 msgid "abc~(~D~^ ~D~)def~C"
105 msgstr "xyz~D~^ ~Duvw~C"
106 # Valid: synonymous conditionals
107 msgid "abc~@[~D~]def~C"
108 msgstr "xyz~:[~;~:*~D~]~C"
109 # Valid: synonymous conditionals
111 msgstr "abc~[null~;eins~:;~:*~D~]def"
112 # Valid: conditionals are optional and don't catch ~^
113 msgid "abc~:[~;~]~^~D~C"
114 msgstr "xyz~:[uvw~^~R~;~:*~S~^~D~]~C"
115 # Invalid: ~:[ requires an argument, ~1@* doesn't
116 msgid "abc~1@*~^~D~C"
117 msgstr "xyz~:[uvw~^~R~;~:*~S~^~D~]~C"
118 # Invalid: ~{~} is special
133 # Invalid: @: matters
136 # Valid: permutation inside iteration
138 msgstr "xyz~{~1@*~C~2:*~D~1*~}"
139 # Invalid: permutation inside iteration, but wrong position at iteration end
141 msgstr "xyz~{~1@*~C~2:*~D~}"
142 # Invalid: ~^ inside iteration matters
143 msgid "abc~{~D ~^~C~}"
144 msgstr "xyz~{~D ~C~}"
145 # Invalid: ~^ inside iteration depends on position
146 msgid "abc~{~D ~^~C~}"
147 msgstr "xyz~{~1@*~C~^~2:*~D~1*~}"
148 # Invalid: ~^ inside iteration depends on position
149 msgid "abc~{~D ~^~C~}"
150 msgstr "xyz~{~1@*~C~2:*~^~D~1*~}"
151 # Invalid: ~^ inside iteration depends on position
152 msgid "abc~{~D ~^~C~}"
153 msgstr "xyz~{~1@*~C~2:*~D~^~1*~}"
154 # Invalid: ~^ inside iteration depends on position
155 msgid "abc~{~D ~^~C~}"
156 msgstr "xyz~{~1@*~C~2:*~D~1*~^~}"
157 # Valid: justification is optional
158 msgid "abc~<~D~;~C~>"
160 # Valid: justification with different segmentation
161 msgid "abc~<~D ~D~;~C~;~S~S~>"
162 msgstr "xyz~<~D~;~D~C~S~;~S~>"
163 # Invalid: justification catches ~^
164 msgid "abc~<~D~;~^~D~>~C"
166 # Invalid: type compatibility with non-strict checking
168 msgid_plural "abc~{~c~c~}"
169 msgstr[0] "xyz~{~c~d~}"
170 msgstr[1] "xyz~{~c~d~}"
175 while read comment; do
179 if echo "$msgstr_line" | grep '^msgid_plural' > /dev/null; then
180 msgid_plural_line="$msgstr_line"
185 if test -z "$msgid_plural_line"; then
186 cat <<EOF > f-l-2-$n.po
192 cat <<EOF > f-l-2-$n.po
201 if echo "$comment" | grep 'Valid:' > /dev/null; then
202 if ${MSGFMT} --check-format -o f-l-2-$n.mo f-l-2-$n.po; then
208 ${MSGFMT} --check-format -o f-l-2-$n.mo f-l-2-$n.po 2> /dev/null
215 if test -n "$fail"; then
216 echo "Format string checking error:" 1>&2
220 rm -f f-l-2-$n.po f-l-2-$n.mo