• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test checking of Java format strings.
5
6cat <<\EOF > f-cs-2.data
7# Invalid: invalid msgstr
8msgid  "abc{0}def"
9msgstr "abc{"
10# Valid: same arguments
11msgid  "abc{1}def"
12msgstr "xyz{1}"
13# Valid: same arguments, differently written
14msgid  "abc{1}def"
15msgstr "xyz{01}"
16# Valid: permutation
17msgid  "abc{2}{0}{1}def"
18msgstr "xyz{1}{0}{2}"
19# Invalid: too few arguments
20msgid  "abc{1}def{0}"
21msgstr "xyz{0}"
22# Invalid: too many arguments
23msgid  "abc{0}def"
24msgstr "xyz{0}uvw{1}"
25# Valid: missing non-final argument
26msgid  "abc{1}def{0}"
27msgstr "xyz{1}"
28# Valid: added non-final argument
29msgid  "abc{1}def"
30msgstr "xyz{0}{1}"
31# Invalid: different number of arguments
32msgid  "abc{500000000}def"
33msgstr "xyz{500000001}"
34# Valid: type compatibility
35msgid  "abc{1:X}"
36msgstr "xyz{1:g}"
37EOF
38
39: ${MSGFMT=msgfmt}
40n=0
41while read comment; do
42  read msgid_line
43  read msgstr_line
44  n=`expr $n + 1`
45  cat <<EOF > f-cs-2-$n.po
46#, csharp-format
47${msgid_line}
48${msgstr_line}
49EOF
50  fail=
51  if echo "$comment" | grep 'Valid:' > /dev/null; then
52    if ${MSGFMT} --check-format -o f-cs-2-$n.mo f-cs-2-$n.po; then
53      :
54    else
55      fail=yes
56    fi
57  else
58    ${MSGFMT} --check-format -o f-cs-2-$n.mo f-cs-2-$n.po 2> /dev/null
59    if test $? = 1; then
60      :
61    else
62      fail=yes
63    fi
64  fi
65  if test -n "$fail"; then
66    echo "Format string checking error:" 1>&2
67    cat f-cs-2-$n.po 1>&2
68    Exit 1
69  fi
70  rm -f f-cs-2-$n.po f-cs-2-$n.mo
71done < f-cs-2.data
72
73Exit 0
74