• 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 Shell format strings.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles f-sh-1.data"
9cat <<\EOF > f-sh-1.data
10# Invalid: no argument
11"abc"
12# Valid: one argument
13"abc$file"
14# Valid: one argument
15"abc$f_x"
16# Invalid: context dependent variable
17"abc$0"
18# Invalid: context dependent variable
19"abc$$"
20# Invalid: complex shell syntax
21"abc${tmpdir-/tmp}"
22# Invalid: unterminated
23"abc$"
24# Invalid: unterminated name
25"abc${A"
26# Invalid: non-ASCII character
27"abc$�"
28# Invalid: non-ASCII character
29"abc${�}"
30# Invalid: an empty name
31"abc${}"
32# Valid: three arguments
33"abc$dir$file"
34# Valid: three arguments, two with equal names
35"abc$addr$char$addr"
36EOF
37
38: ${XGETTEXT=xgettext}
39n=0
40while read comment; do
41  read string
42  n=`expr $n + 1`
43  tmpfiles="$tmpfiles f-sh-1-$n.in f-sh-1-$n.po"
44  sed -e 's,\$,\\$,g' <<EOF > f-sh-1-$n.in
45gettext ${string};
46EOF
47  ${XGETTEXT} -L Shell --from-code=ISO-8859-1 -o f-sh-1-$n.po f-sh-1-$n.in || exit 1
48  test -f f-sh-1-$n.po || exit 1
49  fail=
50  if echo "$comment" | grep 'Valid:' > /dev/null; then
51    if grep sh-format f-sh-1-$n.po > /dev/null; then
52      :
53    else
54      fail=yes
55    fi
56  else
57    if grep sh-format f-sh-1-$n.po > /dev/null; then
58      fail=yes
59    else
60      :
61    fi
62  fi
63  if test -n "$fail"; then
64    echo "Format string recognition error:" 1>&2
65    cat f-sh-1-$n.in 1>&2
66    echo "Got:" 1>&2
67    cat f-sh-1-$n.po 1>&2
68    exit 1
69  fi
70  rm -f f-sh-1-$n.in f-sh-1-$n.po
71done < f-sh-1.data
72
73rm -fr $tmpfiles
74
75exit 0
76