summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/xgettext-c-20
blob: 283f8d0346567b1ace959fb751f25309130d7350 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test C support: C++11 string literals.

: ${XGETTEXT=xgettext}

cat <<\EOF > err0.cc
gettext ("aaa(
bbb
)ccc");
EOF

(LANGUAGE= LC_ALL=C ${XGETTEXT} --no-location --no-wrap -o - err0.cc 2>&1; exit) | grep 'unterminated string literal' || exit 1

cat <<\EOF > err1.cc
gettext (R"aaa(
bbb
)ccc");
EOF

(LANGUAGE= LC_ALL=C ${XGETTEXT} --no-location --no-wrap -o - err1.cc 2>&1; exit) | grep 'unterminated string literal' || exit 1

cat <<\EOF > xg-c-20.cc
#define X ""
gettext (X"This is a concatenation of a macro and a string");

#define RR ""
gettext (RR"This (is NOT a raw string");

#define u8RR ""
gettext (u8RR"This (is NOT a raw string");

#define uRR ""
gettext (uRR"This (is NOT a raw string");

#define URR ""
gettext (URR"This (is NOT a raw string");

#define LRR ""
gettext (LRR"This (is NOT a raw string");

#define uX ""
gettext (uX"This (is NOT a raw string");

gettext (u8"This is a UTF-8 string");

u88"This is not a UTF-8 string";

u"This is a UTF-16 string";

U"This is a UTF-32 string";

L"This is a wide string";

gettext (R"aaa(
This is a raw string
)aaa");

gettext (u8R"aaa(
This is a raw UTF-8 string
)aaa");

uR"aaa(
This is a UTF-16 raw string
)aaa";

LR"aaa(
This is a wide raw string
)aaa";

// 'LR' prefixed raw string should be skipped.
LR"(

baz

gettext(\"abc\");
)";
EOF

${XGETTEXT} --add-comments --no-location --no-wrap \
	    -o - xg-c-20.cc | grep -v 'POT-Creation-Date' > xg-c-20.tmp.po \
	    || exit 1
LC_ALL=C tr -d '\r' < xg-c-20.tmp.po > xg-c-20.po || exit 1

cat <<\EOF > xg-c-20.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "This is a concatenation of a macro and a string"
msgstr ""

msgid "This (is NOT a raw string"
msgstr ""

msgid "This is a UTF-8 string"
msgstr ""

msgid ""
"\n"
"This is a raw string\n"
msgstr ""

msgid ""
"\n"
"This is a raw UTF-8 string\n"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-c-20.ok xg-c-20.po || exit 1

cat <<\EOF > xg-c-20.c
gettext (R"aaa(This is NOT a raw string");

gettext (u8R"aaa(This is NOT a raw string");

uR"aaa(This is NOT a raw string";
EOF

${XGETTEXT} --add-comments --no-location --no-wrap \
	    -o - xg-c-20.c | grep -v 'POT-Creation-Date' > xg-c-20c.tmp.po \
	    || exit 1
LC_ALL=C tr -d '\r' < xg-c-20c.tmp.po > xg-c-20c.po || exit 1

cat <<\EOF > xg-c-20c.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "aaa(This is NOT a raw string"
msgstr ""
EOF

${DIFF} xg-c-20c.ok xg-c-20c.po || exit 1