No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / format-perl-mixed-2
blob09afbbb5b99ff29b9c2db3c677a0f4e5591c5e37
1 #! /bin/sh
3 # Test checking of Perl format strings.
4 # This test is for the combination of printf and brace format strings.
6 tmpfiles=""
7 trap 'rm -fr $tmpfiles' 1 2 3 15
9 tmpfiles="$tmpfiles f-pm-2.data"
10 cat <<\EOF > f-pm-2.data
11 # Valid: normal case.
12 #, perl-format, perl-brace-format
13 msgid "{foo} %d {bar} %s"
14 msgstr "{bar} {foo} %d %s"
15 # Invalid: missing argument.
16 #, perl-format, perl-brace-format
17 msgid "{foo} %d {bar} %s"
18 msgstr "{bar} %d %s"
19 # Valid: missing argument but checking disabled.
20 #, perl-format, no-perl-brace-format
21 msgid "{foo} %d {bar} %s"
22 msgstr "{bar} %d %s"
23 # Invalid: printf format reordered without position specifiers %1$, %2$.
24 #, perl-format, perl-brace-format
25 msgid "{foo} %d {bar} %s"
26 msgstr "{bar} %s {foo} %d"
27 # Valid: same thing but checking disabled.
28 #, no-perl-format, perl-brace-format
29 msgid "{foo} %d {bar} %s"
30 msgstr "{bar} %s {foo} %d"
31 # Invalid: unnamed vs. named arguments
32 #, perl-format
33 msgid "abc%sdef"
34 msgstr "xyz{value}"
35 # Invalid: named vs. unnamed arguments
36 #, perl-brace-format
37 msgid "abc{value}def"
38 msgstr "xyz%s"
39 EOF
41 : ${MSGFMT=msgfmt}
42 n=0
43 while read comment; do
44 read formats
45 read msgid_line
46 read msgstr_line
47 n=`expr $n + 1`
48 tmpfiles="$tmpfiles f-pm-2-$n.po f-pm-2-$n.mo"
49 cat <<EOF > f-pm-2-$n.po
50 ${formats}
51 ${msgid_line}
52 ${msgstr_line}
53 EOF
54 fail=
55 if echo "$comment" | grep 'Valid:' > /dev/null; then
56 if ${MSGFMT} --check-format -o f-pm-2-$n.mo f-pm-2-$n.po; then
58 else
59 fail=yes
61 else
62 ${MSGFMT} --check-format -o f-pm-2-$n.mo f-pm-2-$n.po 2> /dev/null
63 if test $? = 1; then
65 else
66 fail=yes
69 if test -n "$fail"; then
70 echo "Format string checking error:" 1>&2
71 cat f-pm-2-$n.po 1>&2
72 exit 1
74 done < f-pm-2.data
76 rm -fr $tmpfiles
78 exit 0