• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test recognition of Perl brace format strings.
5
6cat <<\EOF > f-pb-1.data
7# Invalid: no argument
8"abc"
9# Valid: a named argument
10"abc{value}"
11# Invalid: an empty name
12"abc{}"
13# Invalid: unterminated name
14"abc{value"
15# Valid: three arguments, two with equal names
16"abc{addr},{char},{addr}"
17# Invalid: place-holder contains a space.
18"{foo bar}"
19# Invalid: missing right angle bracket.
20"{foo bar"
21# Valid: not nested, but one single place-holder.
22"{foo{bar}baz}"
23# Valid: no nesting error, but one single place-holder.
24"{foo{bar}baz"
25# Valid: place-holder with spaces must be ignored, but still one remaining.
26"{foo bar} {baz}"
27# Invalid: percent sign not allowed.
28"{foo%bar}"
29EOF
30
31: ${XGETTEXT=xgettext}
32n=0
33while read comment; do
34  read string
35  n=`expr $n + 1`
36  cat <<EOF > f-pb-1-$n.in
37gettext(${string});
38EOF
39  ${XGETTEXT} -L Perl -o f-pb-1-$n.po f-pb-1-$n.in || Exit 1
40  test -f f-pb-1-$n.po || Exit 1
41  fail=
42  if echo "$comment" | grep 'Valid:' > /dev/null; then
43    if grep perl-brace-format f-pb-1-$n.po > /dev/null; then
44      :
45    else
46      fail=yes
47    fi
48  else
49    if grep perl-brace-format f-pb-1-$n.po > /dev/null; then
50      fail=yes
51    else
52      :
53    fi
54  fi
55  if test -n "$fail"; then
56    echo "Format string recognition error:" 1>&2
57    cat f-pb-1-$n.in 1>&2
58    echo "Got:" 1>&2
59    cat f-pb-1-$n.po 1>&2
60    Exit 1
61  fi
62  rm -f f-pb-1-$n.in f-pb-1-$n.po
63done < f-pb-1.data
64
65Exit 0
66