• 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 Qt format strings.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles f-qt-2.data"
9cat <<\EOF > f-qt-2.data
10# Valid: %% doesn't count
11msgid  "abc%%def"
12msgstr "xyz"
13# Valid: same arguments
14msgid  "abc%2def"
15msgstr "xyz%2"
16# Valid: same arguments, msgstr may be simpler than msgid
17msgid  "abc%L2def"
18msgstr "xyz%2"
19# Valid: same arguments, msgstr may be simpler than msgid
20msgid  "abc%02def"
21msgstr "xyz%2"
22# Invalid: msgid is simple but msgstr is not
23msgid  "abc%2def"
24msgstr "xyz%L2"
25# Invalid: msgid is simple but msgstr is not
26msgid  "abc%2def"
27msgstr "xyz%02"
28# Valid: repetition of an argument in the translation
29msgid  "abc%2def"
30msgstr "xyz%2uvw%2"
31# Valid: removing repeated argument in the translation
32msgid  "abc%2def%2"
33msgstr "xyz%2uvw"
34# Valid: permutation
35msgid  "abc%3%1%2def"
36msgstr "xyz%2%1%3"
37# Invalid: too few arguments
38msgid  "abc%2def%1"
39msgstr "xyz%1"
40# Invalid: too many arguments
41msgid  "abc%1def"
42msgstr "xyz%1uvw%2"
43# Invalid: missing non-final argument
44msgid  "abc%2def%1"
45msgstr "xyz%2"
46# Invalid: added non-final argument
47msgid  "abc%2def"
48msgstr "xyz%1%2"
49EOF
50
51: ${MSGFMT=msgfmt}
52n=0
53while read comment; do
54  read msgid_line
55  read msgstr_line
56  n=`expr $n + 1`
57  tmpfiles="$tmpfiles f-qt-2-$n.po f-qt-2-$n.mo"
58  cat <<EOF > f-qt-2-$n.po
59#, qt-format
60${msgid_line}
61${msgstr_line}
62EOF
63  fail=
64  if echo "$comment" | grep 'Valid:' > /dev/null; then
65    if ${MSGFMT} --check-format -o f-qt-2-$n.mo f-qt-2-$n.po; then
66      :
67    else
68      fail=yes
69    fi
70  else
71    ${MSGFMT} --check-format -o f-qt-2-$n.mo f-qt-2-$n.po 2> /dev/null
72    if test $? = 1; then
73      :
74    else
75      fail=yes
76    fi
77  fi
78  if test -n "$fail"; then
79    echo "Format string checking error:" 1>&2
80    cat f-qt-2-$n.po 1>&2
81    exit 1
82  fi
83  rm -f f-qt-2-$n.po f-qt-2-$n.mo
84done < f-qt-2.data
85
86rm -fr $tmpfiles
87
88exit 0
89