xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/tests/xgettext-c-14 (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1#! /bin/sh
2
3# Test C++ support: test boost-format.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles xg-c-14.cc"
9cat <<\EOF > xg-c-14.cc
10// These are recognized as boost-format because of the keyword 'format'.
11format(gettext("%s on, %s off"));
12format(gettext("%1$d on, %2$d off"));
13format(gettext("%|1$| on, %|2$| off"));
14format(gettext("%1% on, %2% off"));
15// These are recognized as boost-format only through the heuristics.
16gettext("heuristic %s on, %s off");
17gettext("heuristic %1$d on, %2$d off");
18gettext("heuristic %|1$| on, %|2$| off");
19gettext("heuristic %1% on, %2% off");
20EOF
21
22tmpfiles="$tmpfiles xg-c-14.po"
23: ${XGETTEXT=xgettext}
24${XGETTEXT} --omit-header --no-location -d xg-c-14 --boost xg-c-14.cc
25test $? = 0 || { rm -fr $tmpfiles; exit 1; }
26
27# The first 4 are not marked as c-format, because they are known as
28# boost-format. The last 4 are governed by the heuristic. The first two
29# among them are valid c-format strings. The last one is a valid but unlikely
30# c-format string, therefore the heuristic doesn't mark it.
31tmpfiles="$tmpfiles xg-c-14.ok"
32cat <<\EOF > xg-c-14.ok
33#, boost-format
34msgid "%s on, %s off"
35msgstr ""
36
37#, boost-format
38msgid "%1$d on, %2$d off"
39msgstr ""
40
41#, boost-format
42msgid "%|1$| on, %|2$| off"
43msgstr ""
44
45#, boost-format
46msgid "%1% on, %2% off"
47msgstr ""
48
49#, c-format, boost-format
50msgid "heuristic %s on, %s off"
51msgstr ""
52
53#, c-format, boost-format
54msgid "heuristic %1$d on, %2$d off"
55msgstr ""
56
57#, boost-format
58msgid "heuristic %|1$| on, %|2$| off"
59msgstr ""
60
61#, boost-format
62msgid "heuristic %1% on, %2% off"
63msgstr ""
64EOF
65
66: ${DIFF=diff}
67${DIFF} xg-c-14.ok xg-c-14.po
68result=$?
69
70rm -fr $tmpfiles
71
72exit $result
73