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