No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / format-perl-mixed-1
blob3b3a84b89b86db8763008b0a8f413a9b0d72e907
1 #! /bin/sh
3 # Test recognition of Perl format strings of both kinds (printf and brace).
4 # This test is for the combination of both kinds.
6 tmpfiles=""
7 trap 'rm -fr $tmpfiles' 1 2 3 15
9 tmpfiles="$tmpfiles f-pm-1.data"
11 cat <<\EOF > f-pm-1.data
12 # Both formats.
13 #, perl-format, perl-brace-format
14 "{foo} %c {bar} %d {baz}"
15 # printf format only.
16 #, perl-format
17 "%c %d"
18 # printf format only, because '%' is not allowed in identifier.
19 #, perl-format
20 "{foo%cbar}"
21 # Valid bracketed format because there is still one valid identifier.
22 #, perl-format, perl-brace-format
23 "{foo%cbar} {baz}"
24 # Bracketed format only, because %l is not recognized in printf format.
25 #, perl-brace-format
26 "{foo} %l {bar}"
27 # Neither format recognized here.
29 "{foo bar %l"
30 EOF
32 : ${XGETTEXT=xgettext}
33 n=0
34 while read comment; do
35 read formats
36 read string
37 n=`expr $n + 1`
38 tmpfiles="$tmpfiles f-pm-1-$n.in f-pm-1-$n.po"
39 cat <<EOF > f-pm-1-$n.in
40 gettext(${string});
41 EOF
42 ${XGETTEXT} -L perl --omit-header --no-location -o f-pm-1-$n.po f-pm-1-$n.in || exit 1
43 test -f f-pm-1-$n.po || exit 1
44 fail=
45 if test -n "${formats}"; then
46 # Verify that the first line contains the expected #, comment.
47 if sed 1q < f-pm-1-$n.po | grep '^'"${formats}"'$' > /dev/null; then
49 else
50 fail=yes
52 else
53 # Verify that there is no #, comment.
54 if sed 1q < f-pm-1-$n.po | grep '^msgid' > /dev/null; then
56 else
57 fail=yes
60 if test -n "$fail"; then
61 echo "Format string recognition error:" 1>&2
62 cat f-pm-1-$n.in 1>&2
63 echo "Got:" 1>&2
64 cat f-pm-1-$n.po 1>&2
65 exit 1
67 done < f-pm-1.data
69 rm -fr $tmpfiles
71 exit 0