• 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 Shell format strings.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles f-sh-2.data"
9cat <<\EOF > f-sh-2.data
10# Invalid: invalid msgstr
11msgid  "abc$file"
12msgstr "xyz$file$"
13# Valid: same arguments, permutation
14msgid  "abc$file in $dir"
15msgstr "xyz$dir o $file"
16# Invalid: missing argument
17msgid  "abc$dir/$file"
18msgstr "xyz$file"
19# Invalid: added argument
20msgid  "abc$file"
21msgstr "xyz$file in $dir"
22# Valid: braces or not, doesn't matter
23msgid  "abc$file"
24msgstr "xyz${file}"
25# Invalid: different default value
26msgid  "abc$file"
27msgstr "xyz${file-/tmpdir}"
28EOF
29
30: ${MSGFMT=msgfmt}
31n=0
32while read comment; do
33  read msgid_line
34  read msgstr_line
35  n=`expr $n + 1`
36  tmpfiles="$tmpfiles f-sh-2-$n.po f-sh-2-$n.mo"
37  cat <<EOF > f-sh-2-$n.po
38#, sh-format
39${msgid_line}
40${msgstr_line}
41EOF
42  fail=
43  if echo "$comment" | grep 'Valid:' > /dev/null; then
44    if ${MSGFMT} --check-format -o f-sh-2-$n.mo f-sh-2-$n.po; then
45      :
46    else
47      fail=yes
48    fi
49  else
50    ${MSGFMT} --check-format -o f-sh-2-$n.mo f-sh-2-$n.po 2> /dev/null
51    if test $? = 1; then
52      :
53    else
54      fail=yes
55    fi
56  fi
57  if test -n "$fail"; then
58    echo "Format string checking error:" 1>&2
59    cat f-sh-2-$n.po 1>&2
60    exit 1
61  fi
62  rm -f f-sh-2-$n.po f-sh-2-$n.mo
63done < f-sh-2.data
64
65rm -fr $tmpfiles
66
67exit 0
68