Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / msgfilter-3
1 #! /bin/sh
2
3 # Test general filter execution with Java .properties syntax.
4
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
7
8 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
9   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
10   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
11     ac_n= ac_c='
12 ' ac_t='        '
13   else
14     ac_n=-n ac_c= ac_t=
15   fi
16 else
17   ac_n= ac_c='\c' ac_t=
18 fi
19
20 # Some fold programs (like SunOS4 and FreeBSD) don't have an option to wrap at
21 # spaces.
22 echo abc | fold -b -s -w 20 >/dev/null 2>&1 || {
23   echo "Skipping test: fold program not POSIX compliant"
24   rm -fr $tmpfiles; exit 77
25 }
26
27 # Some fold programs (like NetBSD 5.0) remove trailing spaces when wrapping.
28 echo ab cd | fold -b -s -w 3 | grep ' ' >/dev/null || {
29   echo "Skipping test: fold program trims trailing spaces"
30   rm -fr $tmpfiles; exit 77
31 }
32
33 # Some fold programs (like HP-UX) insert a newline at the end, if the last
34 # line was not terminated with a newline and the -s option was given.
35 foldoutputcount=`echo $ac_n "abc$ac_c" | fold -b -s -w 20 | wc -c`
36 foldoutputcount=`echo "$foldoutputcount" | sed -e 's/[  ]//g'`
37 test "$foldoutputcount" = 3 || {
38   echo "Skipping test: fold program inserts extra newline"
39   rm -fr $tmpfiles; exit 77
40 }
41
42 tmpfiles="$tmpfiles mfi-test3.properties"
43 cat <<\EOF > mfi-test3.properties
44 # HEADER.
45 #
46 !=Project-Id-Version\: Bonnie Tyler\n
47
48 #: married-men:4
49 #, fuzzy
50 !The\ world\ is\ full\ of\ married\ men=So viele verheiratete M\u00e4nner
51
52 #: married-men:5
53 with\ wives\ who\ never\ understand=und ihre Frauen verstehen sie nicht
54
55 #: married-men:6
56 !They're\ looking\ for\ someone\ to\ share=
57
58 # schwer zu \u00fcbersetzen...
59 #: married-men:7
60 !the\ excitement\ of\ a\ love\ affair=
61
62 #: married-men:8
63 !Just\ as\ soon\ as\ they\ find\ you=
64
65 #: married-men:9
66 !They\ warn\ you\ and\ darn\ you=
67 EOF
68
69 tmpfiles="$tmpfiles mfi-test3.out"
70 : ${MSGFILTER=msgfilter}
71 LC_ALL=C \
72 ${MSGFILTER} --properties-input --properties-output -i mfi-test3.properties -o mfi-test3.out fold -b -s -w 20
73 result=$?
74 test $result = 0 || { rm -fr $tmpfiles; exit 1; }
75
76 tmpfiles="$tmpfiles mfi-test3.ok"
77 cat <<\EOF > mfi-test3.ok
78 # HEADER.
79 #
80 !=Project-Id-Version\: \nBonnie Tyler\n
81
82 #: married-men:4
83 #, fuzzy
84 !The\ world\ is\ full\ of\ married\ men=So viele \nverheiratete M\u00e4nner
85
86 #: married-men:5
87 with\ wives\ who\ never\ understand=und ihre Frauen \nverstehen sie nicht
88
89 #: married-men:6
90 !They're\ looking\ for\ someone\ to\ share=
91
92 # schwer zu \u00fcbersetzen...
93 #: married-men:7
94 !the\ excitement\ of\ a\ love\ affair=
95
96 #: married-men:8
97 !Just\ as\ soon\ as\ they\ find\ you=
98
99 #: married-men:9
100 !They\ warn\ you\ and\ darn\ you=
101 EOF
102
103 : ${DIFF=diff}
104 ${DIFF} mfi-test3.ok mfi-test3.out
105 result=$?
106
107 rm -fr $tmpfiles
108
109 exit $result