summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/xgettext-c-14
blob: 498d07c9a4e9ce7ce3e2fca271257a3ba4efe231 (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
#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test C++ support: test boost-format.

cat <<\EOF > xg-c-14.cc
// These are recognized as boost-format because of the keyword 'format'.
format(gettext("%s on, %s off"));
format(gettext("%1$d on, %2$d off"));
format(gettext("%|1$| on, %|2$| off"));
format(gettext("%1% on, %2% off"));
// These are recognized as boost-format only through the heuristics.
gettext("heuristic %s on, %s off");
gettext("heuristic %1$d on, %2$d off");
gettext("heuristic %|1$| on, %|2$| off");
gettext("heuristic %1% on, %2% off");
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} --omit-header --no-location -d xg-c-14.tmp --boost xg-c-14.cc || Exit 1
LC_ALL=C tr -d '\r' < xg-c-14.tmp.po > xg-c-14.po || Exit 1

# The first 4 are not marked as c-format, because they are known as
# boost-format. The last 4 are governed by the heuristic. The first two
# among them are valid c-format strings. The last one is a valid but unlikely
# c-format string, therefore the heuristic doesn't mark it.
cat <<\EOF > xg-c-14.ok
#, boost-format
msgid "%s on, %s off"
msgstr ""

#, boost-format
msgid "%1$d on, %2$d off"
msgstr ""

#, boost-format
msgid "%|1$| on, %|2$| off"
msgstr ""

#, boost-format
msgid "%1% on, %2% off"
msgstr ""

#, c-format, boost-format
msgid "heuristic %s on, %s off"
msgstr ""

#, c-format, boost-format
msgid "heuristic %1$d on, %2$d off"
msgstr ""

#, boost-format
msgid "heuristic %|1$| on, %|2$| off"
msgstr ""

#, boost-format
msgid "heuristic %1% on, %2% off"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-c-14.ok xg-c-14.po
result=$?

exit $result