• 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 librep format strings.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles f-lr-2.data"
9cat <<\EOF > f-lr-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%xdef"
18msgstr "xyz%s%x"
19# Valid: same arguments, with different widths
20msgid  "abc%2sdef"
21msgstr "xyz%3s"
22# Valid: same arguments but in numbered syntax
23msgid  "abc%s%xdef"
24msgstr "xyz%1$s%2$x"
25# Valid: permutation
26msgid  "abc%s%x%cdef"
27msgstr "xyz%3$c%2$x%1$s"
28# Invalid: too few arguments
29msgid  "abc%2$xdef%1$s"
30msgstr "xyz%1$s"
31# Invalid: too few arguments
32msgid  "abc%sdef%x"
33msgstr "xyz%s"
34# Invalid: too many arguments
35msgid  "abc%xdef"
36msgstr "xyz%xvw%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$x"
42msgstr "xyz%1$x"
43# Invalid: missing argument
44msgid  "abc%1$sdef%2$x"
45msgstr "xyz%2$x"
46# Invalid: added argument
47msgid  "abc%1$xdef"
48msgstr "xyz%1$xvw%2$c"
49# Valid: type compatibility
50msgid  "abc%d"
51msgstr "xyz%x"
52# Valid: type compatibility
53msgid  "abc%d"
54msgstr "xyz%X"
55# Valid: type compatibility
56msgid  "abc%d"
57msgstr "xyz%o"
58# Valid: type compatibility
59msgid  "abc%x"
60msgstr "xyz%X"
61# Valid: type compatibility
62msgid  "abc%x"
63msgstr "xyz%o"
64# Valid: type compatibility
65msgid  "abc%X"
66msgstr "xyz%o"
67# Invalid: type incompatibility
68msgid  "abc%c"
69msgstr "xyz%d"
70# Invalid: type incompatibility
71msgid  "abc%c"
72msgstr "xyz%x"
73# Invalid: type incompatibility
74msgid  "abc%c"
75msgstr "xyz%X"
76# Invalid: type incompatibility
77msgid  "abc%c"
78msgstr "xyz%o"
79# Invalid: type incompatibility
80msgid  "abc%c"
81msgstr "xyz%s"
82# Invalid: type incompatibility
83msgid  "abc%c"
84msgstr "xyz%S"
85# Invalid: type incompatibility
86msgid  "abc%d"
87msgstr "xyz%s"
88# Invalid: type incompatibility
89msgid  "abc%d"
90msgstr "xyz%S"
91# Invalid: type incompatibility
92msgid  "abc%x"
93msgstr "xyz%s"
94# Invalid: type incompatibility
95msgid  "abc%x"
96msgstr "xyz%S"
97# Invalid: type incompatibility
98msgid  "abc%X"
99msgstr "xyz%s"
100# Invalid: type incompatibility
101msgid  "abc%X"
102msgstr "xyz%S"
103# Invalid: type incompatibility
104msgid  "abc%o"
105msgstr "xyz%s"
106# Invalid: type incompatibility
107msgid  "abc%o"
108msgstr "xyz%S"
109# Invalid: type incompatibility
110msgid  "abc%s"
111msgstr "xyz%S"
112EOF
113
114: ${MSGFMT=msgfmt}
115n=0
116while read comment; do
117  read msgid_line
118  read msgstr_line
119  n=`expr $n + 1`
120  tmpfiles="$tmpfiles f-lr-2-$n.po f-lr-2-$n.mo"
121  cat <<EOF > f-lr-2-$n.po
122#, librep-format
123${msgid_line}
124${msgstr_line}
125EOF
126  fail=
127  if echo "$comment" | grep 'Valid:' > /dev/null; then
128    if ${MSGFMT} --check-format -o f-lr-2-$n.mo f-lr-2-$n.po; then
129      :
130    else
131      fail=yes
132    fi
133  else
134    ${MSGFMT} --check-format -o f-lr-2-$n.mo f-lr-2-$n.po 2> /dev/null
135    if test $? = 1; then
136      :
137    else
138      fail=yes
139    fi
140  fi
141  if test -n "$fail"; then
142    echo "Format string checking error:" 1>&2
143    cat f-lr-2-$n.po 1>&2
144    exit 1
145  fi
146  rm -f f-lr-2-$n.po f-lr-2-$n.mo
147done < f-lr-2.data
148
149rm -fr $tmpfiles
150
151exit 0
152