3 # Test recognition of Python format strings.
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles
="$tmpfiles f-p-1.data"
9 cat <<\EOF
> f-p-1.data
12 # Valid: one character argument
14 # Valid: one string argument
16 # Valid: one string argument
18 # Valid: one integer argument
20 # Valid: one integer argument
22 # Valid: one integer argument
24 # Valid: one integer argument
26 # Valid: one integer argument
28 # Valid: one integer argument
30 # Valid: one floating-point argument
32 # Valid: one floating-point argument
34 # Valid: one floating-point argument
36 # Valid: one floating-point argument
38 # Valid: one floating-point argument
40 # Valid: one argument with flags
42 # Valid: one argument with width
44 # Valid: one argument with width
46 # Valid: one argument with precision
48 # Valid: one argument with precision
50 # Valid: one argument with width and precision
52 # Valid: one argument with width and precision
54 # Valid: one argument with width and precision
56 # Valid: one argument with width and precision
58 # Valid: one argument with size specifier
60 # Valid: one argument with size specifier
62 # Valid: one argument with size specifier
64 # Invalid: unterminated
66 # Invalid: unknown format specifier
68 # Invalid: flags after width
70 # Invalid: twice precision
72 # Invalid: two size specifiers
74 # Valid: three arguments
76 # Valid: a named argument
78 # Valid: an empty name
80 # Invalid: unterminated name
82 # Valid: ignored named argument
84 # Invalid: flags before name
86 # Valid: three arguments, two with equal names
87 "abc%(addr)4x,%(char)c,%(addr)u"
88 # Invalid: argument with conflicting types
89 "abc%(addr)4x,%(char)c,%(addr)s"
91 "abc%(addr)r,%(addr)s"
92 # Invalid: mixing of named and unnamed arguments
94 # Valid: named argument with constant precision
96 # Invalid: mixing of named and unnamed arguments
100 : ${XGETTEXT=xgettext}
102 while read comment
; do
105 tmpfiles
="$tmpfiles f-p-1-$n.in f-p-1-$n.po"
106 cat <<EOF > f-p-1-$n.in
109 ${XGETTEXT} -L Python
-o f-p-1-
$n.po f-p-1-
$n.
in ||
exit 1
110 test -f f-p-1-
$n.po ||
exit 1
112 if echo "$comment" |
grep 'Valid:' > /dev
/null
; then
113 if grep python-format f-p-1-
$n.po
> /dev
/null
; then
119 if grep python-format f-p-1-
$n.po
> /dev
/null
; then
125 if test -n "$fail"; then
126 echo "Format string recognition error:" 1>&2
132 rm -f f-p-1-
$n.
in f-p-1-
$n.po