• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/ap/gpl/timemachine/gettext-0.17/gettext-tools/tests/
1#! /bin/sh
2
3# Test checking of Tcl format strings.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles f-t-2.data"
9cat <<\EOF > f-t-2.data
10# Valid: %% doesn't count
11msgid  "abc%%def"
12msgstr "xyz"
13# Invalid: invalid msgstr
14msgid  "abc%%def"
15msgstr "xyz%"
16# Valid: same arguments
17msgid  "abc%s%gdef"
18msgstr "xyz%s%g"
19# Valid: same arguments, with different widths
20msgid  "abc%2sdef"
21msgstr "xyz%3s"
22# Valid: same arguments but in numbered syntax
23msgid  "abc%s%gdef"
24msgstr "xyz%1$s%2$g"
25# Valid: permutation
26msgid  "abc%s%g%cdef"
27msgstr "xyz%3$c%2$g%1$s"
28# Invalid: too few arguments
29msgid  "abc%2$udef%1$s"
30msgstr "xyz%1$s"
31# Invalid: too few arguments
32msgid  "abc%sdef%u"
33msgstr "xyz%s"
34# Invalid: too many arguments
35msgid  "abc%udef"
36msgstr "xyz%uvw%c"
37# Valid: same numbered arguments, with different widths
38msgid  "abc%2$5s%1$4s"
39msgstr "xyz%2$4s%1$5s"
40# Invalid: missing argument
41msgid  "abc%2$sdef%1$u"
42msgstr "xyz%1$u"
43# Invalid: missing argument
44msgid  "abc%1$sdef%2$u"
45msgstr "xyz%2$u"
46# Invalid: added argument
47msgid  "abc%1$udef"
48msgstr "xyz%1$uvw%2$c"
49# Valid: type compatibility
50msgid  "abc%i"
51msgstr "xyz%d"
52# Valid: type compatibility
53msgid  "abc%o"
54msgstr "xyz%u"
55# Valid: type compatibility
56msgid  "abc%u"
57msgstr "xyz%x"
58# Valid: type compatibility
59msgid  "abc%u"
60msgstr "xyz%X"
61# Valid: type compatibility
62msgid  "abc%e"
63msgstr "xyz%E"
64# Valid: type compatibility
65msgid  "abc%e"
66msgstr "xyz%f"
67# Valid: type compatibility
68msgid  "abc%e"
69msgstr "xyz%g"
70# Valid: type compatibility
71msgid  "abc%e"
72msgstr "xyz%G"
73# Invalid: type incompatibility
74msgid  "abc%c"
75msgstr "xyz%s"
76# Invalid: type incompatibility
77msgid  "abc%c"
78msgstr "xyz%i"
79# Invalid: type incompatibility
80msgid  "abc%c"
81msgstr "xyz%o"
82# Invalid: type incompatibility
83msgid  "abc%c"
84msgstr "xyz%e"
85# Invalid: type incompatibility
86msgid  "abc%s"
87msgstr "xyz%i"
88# Invalid: type incompatibility
89msgid  "abc%s"
90msgstr "xyz%o"
91# Invalid: type incompatibility
92msgid  "abc%s"
93msgstr "xyz%e"
94# Invalid: type incompatibility
95msgid  "abc%i"
96msgstr "xyz%o"
97# Invalid: type incompatibility
98msgid  "abc%i"
99msgstr "xyz%e"
100# Invalid: type incompatibility
101msgid  "abc%u"
102msgstr "xyz%e"
103# Invalid: type incompatibility for width
104msgid  "abc%g%*g"
105msgstr "xyz%*g%g"
106EOF
107
108: ${MSGFMT=msgfmt}
109n=0
110while read comment; do
111  read msgid_line
112  read msgstr_line
113  n=`expr $n + 1`
114  tmpfiles="$tmpfiles f-t-2-$n.po f-t-2-$n.mo"
115  cat <<EOF > f-t-2-$n.po
116#, tcl-format
117${msgid_line}
118${msgstr_line}
119EOF
120  fail=
121  if echo "$comment" | grep 'Valid:' > /dev/null; then
122    if ${MSGFMT} --check-format -o f-t-2-$n.mo f-t-2-$n.po; then
123      :
124    else
125      fail=yes
126    fi
127  else
128    ${MSGFMT} --check-format -o f-t-2-$n.mo f-t-2-$n.po 2> /dev/null
129    if test $? = 1; then
130      :
131    else
132      fail=yes
133    fi
134  fi
135  if test -n "$fail"; then
136    echo "Format string checking error:" 1>&2
137    cat f-t-2-$n.po 1>&2
138    exit 1
139  fi
140  rm -f f-t-2-$n.po f-t-2-$n.mo
141done < f-t-2.data
142
143rm -fr $tmpfiles
144
145exit 0
146