• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test checking of Object Pascal format strings.
5
6cat <<\EOF > f-op-2.data
7# Valid: %% doesn't count
8msgid  "abc%%def"
9msgstr "xyz"
10# Invalid: invalid msgstr
11msgid  "abc%%def"
12msgstr "xyz%"
13# Valid: same arguments
14msgid  "abc%s%gdef"
15msgstr "xyz%s%g"
16# Valid: same arguments, with different widths
17msgid  "abc%2sdef"
18msgstr "xyz%3s"
19# Valid: same arguments but in numbered syntax
20msgid  "abc%s%gdef"
21msgstr "xyz%0:s%1:g"
22# Valid: permutation
23msgid  "abc%s%g%cdef"
24msgstr "xyz%2:c%1:g%0:s"
25# Invalid: too few arguments
26msgid  "abc%1:xdef%0:s"
27msgstr "xyz%0:s"
28# Invalid: too few arguments
29msgid  "abc%sdef%x"
30msgstr "xyz%s"
31# Invalid: too many arguments
32msgid  "abc%xdef"
33msgstr "xyz%xvw%p"
34# Valid: same numbered arguments, with different widths
35msgid  "abc%1:5s%0:4s"
36msgstr "xyz%1:4s%0:5s"
37# Valid: same numbered arguments
38msgid  "abc%:s"
39msgstr "xyz%0:s"
40# Valid: same numbered arguments
41msgid  "abc%0:s"
42msgstr "xyz%:s"
43# Invalid: missing argument
44msgid  "abc%1:sdef%0:x"
45msgstr "xyz%0:x"
46# Invalid: missing argument
47msgid  "abc%0:sdef%1:x"
48msgstr "xyz%1:x"
49# Invalid: added argument
50msgid  "abc%0:xdef"
51msgstr "xyz%0:xvw%1:p"
52# Valid: type compatibility
53msgid  "abc%d"
54msgstr "xyz%u"
55# Valid: type compatibility
56msgid  "abc%d"
57msgstr "xyz%x"
58# Valid: type compatibility
59msgid  "abc%u"
60msgstr "xyz%x"
61# Valid: type compatibility
62msgid  "abc%e"
63msgstr "xyz%f"
64# Valid: type compatibility
65msgid  "abc%e"
66msgstr "xyz%g"
67# Valid: type compatibility
68msgid  "abc%e"
69msgstr "xyz%n"
70# Valid: type compatibility
71msgid  "abc%e"
72msgstr "xyz%m"
73# Invalid: type incompatibility
74msgid  "abc%d"
75msgstr "xyz%e"
76# Invalid: type incompatibility
77msgid  "abc%d"
78msgstr "xyz%s"
79# Invalid: type incompatibility
80msgid  "abc%d"
81msgstr "xyz%p"
82# Invalid: type incompatibility
83msgid  "abc%e"
84msgstr "xyz%s"
85# Invalid: type incompatibility
86msgid  "abc%e"
87msgstr "xyz%p"
88# Invalid: type incompatibility
89msgid  "abc%s"
90msgstr "xyz%p"
91# Invalid: type incompatibility for width
92msgid  "abc%g%*g"
93msgstr "xyz%*g%g"
94EOF
95
96: ${MSGFMT=msgfmt}
97n=0
98while read comment; do
99  read msgid_line
100  read msgstr_line
101  n=`expr $n + 1`
102  cat <<EOF > f-op-2-$n.po
103#, object-pascal-format
104${msgid_line}
105${msgstr_line}
106EOF
107  fail=
108  if echo "$comment" | grep 'Valid:' > /dev/null; then
109    if ${MSGFMT} --check-format -o f-op-2-$n.mo f-op-2-$n.po; then
110      :
111    else
112      fail=yes
113    fi
114  else
115    ${MSGFMT} --check-format -o f-op-2-$n.mo f-op-2-$n.po 2> /dev/null
116    if test $? = 1; then
117      :
118    else
119      fail=yes
120    fi
121  fi
122  if test -n "$fail"; then
123    echo "Format string checking error:" 1>&2
124    cat f-op-2-$n.po 1>&2
125    Exit 1
126  fi
127  rm -f f-op-2-$n.po f-op-2-$n.mo
128done < f-op-2.data
129
130Exit 0
131