summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/format-gfc-internal-1
blob: da26e76a95cfde5644fcf9e70dff5a83473354d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test recognition of GFC internal format strings.

cat <<\EOF > f-gf-1.data
# Valid: no argument
"abc%%"
# Valid: void argument
"abc%C"
# Valid: one locus argument
"abc%L"
# Valid: one character argument
"abc%c"
# Valid: one string argument
"abc%s"
# Valid: one integer argument
"abc%i"
# Valid: one integer argument
"abc%d"
# Valid: one integer argument
"abc%u"
# Valid: one argument with size specifier
"abc%li"
# Valid: one argument with size specifier
"abc%ld"
# Valid: one argument with size specifier
"abc%lu"
# Invalid: one argument with invalid size specifier
"abc%lli"
# Invalid: one argument with invalid size specifier
"abc%llu"
# Invalid: one argument with invalid size specifier
"abc%ls"
# Invalid: unterminated
"abc%"
# Invalid: unknown format specifier
"abc%y"
# Invalid: precision
"abc%.*s"
# Valid: three arguments
"abc%d%u%u"
# Valid: a numbered argument
"abc%1$d"
# Invalid: zero
"abc%0$d"
# Invalid: unterminated number
"abc%1"
# Valid: three arguments, two with same number
"abc%1$i,%2$c,%1$d"
# Invalid: argument with conflicting types
"abc%1$i,%2$c,%1$u"
# Valid: multiple uses of void argument
"abc%Cdef%dghi%C"
# Invalid: argument with conflicting types
"abc%1$i,%2$c,%1$C"
# Valid: mixing of numbered and unnumbered arguments
"abc%d%2$u"
# Invalid: missing non-final argument
"abc%2$u%3$s"
# Valid: non-final argument is void
"abc%C%2$u%3$s"
# Valid: permutation
"abc%2$ddef%1$d"
# Valid: multiple uses of same argument
"abc%2$udef%1$sghi%2$u"
EOF

: ${XGETTEXT=xgettext}
n=0
while read comment; do
  read string
  n=`expr $n + 1`
  cat <<EOF > f-gf-1-$n.in
gettext(${string});
EOF
  ${XGETTEXT} -L GCC-source -o f-gf-1-$n.po f-gf-1-$n.in || Exit 1
  test -f f-gf-1-$n.po || Exit 1
  fail=
  if echo "$comment" | grep 'Valid:' > /dev/null; then
    if grep gfc-internal-format f-gf-1-$n.po > /dev/null; then
      :
    else
      fail=yes
    fi
  else
    if grep gfc-internal-format f-gf-1-$n.po > /dev/null; then
      fail=yes
    else
      :
    fi
  fi
  if test -n "$fail"; then
    echo "Format string recognition error:" 1>&2
    cat f-gf-1-$n.in 1>&2
    echo "Got:" 1>&2
    cat f-gf-1-$n.po 1>&2
    Exit 1
  fi
  rm -f f-gf-1-$n.in f-gf-1-$n.po
done < f-gf-1.data

Exit 0