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