3 # Test checking of Python format strings.
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles
="$tmpfiles f-p-2.data"
9 cat <<\EOF
> f-p-2.data
10 # Valid: %% doesn't count
13 # Invalid: invalid msgstr
16 # Valid: same arguments, with different widths
19 # Invalid: too few arguments
22 # Invalid: too many arguments
25 # Valid: same named arguments, with different widths
26 msgid
"abc%(date)5s%(time)4s"
27 msgstr
"xyz%(date)4s%(time)5s"
29 msgid
"abc%(3)d%(1)c%(2)sdef"
30 msgstr
"xyz%(2)s%(1)c%(3)d"
31 # Invalid: missing argument
32 msgid
"abc%(2)sdef%(1)u"
34 # Invalid: missing argument
35 msgid
"abc%(1)sdef%(2)u"
37 # Invalid: added argument
39 msgstr
"xyz%(foo)uvw%(char)c"
40 # Invalid: added argument
42 msgstr
"xyz%(foo)uvw%(zoo)c"
43 # Invalid: unnamed vs. named arguments
46 # Invalid: named vs. unnamed arguments
47 msgid
"abc%(value)sdef"
49 # Valid: type compatibility
52 # Valid: type compatibility
55 # Valid: type compatibility
58 # Valid: type compatibility
61 # Valid: type compatibility
64 # Valid: type compatibility
67 # Valid: type compatibility
70 # Valid: type compatibility
73 # Valid: type compatibility
76 # Valid: type compatibility
79 # Valid: type compatibility
82 # Invalid: type incompatibility
85 # Invalid: type incompatibility
88 # Invalid: type incompatibility
91 # Invalid: type incompatibility
94 # Invalid: type incompatibility
97 # Invalid: type incompatibility
100 # Invalid: type incompatibility for width
107 while read comment
; do
111 tmpfiles
="$tmpfiles f-p-2-$n.po f-p-2-$n.mo"
112 cat <<EOF > f-p-2-$n.po
118 if echo "$comment" |
grep 'Valid:' > /dev
/null
; then
119 if ${MSGFMT} --check-format -o f-p-2-
$n.mo f-p-2-
$n.po
; then
125 ${MSGFMT} --check-format -o f-p-2-
$n.mo f-p-2-
$n.po
2> /dev
/null
132 if test -n "$fail"; then
133 echo "Format string checking error:" 1>&2
137 rm -f f-p-2-
$n.po f-p-2-
$n.mo