3 # Test recognition of PHP format strings.
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles
="$tmpfiles f-ph-1.data"
9 cat <<\EOF
> f-ph-1.data
12 # Valid: one string argument
14 # Valid: one integer argument
16 # Valid: one integer argument
18 # Valid: one integer argument
20 # Valid: one integer argument
22 # Valid: one integer argument
24 # Valid: one integer argument
26 # Valid: one floating-point argument
28 # Valid: one floating-point argument
30 # Valid: one character argument
32 # Valid: one argument with flags
34 # Valid: one argument with padding flags
36 # Valid: one argument with width
38 # Valid: one argument with precision
40 # Valid: one argument with width and precision
42 # Invalid: unterminated
44 # Invalid: unknown format specifier
46 # Invalid: unknown format specifier
48 # Invalid: flags after width
50 # Invalid: twice precision
52 # Valid: three arguments
54 # Valid: a numbered argument
58 # Valid: two-digit numbered arguments
59 "abc%11$def%10$dgh%9$dij%8$dkl%7$dmn%6$dop%5$dqr%4$dst%3$duv%2$dwx%1$dyz"
60 # Invalid: unterminated number
62 # Invalid: flags before number
64 # Valid: three arguments, two with same number
66 # Invalid: argument with conflicting types
70 # Valid: mixing of numbered and unnumbered arguments
72 # Valid: numbered argument with constant precision
74 # Valid: missing non-final argument
78 # Valid: multiple uses of same argument
79 "abc%2$xdef%1$sghi%2$x"
82 : ${XGETTEXT=xgettext}
84 while read comment
; do
87 tmpfiles
="$tmpfiles f-ph-1-$n.in f-ph-1-$n.po"
88 echo "<?= gettext(${string}) ?>" |
sed -e 's/\$/\\\$/g' > f-ph-1-
$n.
in
89 ${XGETTEXT} -L PHP
-o f-ph-1-
$n.po f-ph-1-
$n.
in ||
exit 1
90 test -f f-ph-1-
$n.po ||
exit 1
92 if echo "$comment" |
grep 'Valid:' > /dev
/null
; then
93 if grep php-format f-ph-1-
$n.po
> /dev
/null
; then
99 if grep php-format f-ph-1-
$n.po
> /dev
/null
; then
105 if test -n "$fail"; then
106 echo "Format string recognition error:" 1>&2
107 cat f-ph-1-
$n.
in 1>&2
109 cat f-ph-1-
$n.po
1>&2
112 rm -f f-ph-1-
$n.
in f-ph-1-
$n.po