2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test recognition of PHP format strings.
6 cat <<\EOF > f-ph-1.data
9 # Valid: one string argument
11 # Valid: one integer argument
13 # Valid: one integer argument
15 # Valid: one integer argument
17 # Valid: one integer argument
19 # Valid: one integer argument
21 # Valid: one integer argument
23 # Valid: one floating-point argument
25 # Valid: one floating-point argument
27 # Valid: one character argument
29 # Valid: one argument with flags
31 # Valid: one argument with padding flags
33 # Valid: one argument with width
35 # Valid: one argument with precision
37 # Valid: one argument with width and precision
39 # Invalid: unterminated
41 # Invalid: unknown format specifier
43 # Invalid: unknown format specifier
45 # Invalid: flags after width
47 # Invalid: twice precision
49 # Valid: three arguments
51 # Valid: a numbered argument
55 # Valid: two-digit numbered arguments
56 "abc%11$def%10$dgh%9$dij%8$dkl%7$dmn%6$dop%5$dqr%4$dst%3$duv%2$dwx%1$dyz"
57 # Invalid: unterminated number
59 # Invalid: flags before number
61 # Valid: three arguments, two with same number
63 # Invalid: argument with conflicting types
67 # Valid: mixing of numbered and unnumbered arguments
69 # Valid: numbered argument with constant precision
71 # Valid: missing non-final argument
75 # Valid: multiple uses of same argument
76 "abc%2$xdef%1$sghi%2$x"
79 : ${XGETTEXT=xgettext}
81 while read comment; do
84 echo "<?= gettext(${string}) ?>" | sed -e 's/\$/\\\$/g' > f-ph-1-$n.in
85 ${XGETTEXT} -L PHP -o f-ph-1-$n.po f-ph-1-$n.in || exit 1
86 test -f f-ph-1-$n.po || exit 1
88 if echo "$comment" | grep 'Valid:' > /dev/null; then
89 if grep php-format f-ph-1-$n.po > /dev/null; then
95 if grep php-format f-ph-1-$n.po > /dev/null; then
101 if test -n "$fail"; then
102 echo "Format string recognition error:" 1>&2
103 cat f-ph-1-$n.in 1>&2
105 cat f-ph-1-$n.po 1>&2
108 rm -f f-ph-1-$n.in f-ph-1-$n.po