• 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 KDE format strings.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles f-kd-2.data"
9cat <<\EOF > f-kd-2.data
10# Valid: %% doesn't count
11msgid  "abc%%def"
12msgstr "xyz"
13# Valid: digit sequence starting with 0 doesn't count
14msgid  "abc%09def"
15msgstr "xyz"
16# Valid: digit sequence starting with 0 doesn't count
17msgid  "abc%0"
18msgstr "xyz"
19# Valid: digit sequence starting with 0 doesn't count
20msgid  "abc%00"
21msgstr "xyz"
22# Valid: L is not a recognized flag
23msgid  "abc%L1def"
24msgstr "xyz"
25# Valid: same arguments
26msgid  "abc%2def"
27msgstr "xyz%2"
28# Invalid: different arguments
29msgid  "abc%2def"
30msgstr "xyz%1"
31# Invalid: different arguments
32msgid  "abc%1def"
33msgstr "xyz%2"
34# Valid: repetition of an argument in the translation
35msgid  "abc%2def"
36msgstr "xyz%2uvw%2"
37# Valid: removing repeated argument in the translation
38msgid  "abc%2def%2"
39msgstr "xyz%2uvw"
40# Valid: permutation
41msgid  "abc%3%1%2def"
42msgstr "xyz%2%1%3"
43# Invalid: too few arguments
44msgid  "abc%2def%1ghi%3"
45msgstr "xyz%1"
46# Invalid: only one argument removed (valid only in singular form)
47msgid  "abc%2def%1ghi%3"
48msgstr "xyz%1uvw%2"
49# Invalid: only one argument removed (valid only in singular form)
50msgid  "abc%2def%1ghi%3"
51msgstr "xyz%1uvw%3"
52# Invalid: only one argument removed (valid only in singular form)
53msgid  "abc%2def%1ghi%3"
54msgstr "xyz%3uvw%2"
55# Invalid: only one argument removed (valid only in singular form)
56msgid  "abc%1def%3"
57msgstr "xyz%1"
58# Invalid: wrong argument removed
59msgid  "abc%1def%3"
60msgstr "xyz%3"
61# Invalid: too many arguments
62msgid  "abc%1def"
63msgstr "xyz%1uvw%2"
64# Invalid: missing non-final argument (valid only in singular form)
65msgid  "abc%2def%1"
66msgstr "xyz%2"
67# Invalid: added non-final argument
68msgid  "abc%2def"
69msgstr "xyz%1%2"
70EOF
71
72: ${MSGFMT=msgfmt}
73n=0
74while read comment; do
75  read msgid_line
76  read msgstr_line
77  n=`expr $n + 1`
78  tmpfiles="$tmpfiles f-kd-2-$n.po f-kd-2-$n.mo"
79  cat <<EOF > f-kd-2-$n.po
80#, kde-format
81${msgid_line}
82${msgstr_line}
83EOF
84  fail=
85  if echo "$comment" | grep 'Valid:' > /dev/null; then
86    if ${MSGFMT} --check-format -o f-kd-2-$n.mo f-kd-2-$n.po; then
87      :
88    else
89      fail=yes
90    fi
91  else
92    ${MSGFMT} --check-format -o f-kd-2-$n.mo f-kd-2-$n.po 2> /dev/null
93    if test $? = 1; then
94      :
95    else
96      fail=yes
97    fi
98  fi
99  if test -n "$fail"; then
100    echo "Format string checking error:" 1>&2
101    cat f-kd-2-$n.po 1>&2
102    exit 1
103  fi
104  rm -f f-kd-2-$n.po f-kd-2-$n.mo
105done < f-kd-2.data
106
107rm -fr $tmpfiles
108
109exit 0
110