• 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 recognition of Python format strings.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles f-p-1.data"
9cat <<\EOF > f-p-1.data
10# Valid: no argument
11"abc%%"
12# Valid: one character argument
13"abc%c"
14# Valid: one string argument
15"abc%s"
16# Valid: one string argument
17"abc%r"
18# Valid: one integer argument
19"abc%i"
20# Valid: one integer argument
21"abc%d"
22# Valid: one integer argument
23"abc%u"
24# Valid: one integer argument
25"abc%o"
26# Valid: one integer argument
27"abc%x"
28# Valid: one integer argument
29"abc%X"
30# Valid: one floating-point argument
31"abc%e"
32# Valid: one floating-point argument
33"abc%E"
34# Valid: one floating-point argument
35"abc%f"
36# Valid: one floating-point argument
37"abc%g"
38# Valid: one floating-point argument
39"abc%G"
40# Valid: one argument with flags
41"abc%0#g"
42# Valid: one argument with width
43"abc%2g"
44# Valid: one argument with width
45"abc%*g"
46# Valid: one argument with precision
47"abc%.4g"
48# Valid: one argument with precision
49"abc%.*g"
50# Valid: one argument with width and precision
51"abc%14.4g"
52# Valid: one argument with width and precision
53"abc%14.*g"
54# Valid: one argument with width and precision
55"abc%*.4g"
56# Valid: one argument with width and precision
57"abc%*.*g"
58# Valid: one argument with size specifier
59"abc%hi"
60# Valid: one argument with size specifier
61"abc%li"
62# Valid: one argument with size specifier
63"abc%Li"
64# Invalid: unterminated
65"abc%"
66# Invalid: unknown format specifier
67"abc%y"
68# Invalid: flags after width
69"abc%*0g"
70# Invalid: twice precision
71"abc%.4.2g"
72# Invalid: two size specifiers
73"abc%lli"
74# Valid: three arguments
75"abc%d%u%u"
76# Valid: a named argument
77"abc%(value)d"
78# Valid: an empty name
79"abc%()d"
80# Invalid: unterminated name
81"abc%(value"
82# Valid: ignored named argument
83"abc%(dummy)%"
84# Invalid: flags before name
85"abc%0(value)d"
86# Valid: three arguments, two with equal names
87"abc%(addr)4x,%(char)c,%(addr)u"
88# Invalid: argument with conflicting types
89"abc%(addr)4x,%(char)c,%(addr)s"
90# Valid: no conflict
91"abc%(addr)r,%(addr)s"
92# Invalid: mixing of named and unnamed arguments
93"abc%d%(addr)x"
94# Valid: named argument with constant precision
95"abc%(addr).9x"
96# Invalid: mixing of named and unnamed arguments
97"abc%(addr).*x"
98EOF
99
100tmpfiles="$tmpfiles f-p-1.err"
101: ${XGETTEXT=xgettext}
102n=0
103while read comment; do
104  read string
105  n=`expr $n + 1`
106  tmpfiles="$tmpfiles f-p-1-$n.in f-p-1-$n.po"
107  cat <<EOF > f-p-1-$n.in
108gettext(${string});
109EOF
110  # Hide xgettext's "The translator cannot reorder the arguments." warnings.
111  ${XGETTEXT} -L Python -o f-p-1-$n.po f-p-1-$n.in 2> f-p-1.err \
112    || { cat f-p-1.err 1>&2; exit 1; }
113  test -f f-p-1-$n.po || exit 1
114  fail=
115  if echo "$comment" | grep 'Valid:' > /dev/null; then
116    if grep python-format f-p-1-$n.po > /dev/null; then
117      :
118    else
119      fail=yes
120    fi
121  else
122    if grep python-format f-p-1-$n.po > /dev/null; then
123      fail=yes
124    else
125      :
126    fi
127  fi
128  if test -n "$fail"; then
129    echo "Format string recognition error:" 1>&2
130    cat f-p-1-$n.in 1>&2
131    echo "Got:" 1>&2
132    cat f-p-1-$n.po 1>&2
133    exit 1
134  fi
135  rm -f f-p-1-$n.in f-p-1-$n.po
136done < f-p-1.data
137
138rm -fr $tmpfiles
139
140exit 0
141