/src/gettext/gettext-tools/libgettextpo/gettext.h
Line | Count | Source |
1 | | /* Convenience header for conditional use of GNU <libintl.h>. |
2 | | Copyright (C) 1995-2025 Free Software Foundation, Inc. |
3 | | |
4 | | This program is free software: you can redistribute it and/or modify |
5 | | it under the terms of the GNU Lesser General Public License as published by |
6 | | the Free Software Foundation; either version 2.1 of the License, or |
7 | | (at your option) any later version. |
8 | | |
9 | | This program is distributed in the hope that it will be useful, |
10 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | GNU Lesser General Public License for more details. |
13 | | |
14 | | You should have received a copy of the GNU Lesser General Public License |
15 | | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
16 | | |
17 | | #ifndef _LIBGETTEXT_H |
18 | | #define _LIBGETTEXT_H 1 |
19 | | |
20 | | |
21 | | /* NLS can be disabled through the configure --disable-nls option |
22 | | or through "#define ENABLE NLS 0" before including this file. */ |
23 | | #if defined ENABLE_NLS && ENABLE_NLS |
24 | | |
25 | | /* Get declarations of GNU message catalog functions. */ |
26 | | # include <libintl.h> |
27 | | |
28 | | /* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by |
29 | | the gettext() and ngettext() macros. This is an alternative to calling |
30 | | textdomain(), and is useful for libraries. */ |
31 | | # ifdef DEFAULT_TEXT_DOMAIN |
32 | | # undef gettext |
33 | | # define gettext(Msgid) \ |
34 | | dgettext (DEFAULT_TEXT_DOMAIN, Msgid) |
35 | | # undef ngettext |
36 | | # define ngettext(Msgid1, Msgid2, N) \ |
37 | | dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N) |
38 | | # endif |
39 | | |
40 | | #else |
41 | | |
42 | | /* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which |
43 | | chokes if dcgettext is defined as a macro. So include it now, to make |
44 | | later inclusions of <locale.h> a NOP. We don't include <libintl.h> |
45 | | as well because people using "gettext.h" will not include <libintl.h>, |
46 | | and also including <libintl.h> would fail on SunOS 4, whereas <locale.h> |
47 | | is OK. */ |
48 | | # if defined(__sun) |
49 | | # include <locale.h> |
50 | | # endif |
51 | | |
52 | | /* Many header files from the libstdc++ coming with g++ 3.3 or newer include |
53 | | <libintl.h>, which chokes if dcgettext is defined as a macro. So include |
54 | | it now, to make later inclusions of <libintl.h> a NOP. */ |
55 | | # if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) |
56 | | # include <cstdlib> |
57 | | # if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H |
58 | | # include <libintl.h> |
59 | | # endif |
60 | | # endif |
61 | | |
62 | | /* Disabled NLS. */ |
63 | | /* When gcc is used with option -Wformat=2, we need to silence |
64 | | "warning: format not a string literal, argument types not checked [-Wformat-nonliteral]" |
65 | | warnings that would occur at every invocation of a *gettext function |
66 | | in a *printf format string position. |
67 | | Do this with inline functions when possible, namely for gettext, dgettext, |
68 | | dcgettext, which are known to gcc as "external built-ins". |
69 | | It is not ideal to ignore the possible side effects done in the |
70 | | Domainname and Category arguments, but it's better than to have a |
71 | | warning at every invocation in a format string position. */ |
72 | | /* When clang is used with option -Wformat=2, we need to silence |
73 | | "warning: format string is not a string literal [-Wformat-nonliteral]" |
74 | | warnings that would occur at every invocation of a *gettext function |
75 | | in a *printf format string position. |
76 | | It is not ideal to ignore the possible side effects done in the |
77 | | Domainname and Category arguments, but it's better than to have a |
78 | | warning at every invocation in a format string position. */ |
79 | | /* These warnings would not occur with enabled NLS. */ |
80 | | /* A test case: |
81 | | ================================ foo.c ================================ |
82 | | #include <stdio.h> |
83 | | #include "gettext.h" |
84 | | void foo (int n) |
85 | | { |
86 | | printf (gettext ("foo %d"), n); |
87 | | printf (dgettext ("toto", "foo %d"), n); |
88 | | printf (dcgettext ("toto", "foo %d", LC_MESSAGES), n); |
89 | | printf (ngettext ("foo %d", "bar %d", n), n); |
90 | | printf (dngettext ("toto", "foo %d", "bar %d", n), n); |
91 | | printf (dcngettext ("toto", "foo %d", "bar %d", n, LC_MESSAGES), n); |
92 | | } |
93 | | ======================================================================= |
94 | | $CC -Wformat=2 -S foo.c |
95 | | */ |
96 | | # if defined __GNUC__ && !defined __clang__ && !defined __cplusplus |
97 | | /* The return type 'const char *' serves the purpose of producing warnings |
98 | | for invalid uses of the value returned from these functions. */ |
99 | | # if __GNUC__ >= 9 |
100 | | # pragma GCC diagnostic push |
101 | | # pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch" |
102 | | # endif |
103 | | # if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4 |
104 | | __attribute__ ((__always_inline__, __gnu_inline__)) |
105 | | # else |
106 | | __attribute__ ((__always_inline__)) |
107 | | # endif |
108 | | extern inline |
109 | | # if !defined(__sun) |
110 | | const |
111 | | # endif |
112 | | char * |
113 | | gettext (const char *msgid) |
114 | | { |
115 | | return |
116 | | # ifdef __sun |
117 | | (char *) |
118 | | # endif |
119 | | msgid; |
120 | | } |
121 | | # if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4 |
122 | | __attribute__ ((__always_inline__, __gnu_inline__)) |
123 | | # else |
124 | | __attribute__ ((__always_inline__)) |
125 | | # endif |
126 | | extern inline |
127 | | # if !defined(__sun) |
128 | | const |
129 | | # endif |
130 | | char * |
131 | | dgettext (const char *domain, const char *msgid) |
132 | | { |
133 | | (void) domain; |
134 | | return |
135 | | # ifdef __sun |
136 | | (char *) |
137 | | # endif |
138 | | msgid; |
139 | | } |
140 | | # if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4 |
141 | | __attribute__ ((__always_inline__, __gnu_inline__)) |
142 | | # else |
143 | | __attribute__ ((__always_inline__)) |
144 | | # endif |
145 | | extern inline |
146 | | # if !defined(__sun) |
147 | | const |
148 | | # endif |
149 | | char * |
150 | | dcgettext (const char *domain, const char *msgid, int category) |
151 | | { |
152 | | (void) domain; |
153 | | (void) category; |
154 | | return |
155 | | # ifdef __sun |
156 | | (char *) |
157 | | # endif |
158 | | msgid; |
159 | | } |
160 | | # if __GNUC__ >= 9 |
161 | | # pragma GCC diagnostic pop |
162 | | # endif |
163 | | # elif defined __clang__ |
164 | | # undef gettext |
165 | 8.36M | # define gettext(Msgid) ((const char *) (Msgid)) |
166 | | # undef dgettext |
167 | 0 | # define dgettext(Domainname, Msgid) gettext (Msgid) |
168 | | # undef dcgettext |
169 | | # define dcgettext(Domainname, Msgid, Category) dgettext (Domainname, Msgid) |
170 | | # else |
171 | | /* The conversions to 'const char *' via compound literals serve the purpose |
172 | | of producing warnings for invalid uses of the value returned from these |
173 | | functions and for invalid-typed Msgid arguments. */ |
174 | | # undef gettext |
175 | | # define gettext(Msgid) ((const char *) {(Msgid)}) |
176 | | /* The conversions via compound literals serve the purpose of producing warnings |
177 | | for invalid-typed arguments. */ |
178 | | # undef dgettext |
179 | | # define dgettext(Domainname, Msgid) \ |
180 | | ((void) (const char *) {(Domainname)}, gettext (Msgid)) |
181 | | # undef dcgettext |
182 | | # define dcgettext(Domainname, Msgid, Category) \ |
183 | | ((void) (int) {(Category)}, dgettext (Domainname, Msgid)) |
184 | | # endif |
185 | | |
186 | | # if (defined __GNUC__ && defined __cplusplus) || defined __clang__ |
187 | | # undef ngettext |
188 | | # define ngettext(Msgid1, Msgid2, N) \ |
189 | 0 | ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) |
190 | | # undef dngettext |
191 | | # define dngettext(Domainname, Msgid1, Msgid2, N) \ |
192 | | ngettext (Msgid1, Msgid2, N) |
193 | | # undef dcngettext |
194 | | # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ |
195 | | dngettext (Domainname, Msgid1, Msgid2, N) |
196 | | # elif defined __GNUC__ && !defined __cplusplus |
197 | | /* Silence -Wuseless-cast warnings. */ |
198 | | # if __GNUC__ >= 14 |
199 | | # pragma GCC diagnostic ignored "-Wuseless-cast" |
200 | | # endif |
201 | | # undef ngettext |
202 | | # define ngettext(Msgid1, Msgid2, N) \ |
203 | | ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) |
204 | | # undef dngettext |
205 | | # define dngettext(Domainname, Msgid1, Msgid2, N) \ |
206 | | ((void) (const char *) (Domainname), ngettext (Msgid1, Msgid2, N)) |
207 | | # undef dcngettext |
208 | | # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ |
209 | | ((void) (int) (Category), dngettext (Domainname, Msgid1, Msgid2, N)) |
210 | | # else |
211 | | /* The conversions to 'const char *' via compound literals serve the purpose |
212 | | of producing warnings for invalid uses of the value returned from these |
213 | | functions and for invalid-typed Msgid1 and Msgid2 arguments. */ |
214 | | # undef ngettext |
215 | | # define ngettext(Msgid1, Msgid2, N) \ |
216 | | ((N) == 1 \ |
217 | | ? ((void) (Msgid2), (const char *) {(Msgid1)}) \ |
218 | | : ((void) (Msgid1), (const char *) {(Msgid2)})) |
219 | | /* The conversions via compound literals serve the purpose of producing warnings |
220 | | for invalid-typed arguments. */ |
221 | | # undef dngettext |
222 | | # define dngettext(Domainname, Msgid1, Msgid2, N) \ |
223 | | ((void) (const char *) {(Domainname)}, ngettext (Msgid1, Msgid2, N)) |
224 | | # undef dcngettext |
225 | | # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ |
226 | | ((void) (int) {(Category)}, dngettext (Domainname, Msgid1, Msgid2, N)) |
227 | | # endif |
228 | | |
229 | | # undef textdomain |
230 | | # define textdomain(Domainname) ((const char *) {(Domainname)}) |
231 | | # undef bindtextdomain |
232 | | # define bindtextdomain(Domainname, Dirname) \ |
233 | | ((void) (const char *) {(Domainname)}, (const char *) {(Dirname)}) |
234 | | # undef bind_textdomain_codeset |
235 | | # define bind_textdomain_codeset(Domainname, Codeset) \ |
236 | | ((void) (const char *) {(Domainname)}, (const char *) {(Codeset)}) |
237 | | |
238 | | #endif |
239 | | |
240 | | |
241 | | /* Prefer gnulib's setlocale override over libintl's setlocale override. */ |
242 | | #ifdef GNULIB_defined_setlocale |
243 | | # undef setlocale |
244 | | # define setlocale rpl_setlocale |
245 | | #endif |
246 | | |
247 | | |
248 | | /* A pseudo function call that serves as a marker for the automated |
249 | | extraction of messages, but does not call gettext(). The run-time |
250 | | translation is done at a different place in the code. |
251 | | The argument, String, should be a literal string. Concatenated strings |
252 | | and other string expressions won't work. |
253 | | The macro's expansion is not parenthesized, so that it is suitable as |
254 | | initializer for static 'char[]' or 'const char[]' variables. */ |
255 | | #define gettext_noop(String) String |
256 | | |
257 | | |
258 | | /* The separator between msgctxt and msgid in a .mo file. */ |
259 | | #define GETTEXT_CONTEXT_GLUE "\004" |
260 | | |
261 | | /* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a |
262 | | MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be |
263 | | short and rarely need to change. |
264 | | The letter 'p' stands for 'particular' or 'special'. */ |
265 | | |
266 | | #include <locale.h> /* for LC_MESSAGES */ |
267 | | /* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C. |
268 | | On systems that don't define it, use the same value as GNU libintl. */ |
269 | | #if !defined LC_MESSAGES |
270 | | # define LC_MESSAGES 1729 |
271 | | #endif |
272 | | |
273 | | #ifdef DEFAULT_TEXT_DOMAIN |
274 | | # define pgettext(Msgctxt, Msgid) \ |
275 | | pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) |
276 | | #else |
277 | | # define pgettext(Msgctxt, Msgid) \ |
278 | | pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) |
279 | | #endif |
280 | | #define dpgettext(Domainname, Msgctxt, Msgid) \ |
281 | | pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) |
282 | | #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ |
283 | | pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) |
284 | | #ifdef DEFAULT_TEXT_DOMAIN |
285 | | # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ |
286 | | npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) |
287 | | #else |
288 | | # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ |
289 | | npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) |
290 | | #endif |
291 | | #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ |
292 | | npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) |
293 | | #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ |
294 | | npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) |
295 | | |
296 | | #if defined __GNUC__ || defined __clang__ |
297 | | __inline |
298 | | #elif defined __cplusplus |
299 | | inline |
300 | | #endif |
301 | | static const char * |
302 | | pgettext_aux (const char *domain, |
303 | | const char *msg_ctxt_id, const char *msgid, |
304 | | int category) |
305 | 0 | { |
306 | 0 | const char *translation = dcgettext (domain, msg_ctxt_id, category); |
307 | 0 | if (translation == msg_ctxt_id) |
308 | 0 | return msgid; |
309 | 0 | else |
310 | 0 | return translation; |
311 | 0 | } Unexecuted instantiation: gettext-po.c:pgettext_aux Unexecuted instantiation: write-catalog.c:pgettext_aux Unexecuted instantiation: write-po.c:pgettext_aux Unexecuted instantiation: po-charset.c:pgettext_aux Unexecuted instantiation: read-catalog.c:pgettext_aux Unexecuted instantiation: read-po-lex.c:pgettext_aux Unexecuted instantiation: read-po-gram.c:pgettext_aux Unexecuted instantiation: format.c:pgettext_aux Unexecuted instantiation: msgl-check.c:pgettext_aux Unexecuted instantiation: obstack.c:pgettext_aux Unexecuted instantiation: xalloc-die.c:pgettext_aux Unexecuted instantiation: xstrerror.c:pgettext_aux Unexecuted instantiation: read-catalog-abstract.c:pgettext_aux Unexecuted instantiation: format-c.c:pgettext_aux Unexecuted instantiation: format-c++-brace.c:pgettext_aux Unexecuted instantiation: format-python.c:pgettext_aux Unexecuted instantiation: format-python-brace.c:pgettext_aux Unexecuted instantiation: format-java.c:pgettext_aux Unexecuted instantiation: format-java-printf.c:pgettext_aux Unexecuted instantiation: format-csharp.c:pgettext_aux Unexecuted instantiation: format-javascript.c:pgettext_aux Unexecuted instantiation: format-scheme.c:pgettext_aux Unexecuted instantiation: format-lisp.c:pgettext_aux Unexecuted instantiation: format-elisp.c:pgettext_aux Unexecuted instantiation: format-librep.c:pgettext_aux Unexecuted instantiation: format-rust.c:pgettext_aux Unexecuted instantiation: format-go.c:pgettext_aux Unexecuted instantiation: format-ruby.c:pgettext_aux Unexecuted instantiation: format-sh.c:pgettext_aux Unexecuted instantiation: format-sh-printf.c:pgettext_aux Unexecuted instantiation: format-awk.c:pgettext_aux Unexecuted instantiation: format-lua.c:pgettext_aux Unexecuted instantiation: format-pascal.c:pgettext_aux Unexecuted instantiation: format-modula2.c:pgettext_aux Unexecuted instantiation: format-d.c:pgettext_aux Unexecuted instantiation: format-ocaml.c:pgettext_aux Unexecuted instantiation: format-smalltalk.c:pgettext_aux Unexecuted instantiation: format-qt.c:pgettext_aux Unexecuted instantiation: format-qt-plural.c:pgettext_aux Unexecuted instantiation: format-kde.c:pgettext_aux Unexecuted instantiation: format-kde-kuit.c:pgettext_aux Unexecuted instantiation: format-boost.c:pgettext_aux Unexecuted instantiation: format-tcl.c:pgettext_aux Unexecuted instantiation: format-perl.c:pgettext_aux Unexecuted instantiation: format-perl-brace.c:pgettext_aux Unexecuted instantiation: format-php.c:pgettext_aux Unexecuted instantiation: format-gcc-internal.c:pgettext_aux Unexecuted instantiation: format-gfc-internal.c:pgettext_aux Unexecuted instantiation: markup.c:pgettext_aux |
312 | | |
313 | | #if defined __GNUC__ || defined __clang__ |
314 | | __inline |
315 | | #elif defined __cplusplus |
316 | | inline |
317 | | #endif |
318 | | static const char * |
319 | | npgettext_aux (const char *domain, |
320 | | const char *msg_ctxt_id, const char *msgid, |
321 | | const char *msgid_plural, unsigned long int n, |
322 | | int category) |
323 | 0 | { |
324 | 0 | const char *translation = |
325 | 0 | dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); |
326 | 0 | if (translation == msg_ctxt_id || translation == msgid_plural) |
327 | 0 | return (n == 1 ? msgid : msgid_plural); |
328 | 0 | else |
329 | 0 | return translation; |
330 | 0 | } Unexecuted instantiation: gettext-po.c:npgettext_aux Unexecuted instantiation: write-catalog.c:npgettext_aux Unexecuted instantiation: write-po.c:npgettext_aux Unexecuted instantiation: po-charset.c:npgettext_aux Unexecuted instantiation: read-catalog.c:npgettext_aux Unexecuted instantiation: read-po-lex.c:npgettext_aux Unexecuted instantiation: read-po-gram.c:npgettext_aux Unexecuted instantiation: format.c:npgettext_aux Unexecuted instantiation: msgl-check.c:npgettext_aux Unexecuted instantiation: obstack.c:npgettext_aux Unexecuted instantiation: xalloc-die.c:npgettext_aux Unexecuted instantiation: xstrerror.c:npgettext_aux Unexecuted instantiation: read-catalog-abstract.c:npgettext_aux Unexecuted instantiation: format-c.c:npgettext_aux Unexecuted instantiation: format-c++-brace.c:npgettext_aux Unexecuted instantiation: format-python.c:npgettext_aux Unexecuted instantiation: format-python-brace.c:npgettext_aux Unexecuted instantiation: format-java.c:npgettext_aux Unexecuted instantiation: format-java-printf.c:npgettext_aux Unexecuted instantiation: format-csharp.c:npgettext_aux Unexecuted instantiation: format-javascript.c:npgettext_aux Unexecuted instantiation: format-scheme.c:npgettext_aux Unexecuted instantiation: format-lisp.c:npgettext_aux Unexecuted instantiation: format-elisp.c:npgettext_aux Unexecuted instantiation: format-librep.c:npgettext_aux Unexecuted instantiation: format-rust.c:npgettext_aux Unexecuted instantiation: format-go.c:npgettext_aux Unexecuted instantiation: format-ruby.c:npgettext_aux Unexecuted instantiation: format-sh.c:npgettext_aux Unexecuted instantiation: format-sh-printf.c:npgettext_aux Unexecuted instantiation: format-awk.c:npgettext_aux Unexecuted instantiation: format-lua.c:npgettext_aux Unexecuted instantiation: format-pascal.c:npgettext_aux Unexecuted instantiation: format-modula2.c:npgettext_aux Unexecuted instantiation: format-d.c:npgettext_aux Unexecuted instantiation: format-ocaml.c:npgettext_aux Unexecuted instantiation: format-smalltalk.c:npgettext_aux Unexecuted instantiation: format-qt.c:npgettext_aux Unexecuted instantiation: format-qt-plural.c:npgettext_aux Unexecuted instantiation: format-kde.c:npgettext_aux Unexecuted instantiation: format-kde-kuit.c:npgettext_aux Unexecuted instantiation: format-boost.c:npgettext_aux Unexecuted instantiation: format-tcl.c:npgettext_aux Unexecuted instantiation: format-perl.c:npgettext_aux Unexecuted instantiation: format-perl-brace.c:npgettext_aux Unexecuted instantiation: format-php.c:npgettext_aux Unexecuted instantiation: format-gcc-internal.c:npgettext_aux Unexecuted instantiation: format-gfc-internal.c:npgettext_aux Unexecuted instantiation: markup.c:npgettext_aux |
331 | | |
332 | | |
333 | | /* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID |
334 | | can be arbitrary expressions. But for string literals these macros are |
335 | | less efficient than those above. */ |
336 | | |
337 | | #include <string.h> /* for memcpy */ |
338 | | |
339 | | /* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported. |
340 | | This relates to the -Wvla and -Wvla-larger-than warnings, enabled in |
341 | | the default GCC many warnings set. This allows programs to disable use |
342 | | of VLAs, which may be unintended, or may be awkward to support portably, |
343 | | or may have security implications due to non-deterministic stack usage. */ |
344 | | |
345 | | #if (!defined GNULIB_NO_VLA \ |
346 | | && (((__GNUC__ >= 3 || defined __clang__) \ |
347 | | && !defined __STRICT_ANSI__ && !defined __cplusplus) \ |
348 | | /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc) |
349 | | || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )) |
350 | | # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 |
351 | | #else |
352 | | # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 |
353 | | #endif |
354 | | |
355 | | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS |
356 | | # include <stdlib.h> /* for malloc, free */ |
357 | | #endif |
358 | | |
359 | | #define pgettext_expr(Msgctxt, Msgid) \ |
360 | | dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) |
361 | | #define dpgettext_expr(Domainname, Msgctxt, Msgid) \ |
362 | | dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) |
363 | | |
364 | | #if defined __GNUC__ || defined __clang__ |
365 | | __inline |
366 | | #elif defined __cplusplus |
367 | | inline |
368 | | #endif |
369 | | static const char * |
370 | | dcpgettext_expr (const char *domain, |
371 | | const char *msgctxt, const char *msgid, |
372 | | int category) |
373 | 0 | { |
374 | 0 | size_t msgctxt_len = strlen (msgctxt) + 1; |
375 | 0 | size_t msgid_len = strlen (msgid) + 1; |
376 | 0 | const char *translation; |
377 | 0 | #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS |
378 | 0 | char msg_ctxt_id[msgctxt_len + msgid_len]; |
379 | 0 | #else |
380 | 0 | char buf[1024]; |
381 | 0 | char *msg_ctxt_id = |
382 | 0 | (msgctxt_len + msgid_len <= sizeof (buf) |
383 | 0 | ? buf |
384 | 0 | : (char *) malloc (msgctxt_len + msgid_len)); |
385 | 0 | if (msg_ctxt_id != NULL) |
386 | 0 | #endif |
387 | 0 | { |
388 | 0 | memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); |
389 | 0 | msg_ctxt_id[msgctxt_len - 1] = '\004'; |
390 | 0 | memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); |
391 | 0 | translation = dcgettext (domain, msg_ctxt_id, category); |
392 | 0 | int found_translation = (translation != msg_ctxt_id); |
393 | 0 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS |
394 | 0 | if (msg_ctxt_id != buf) |
395 | 0 | free (msg_ctxt_id); |
396 | 0 | #endif |
397 | 0 | if (found_translation) |
398 | 0 | return translation; |
399 | 0 | } |
400 | 0 | return msgid; |
401 | 0 | } Unexecuted instantiation: gettext-po.c:dcpgettext_expr Unexecuted instantiation: write-catalog.c:dcpgettext_expr Unexecuted instantiation: write-po.c:dcpgettext_expr Unexecuted instantiation: po-charset.c:dcpgettext_expr Unexecuted instantiation: read-catalog.c:dcpgettext_expr Unexecuted instantiation: read-po-lex.c:dcpgettext_expr Unexecuted instantiation: read-po-gram.c:dcpgettext_expr Unexecuted instantiation: format.c:dcpgettext_expr Unexecuted instantiation: msgl-check.c:dcpgettext_expr Unexecuted instantiation: obstack.c:dcpgettext_expr Unexecuted instantiation: xalloc-die.c:dcpgettext_expr Unexecuted instantiation: xstrerror.c:dcpgettext_expr Unexecuted instantiation: read-catalog-abstract.c:dcpgettext_expr Unexecuted instantiation: format-c.c:dcpgettext_expr Unexecuted instantiation: format-c++-brace.c:dcpgettext_expr Unexecuted instantiation: format-python.c:dcpgettext_expr Unexecuted instantiation: format-python-brace.c:dcpgettext_expr Unexecuted instantiation: format-java.c:dcpgettext_expr Unexecuted instantiation: format-java-printf.c:dcpgettext_expr Unexecuted instantiation: format-csharp.c:dcpgettext_expr Unexecuted instantiation: format-javascript.c:dcpgettext_expr Unexecuted instantiation: format-scheme.c:dcpgettext_expr Unexecuted instantiation: format-lisp.c:dcpgettext_expr Unexecuted instantiation: format-elisp.c:dcpgettext_expr Unexecuted instantiation: format-librep.c:dcpgettext_expr Unexecuted instantiation: format-rust.c:dcpgettext_expr Unexecuted instantiation: format-go.c:dcpgettext_expr Unexecuted instantiation: format-ruby.c:dcpgettext_expr Unexecuted instantiation: format-sh.c:dcpgettext_expr Unexecuted instantiation: format-sh-printf.c:dcpgettext_expr Unexecuted instantiation: format-awk.c:dcpgettext_expr Unexecuted instantiation: format-lua.c:dcpgettext_expr Unexecuted instantiation: format-pascal.c:dcpgettext_expr Unexecuted instantiation: format-modula2.c:dcpgettext_expr Unexecuted instantiation: format-d.c:dcpgettext_expr Unexecuted instantiation: format-ocaml.c:dcpgettext_expr Unexecuted instantiation: format-smalltalk.c:dcpgettext_expr Unexecuted instantiation: format-qt.c:dcpgettext_expr Unexecuted instantiation: format-qt-plural.c:dcpgettext_expr Unexecuted instantiation: format-kde.c:dcpgettext_expr Unexecuted instantiation: format-kde-kuit.c:dcpgettext_expr Unexecuted instantiation: format-boost.c:dcpgettext_expr Unexecuted instantiation: format-tcl.c:dcpgettext_expr Unexecuted instantiation: format-perl.c:dcpgettext_expr Unexecuted instantiation: format-perl-brace.c:dcpgettext_expr Unexecuted instantiation: format-php.c:dcpgettext_expr Unexecuted instantiation: format-gcc-internal.c:dcpgettext_expr Unexecuted instantiation: format-gfc-internal.c:dcpgettext_expr Unexecuted instantiation: markup.c:dcpgettext_expr |
402 | | |
403 | | #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ |
404 | | dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) |
405 | | #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ |
406 | | dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) |
407 | | |
408 | | #if defined __GNUC__ || defined __clang__ |
409 | | __inline |
410 | | #elif defined __cplusplus |
411 | | inline |
412 | | #endif |
413 | | static const char * |
414 | | dcnpgettext_expr (const char *domain, |
415 | | const char *msgctxt, const char *msgid, |
416 | | const char *msgid_plural, unsigned long int n, |
417 | | int category) |
418 | 0 | { |
419 | 0 | size_t msgctxt_len = strlen (msgctxt) + 1; |
420 | 0 | size_t msgid_len = strlen (msgid) + 1; |
421 | 0 | const char *translation; |
422 | 0 | #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS |
423 | 0 | char msg_ctxt_id[msgctxt_len + msgid_len]; |
424 | 0 | #else |
425 | 0 | char buf[1024]; |
426 | 0 | char *msg_ctxt_id = |
427 | 0 | (msgctxt_len + msgid_len <= sizeof (buf) |
428 | 0 | ? buf |
429 | 0 | : (char *) malloc (msgctxt_len + msgid_len)); |
430 | 0 | if (msg_ctxt_id != NULL) |
431 | 0 | #endif |
432 | 0 | { |
433 | 0 | memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); |
434 | 0 | msg_ctxt_id[msgctxt_len - 1] = '\004'; |
435 | 0 | memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); |
436 | 0 | translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); |
437 | 0 | int found_translation = !(translation == msg_ctxt_id || translation == msgid_plural); |
438 | 0 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS |
439 | 0 | if (msg_ctxt_id != buf) |
440 | 0 | free (msg_ctxt_id); |
441 | 0 | #endif |
442 | 0 | if (found_translation) |
443 | 0 | return translation; |
444 | 0 | } |
445 | 0 | return (n == 1 ? msgid : msgid_plural); |
446 | 0 | } Unexecuted instantiation: gettext-po.c:dcnpgettext_expr Unexecuted instantiation: write-catalog.c:dcnpgettext_expr Unexecuted instantiation: write-po.c:dcnpgettext_expr Unexecuted instantiation: po-charset.c:dcnpgettext_expr Unexecuted instantiation: read-catalog.c:dcnpgettext_expr Unexecuted instantiation: read-po-lex.c:dcnpgettext_expr Unexecuted instantiation: read-po-gram.c:dcnpgettext_expr Unexecuted instantiation: format.c:dcnpgettext_expr Unexecuted instantiation: msgl-check.c:dcnpgettext_expr Unexecuted instantiation: obstack.c:dcnpgettext_expr Unexecuted instantiation: xalloc-die.c:dcnpgettext_expr Unexecuted instantiation: xstrerror.c:dcnpgettext_expr Unexecuted instantiation: read-catalog-abstract.c:dcnpgettext_expr Unexecuted instantiation: format-c.c:dcnpgettext_expr Unexecuted instantiation: format-c++-brace.c:dcnpgettext_expr Unexecuted instantiation: format-python.c:dcnpgettext_expr Unexecuted instantiation: format-python-brace.c:dcnpgettext_expr Unexecuted instantiation: format-java.c:dcnpgettext_expr Unexecuted instantiation: format-java-printf.c:dcnpgettext_expr Unexecuted instantiation: format-csharp.c:dcnpgettext_expr Unexecuted instantiation: format-javascript.c:dcnpgettext_expr Unexecuted instantiation: format-scheme.c:dcnpgettext_expr Unexecuted instantiation: format-lisp.c:dcnpgettext_expr Unexecuted instantiation: format-elisp.c:dcnpgettext_expr Unexecuted instantiation: format-librep.c:dcnpgettext_expr Unexecuted instantiation: format-rust.c:dcnpgettext_expr Unexecuted instantiation: format-go.c:dcnpgettext_expr Unexecuted instantiation: format-ruby.c:dcnpgettext_expr Unexecuted instantiation: format-sh.c:dcnpgettext_expr Unexecuted instantiation: format-sh-printf.c:dcnpgettext_expr Unexecuted instantiation: format-awk.c:dcnpgettext_expr Unexecuted instantiation: format-lua.c:dcnpgettext_expr Unexecuted instantiation: format-pascal.c:dcnpgettext_expr Unexecuted instantiation: format-modula2.c:dcnpgettext_expr Unexecuted instantiation: format-d.c:dcnpgettext_expr Unexecuted instantiation: format-ocaml.c:dcnpgettext_expr Unexecuted instantiation: format-smalltalk.c:dcnpgettext_expr Unexecuted instantiation: format-qt.c:dcnpgettext_expr Unexecuted instantiation: format-qt-plural.c:dcnpgettext_expr Unexecuted instantiation: format-kde.c:dcnpgettext_expr Unexecuted instantiation: format-kde-kuit.c:dcnpgettext_expr Unexecuted instantiation: format-boost.c:dcnpgettext_expr Unexecuted instantiation: format-tcl.c:dcnpgettext_expr Unexecuted instantiation: format-perl.c:dcnpgettext_expr Unexecuted instantiation: format-perl-brace.c:dcnpgettext_expr Unexecuted instantiation: format-php.c:dcnpgettext_expr Unexecuted instantiation: format-gcc-internal.c:dcnpgettext_expr Unexecuted instantiation: format-gfc-internal.c:dcnpgettext_expr Unexecuted instantiation: markup.c:dcnpgettext_expr |
447 | | |
448 | | |
449 | | #endif /* _LIBGETTEXT_H */ |