No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / format-perl-brace-2
blobc00636bfac577a0e166f2825ac79b8bbbc555a4a
1 #! /bin/sh
3 # Test checking of Perl brace format strings.
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles="$tmpfiles f-pb-2.data"
9 cat <<\EOF > f-pb-2.data
10 # Valid: same named arguments
11 msgid "abc{date}{time}"
12 msgstr "xyz{date}{time}"
13 # Valid: permutation
14 msgid "abc{x3}{x1}{x2}def"
15 msgstr "xyz{x2}{x1}{x3}"
16 # Invalid: missing argument
17 msgid "abc{x2}def{x1}"
18 msgstr "xyz{x1}"
19 # Invalid: missing argument
20 msgid "abc{x1}def{x2}"
21 msgstr "xyz{x2}"
22 # Valid: added argument (valid since "{zoo}" expands to itself)
23 msgid "abc{foo}def"
24 msgstr "xyz{foo}uvw{zoo}"
25 # Valid: multiple reuse of same argument
26 msgid "{foo} {bar} {baz}"
27 msgstr "{baz} {bar} {foo} {bar}"
28 # Valid: single reuse of same argument
29 msgid "{baz} {bar} {foo} {bar}"
30 msgstr "{foo} {bar} {baz}"
31 EOF
33 : ${MSGFMT=msgfmt}
34 n=0
35 while read comment; do
36 read msgid_line
37 read msgstr_line
38 n=`expr $n + 1`
39 tmpfiles="$tmpfiles f-pb-2-$n.po f-pb-2-$n.mo"
40 cat <<EOF > f-pb-2-$n.po
41 #, perl-brace-format
42 ${msgid_line}
43 ${msgstr_line}
44 EOF
45 fail=
46 if echo "$comment" | grep 'Valid:' > /dev/null; then
47 if ${MSGFMT} --check-format -o f-pb-2-$n.mo f-pb-2-$n.po; then
49 else
50 fail=yes
52 else
53 ${MSGFMT} --check-format -o f-pb-2-$n.mo f-pb-2-$n.po 2> /dev/null
54 if test $? = 1; then
56 else
57 fail=yes
60 if test -n "$fail"; then
61 echo "Format string checking error:" 1>&2
62 cat f-pb-2-$n.po 1>&2
63 exit 1
65 rm -f f-pb-2-$n.po f-pb-2-$n.mo
66 done < f-pb-2.data
68 rm -fr $tmpfiles
70 exit 0