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