• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/ap/gpl/timemachine/gettext-0.17/gettext-tools/tests/
1#! /bin/sh
2
3# Test checking of Perl format strings.
4# This test is for the combination of printf and brace format strings.
5
6tmpfiles=""
7trap 'rm -fr $tmpfiles' 1 2 3 15
8
9tmpfiles="$tmpfiles f-pm-2.data"
10cat <<\EOF > f-pm-2.data
11# Valid: normal case.
12#, perl-format, perl-brace-format
13msgid  "{foo} %d {bar} %s"
14msgstr "{bar} {foo} %d %s"
15# Invalid: missing argument.
16#, perl-format, perl-brace-format
17msgid  "{foo} %d {bar} %s"
18msgstr "{bar} %d %s"
19# Valid: missing argument but checking disabled.
20#, perl-format, no-perl-brace-format
21msgid  "{foo} %d {bar} %s"
22msgstr "{bar} %d %s"
23# Invalid: printf format reordered without position specifiers %1$, %2$.
24#, perl-format, perl-brace-format
25msgid  "{foo} %d {bar} %s"
26msgstr "{bar} %s {foo} %d"
27# Valid: same thing but checking disabled.
28#, no-perl-format, perl-brace-format
29msgid  "{foo} %d {bar} %s"
30msgstr "{bar} %s {foo} %d"
31# Invalid: unnamed vs. named arguments
32#, perl-format
33msgid  "abc%sdef"
34msgstr "xyz{value}"
35# Invalid: named vs. unnamed arguments
36#, perl-brace-format
37msgid  "abc{value}def"
38msgstr "xyz%s"
39EOF
40
41: ${MSGFMT=msgfmt}
42n=0
43while read comment; do
44  read formats
45  read msgid_line
46  read msgstr_line
47  n=`expr $n + 1`
48  tmpfiles="$tmpfiles f-pm-2-$n.po f-pm-2-$n.mo"
49  cat <<EOF > f-pm-2-$n.po
50${formats}
51${msgid_line}
52${msgstr_line}
53EOF
54  fail=
55  if echo "$comment" | grep 'Valid:' > /dev/null; then
56    if ${MSGFMT} --check-format -o f-pm-2-$n.mo f-pm-2-$n.po; then
57      :
58    else
59      fail=yes
60    fi
61  else
62    ${MSGFMT} --check-format -o f-pm-2-$n.mo f-pm-2-$n.po 2> /dev/null
63    if test $? = 1; then
64      :
65    else
66      fail=yes
67    fi
68  fi
69  if test -n "$fail"; then
70    echo "Format string checking error:" 1>&2
71    cat f-pm-2-$n.po 1>&2
72    exit 1
73  fi
74done < f-pm-2.data
75
76rm -fr $tmpfiles
77
78exit 0
79