• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/tests/
1#! /bin/sh
2
3# Test checking of Java format strings.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles f-j-2.data"
9cat <<\EOF > f-j-2.data
10# Invalid: invalid msgstr
11msgid  "abc{0}def"
12msgstr "abc{"
13# Valid: same arguments
14msgid  "abc{1}def"
15msgstr "xyz{1}"
16# Valid: same arguments, differently written
17msgid  "abc{1}def"
18msgstr "xyz{01}"
19# Valid: permutation
20msgid  "abc{2}{0}{1}def"
21msgstr "xyz{1}{0}{2}"
22# Invalid: too few arguments
23msgid  "abc{1}def{0}"
24msgstr "xyz{0}"
25# Invalid: too many arguments
26msgid  "abc{0}def"
27msgstr "xyz{0}uvw{1}"
28# Invalid: missing non-final argument
29msgid  "abc{1}def{0}"
30msgstr "xyz{1}"
31# Invalid: added non-final argument
32msgid  "abc{1}def"
33msgstr "xyz{0}{1}"
34# Invalid: different number of arguments
35msgid  "abc{500000000}def"
36msgstr "xyz{500000001}"
37# Valid: type compatibility
38msgid  "abc{1,number}"
39msgstr "xyz{1,choice,0#zero|1#{1,number}}"
40# Valid: type compatibility
41msgid  "abc{1,number}"
42msgstr "xyz{1,number,currency}"
43# Valid: type compatibility
44msgid  "abc{1,number}"
45msgstr "xyz{1,number,percent}"
46# Valid: type compatibility
47msgid  "abc{1,number}"
48msgstr "xyz{1,number,integer}"
49# Valid: type compatibility
50msgid  "abc{1,number}"
51msgstr "xyz{1,number,###,##0}"
52# Valid: type compatibility
53msgid  "abc{1,date}"
54msgstr "xyz{1,time}"
55# Valid: type compatibility
56msgid  "abc{1,date}"
57msgstr "xyz{1,date,short}"
58# Valid: type compatibility
59msgid  "abc{1,date}"
60msgstr "xyz{1,date,medium}"
61# Valid: type compatibility
62msgid  "abc{1,date}"
63msgstr "xyz{1,date,long}"
64# Valid: type compatibility
65msgid  "abc{1,date}"
66msgstr "xyz{1,date,full}"
67# Valid: type compatibility
68msgid  "abc{1,date}"
69msgstr "xyz{1,date,yyyy-MM-dd}"
70# Valid: type compatibility
71msgid  "abc{1,time}"
72msgstr "xyz{1,time,short}"
73# Valid: type compatibility
74msgid  "abc{1,time}"
75msgstr "xyz{1,time,medium}"
76# Valid: type compatibility
77msgid  "abc{1,time}"
78msgstr "xyz{1,time,long}"
79# Valid: type compatibility
80msgid  "abc{1,time}"
81msgstr "xyz{1,time,full}"
82# Valid: type compatibility
83msgid  "abc{1,time}"
84msgstr "xyz{1,time,}"
85# Valid: type compatibility
86msgid  "abc{1,time}"
87msgstr "xyz{1,time,hh:mm:ss}"
88# Invalid: type incompatibility
89msgid  "abc{1}"
90msgstr "xyz{1,number}"
91# Invalid: type incompatibility
92msgid  "abc{1}"
93msgstr "xyz{1,date}"
94# Invalid: type incompatibility
95msgid  "abc{1,time}"
96msgstr "xyz{1,number}"
97# Invalid: type incompatibility
98msgid  "abc{1,number}"
99msgstr "xyz{1,date}"
100# Invalid: type incompatibility
101msgid  "abc{1}"
102msgstr "xyz{1,choice,0#zero|1#{1,number}}"
103# Invalid: type incompatibility
104msgid  "abc{1}"
105msgstr "xyz{1,choice,0#zero|1#{0,number}}"
106# Invalid: type incompatibility
107msgid  "abc{0,number}{1}"
108msgstr "xyz{0,choice,0#zero|1#{1,number}}"
109EOF
110
111: ${MSGFMT=msgfmt}
112n=0
113while read comment; do
114  read msgid_line
115  read msgstr_line
116  n=`expr $n + 1`
117  tmpfiles="$tmpfiles f-j-2-$n.po f-j-2-$n.mo"
118  cat <<EOF > f-j-2-$n.po
119#, java-format
120${msgid_line}
121${msgstr_line}
122EOF
123  fail=
124  if echo "$comment" | grep 'Valid:' > /dev/null; then
125    if ${MSGFMT} --check-format -o f-j-2-$n.mo f-j-2-$n.po; then
126      :
127    else
128      fail=yes
129    fi
130  else
131    ${MSGFMT} --check-format -o f-j-2-$n.mo f-j-2-$n.po 2> /dev/null
132    if test $? = 1; then
133      :
134    else
135      fail=yes
136    fi
137  fi
138  if test -n "$fail"; then
139    echo "Format string checking error:" 1>&2
140    cat f-j-2-$n.po 1>&2
141    exit 1
142  fi
143  rm -f f-j-2-$n.po f-j-2-$n.mo
144done < f-j-2.data
145
146rm -fr $tmpfiles
147
148exit 0
149