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