/src/gettext/gettext-tools/libgettextpo/gettext.h
Line | Count | Source |
1 | | /* Convenience header for conditional use of GNU <libintl.h>. |
2 | | Copyright (C) 1995-2026 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 | | # if defined(__sun) |
47 | | # include <locale.h> |
48 | | # endif |
49 | | |
50 | | /* Many header files from the libstdc++ coming with g++ 3.3 or newer include |
51 | | <libintl.h>, which chokes if dcgettext is defined as a macro. So include |
52 | | it now, to make later inclusions of <libintl.h> a NOP. */ |
53 | | # if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) |
54 | | # include <cstdlib> |
55 | | # if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H |
56 | | # include <libintl.h> |
57 | | # endif |
58 | | # endif |
59 | | |
60 | | /* Like the C cast ((type) (expr)), but do only conversions that an |
61 | | ordinary assignment would do. This can diagnose invalid arguments |
62 | | better than a cast would. */ |
63 | | # ifdef __cplusplus |
64 | | # define _LIBGETTEXT_FUNCAST(type, expr) static_cast <type> (expr) |
65 | | # else |
66 | | # define _LIBGETTEXT_FUNCAST(type, expr) (type) {(expr)} |
67 | | # endif |
68 | | |
69 | | /* Disabled NLS. */ |
70 | | /* When gcc or clang is used with option -Wformat=2, we need to silence |
71 | | gcc: "warning: format not a string literal, argument types not checked [-Wformat-nonliteral]" |
72 | | clang: "warning: format string is not a string literal [-Wformat-nonliteral]", |
73 | | "warning: format string is not a string literal (potentially insecure) [-Wformat-security]" |
74 | | warnings that would occur at every invocation of a *gettext function |
75 | | in a *printf format string position. |
76 | | Do this with inline functions when possible. */ |
77 | | /* These warnings would not occur with enabled NLS. */ |
78 | | /* A test case: |
79 | | ================================ foo.c ================================ |
80 | | #include <stdio.h> |
81 | | #include "gettext.h" |
82 | | extern const char *some_computed_string (void); |
83 | | |
84 | | void foo (int n) |
85 | | { |
86 | | textdomain ("pkg"); |
87 | | bindtextdomain ("pkg", "/usr/share/locale"); |
88 | | bind_textdomain_codeset ("pkg", "UTF-8"); |
89 | | |
90 | | printf (gettext ("foo %d"), n); |
91 | | printf (dgettext ("toto", "foo %d"), n); |
92 | | printf (dcgettext ("toto", "foo %d", LC_MESSAGES), n); |
93 | | printf (ngettext ("foo %d", "bar %d", n), n); |
94 | | printf (dngettext ("toto", "foo %d", "bar %d", n), n); |
95 | | printf (dcngettext ("toto", "foo %d", "bar %d", n, LC_MESSAGES), n); |
96 | | |
97 | | printf ("%s", gettext ("between 7% & 19%.")); |
98 | | printf ("%s", dgettext ("toto", "between 7% & 19%.")); |
99 | | printf ("%s", dcgettext ("toto", "between 7% & 19%.", LC_MESSAGES)); |
100 | | |
101 | | printf (gettext (some_computed_string ())); |
102 | | printf (dgettext ("toto", some_computed_string ())); |
103 | | printf (dcgettext ("toto", some_computed_string (), LC_MESSAGES)); |
104 | | } |
105 | | ======================================================================= |
106 | | $CC -Wall -Wformat=2 -S foo.c |
107 | | $CC -Wall -Wformat=2 -S -x c++ foo.c |
108 | | */ |
109 | | # if (defined __GNUC__ || defined __clang__) && !defined __cplusplus |
110 | | # if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4 || defined __clang__ |
111 | | # define _LIBGETTEXT_INLINE __always_inline__, __gnu_inline__ |
112 | | # else |
113 | | # define _LIBGETTEXT_INLINE __always_inline__ |
114 | | # endif |
115 | | /* The return type 'const char *' serves the purpose of producing warnings |
116 | | for invalid uses of the value returned from these functions. */ |
117 | | # if defined __GNUC__ && __GNUC__ >= 9 && !defined __clang__ |
118 | | # pragma GCC diagnostic push |
119 | | # pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch" |
120 | | # endif |
121 | | __attribute__ ((_LIBGETTEXT_INLINE, __format_arg__ (1))) |
122 | | extern inline |
123 | | # if !defined(__sun) |
124 | | const |
125 | | # endif |
126 | | char * |
127 | | gettext (const char *msgid) |
128 | 9.50M | { |
129 | 9.50M | return |
130 | | # ifdef __sun |
131 | | (char *) |
132 | | # endif |
133 | 9.50M | msgid; |
134 | 9.50M | } |
135 | | __attribute__ ((_LIBGETTEXT_INLINE, __format_arg__ (2))) |
136 | | extern inline |
137 | | # if !defined(__sun) |
138 | | const |
139 | | # endif |
140 | | char * |
141 | | dgettext (const char *domain, const char *msgid) |
142 | 0 | { |
143 | 0 | (void) domain; |
144 | 0 | return |
145 | | # ifdef __sun |
146 | | (char *) |
147 | | # endif |
148 | 0 | msgid; |
149 | 0 | } |
150 | | __attribute__ ((_LIBGETTEXT_INLINE, __format_arg__ (2))) |
151 | | extern inline |
152 | | # if !defined(__sun) |
153 | | const |
154 | | # endif |
155 | | char * |
156 | | dcgettext (const char *domain, const char *msgid, int category) |
157 | 0 | { |
158 | 0 | (void) domain; |
159 | 0 | (void) category; |
160 | 0 | return |
161 | 0 | # ifdef __sun |
162 | 0 | (char *) |
163 | 0 | # endif |
164 | 0 | msgid; |
165 | 0 | } |
166 | | __attribute__ ((_LIBGETTEXT_INLINE, __format_arg__ (1), __format_arg__ (2))) |
167 | | extern inline |
168 | | # if !defined(__sun) |
169 | | const |
170 | | # endif |
171 | | char * |
172 | | ngettext (const char *msgid1, const char *msgid2, unsigned long n) |
173 | 0 | { |
174 | 0 | return |
175 | | # ifdef __sun |
176 | | (char *) |
177 | | # endif |
178 | 0 | (n == 1 ? msgid1 : msgid2); |
179 | 0 | } |
180 | | __attribute__ ((_LIBGETTEXT_INLINE, __format_arg__ (2), __format_arg__ (3))) |
181 | | extern inline |
182 | | # if !defined(__sun) |
183 | | const |
184 | | # endif |
185 | | char * |
186 | | dngettext (const char *domain, const char *msgid1, const char *msgid2, unsigned long n) |
187 | 0 | { |
188 | 0 | (void) domain; |
189 | 0 | return |
190 | 0 | # ifdef __sun |
191 | 0 | (char *) |
192 | 0 | # endif |
193 | 0 | (n == 1 ? msgid1 : msgid2); |
194 | 0 | } |
195 | | __attribute__ ((_LIBGETTEXT_INLINE, __format_arg__ (2), __format_arg__ (3))) |
196 | | extern inline |
197 | | # if !defined(__sun) |
198 | | const |
199 | | # endif |
200 | | char * |
201 | | dcngettext (const char *domain, const char *msgid1, const char *msgid2, unsigned long n, int category) |
202 | 0 | { |
203 | 0 | (void) domain; |
204 | 0 | (void) category; |
205 | 0 | return |
206 | 0 | # ifdef __sun |
207 | 0 | (char *) |
208 | 0 | # endif |
209 | 0 | (n == 1 ? msgid1 : msgid2); |
210 | 0 | } |
211 | | __attribute__ ((_LIBGETTEXT_INLINE)) |
212 | | extern inline |
213 | | # if !defined(__sun) |
214 | | const |
215 | | # endif |
216 | | char * |
217 | | textdomain (const char *domainname) |
218 | 0 | { |
219 | 0 | return |
220 | 0 | # ifdef __sun |
221 | 0 | (char *) |
222 | 0 | # endif |
223 | 0 | domainname; |
224 | 0 | } |
225 | | # if defined __GNUC__ && __GNUC__ >= 9 && !defined __clang__ |
226 | | # pragma GCC diagnostic pop |
227 | | # endif |
228 | | |
229 | | # elif (defined __GNUC__ || defined __clang__) && defined __cplusplus |
230 | | |
231 | | __attribute__ ((__format_arg__ (1))) |
232 | | static inline const char * |
233 | | _libgettext_gettext (const char *msgid) |
234 | | { |
235 | | return msgid; |
236 | | } |
237 | | # undef gettext |
238 | | # define gettext _libgettext_gettext |
239 | | __attribute__ ((__format_arg__ (2))) |
240 | | static inline const char * |
241 | | _libgettext_dgettext (const char *domain, const char *msgid) |
242 | | { |
243 | | (void) domain; |
244 | | return msgid; |
245 | | } |
246 | | # undef dgettext |
247 | | # define dgettext _libgettext_dgettext |
248 | | __attribute__ ((__format_arg__ (2))) |
249 | | static inline const char * |
250 | | _libgettext_dcgettext (const char *domain, const char *msgid, int category) |
251 | | { |
252 | | (void) domain; |
253 | | (void) category; |
254 | | return msgid; |
255 | | } |
256 | | # undef dcgettext |
257 | | # define dcgettext _libgettext_dcgettext |
258 | | __attribute__ ((__format_arg__ (1), __format_arg__ (2))) |
259 | | static inline const char * |
260 | | _libgettext_ngettext (const char *msgid1, const char *msgid2, unsigned long n) |
261 | | { |
262 | | return (n == 1 ? msgid1 : msgid2); |
263 | | } |
264 | | # undef ngettext |
265 | | # define ngettext _libgettext_ngettext |
266 | | __attribute__ ((__format_arg__ (2), __format_arg__ (3))) |
267 | | static inline const char * |
268 | | _libgettext_dngettext (const char *domain, const char *msgid1, const char *msgid2, unsigned long n) |
269 | | { |
270 | | (void) domain; |
271 | | return (n == 1 ? msgid1 : msgid2); |
272 | | } |
273 | | # undef dngettext |
274 | | # define dngettext _libgettext_dngettext |
275 | | __attribute__ ((__format_arg__ (2), __format_arg__ (3))) |
276 | | static inline const char * |
277 | | _libgettext_dcngettext (const char *domain, const char *msgid1, const char *msgid2, unsigned long n, int category) |
278 | | { |
279 | | (void) domain; |
280 | | (void) category; |
281 | | return (n == 1 ? msgid1 : msgid2); |
282 | | } |
283 | | # undef dcngettext |
284 | | # define dcngettext _libgettext_dcngettext |
285 | | static inline const char * |
286 | | _libgettext_textdomain (const char *domainname) |
287 | | { |
288 | | return domainname; |
289 | | } |
290 | | # undef textdomain |
291 | | # define textdomain _libgettext_textdomain |
292 | | |
293 | | # else |
294 | | |
295 | | # undef gettext |
296 | | # define gettext(Msgid) _LIBGETTEXT_FUNCAST (const char *, Msgid) |
297 | | # undef dgettext |
298 | | # define dgettext(Domainname, Msgid) \ |
299 | | ((void) _LIBGETTEXT_FUNCAST (const char *, Domainname), gettext (Msgid)) |
300 | | # undef dcgettext |
301 | | # define dcgettext(Domainname, Msgid, Category) \ |
302 | | ((void) _LIBGETTEXT_FUNCAST (int, Category), \ |
303 | | dgettext (Domainname, Msgid)) |
304 | | # undef ngettext |
305 | | # define ngettext(Msgid1, Msgid2, N) \ |
306 | | ((N) == 1 \ |
307 | | ? ((void) _LIBGETTEXT_FUNCAST (const char *, Msgid2), \ |
308 | | _LIBGETTEXT_FUNCAST (const char *, Msgid1)) \ |
309 | | : ((void) _LIBGETTEXT_FUNCAST (const char *, Msgid1), \ |
310 | | _LIBGETTEXT_FUNCAST (const char *, Msgid2))) |
311 | | # undef dngettext |
312 | | # define dngettext(Domainname, Msgid1, Msgid2, N) \ |
313 | | ((void) _LIBGETTEXT_FUNCAST (const char *, Domainname), \ |
314 | | ngettext (Msgid1, Msgid2, N)) |
315 | | # undef dcngettext |
316 | | # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ |
317 | | ((void) _LIBGETTEXT_FUNCAST (int, Category), \ |
318 | | dngettext (Domainname, Msgid1, Msgid2, N)) |
319 | | # undef textdomain |
320 | | # define textdomain(Domainname) _LIBGETTEXT_FUNCAST (const char *, Domainname) |
321 | | |
322 | | # endif |
323 | | |
324 | | # undef bindtextdomain |
325 | | # define bindtextdomain(Domainname, Dirname) \ |
326 | | ((void) _LIBGETTEXT_FUNCAST (const char *, Domainname), \ |
327 | | _LIBGETTEXT_FUNCAST (const char *, Dirname)) |
328 | | # undef bind_textdomain_codeset |
329 | | # define bind_textdomain_codeset(Domainname, Codeset) \ |
330 | | ((void) _LIBGETTEXT_FUNCAST (const char *, Domainname), \ |
331 | | _LIBGETTEXT_FUNCAST (const char *, Codeset)) |
332 | | |
333 | | #endif |
334 | | |
335 | | |
336 | | /* Prefer gnulib's setlocale override over libintl's setlocale override. */ |
337 | | #ifdef GNULIB_defined_setlocale |
338 | | # undef setlocale |
339 | | # define setlocale rpl_setlocale |
340 | | #endif |
341 | | |
342 | | |
343 | | /* A pseudo function call that serves as a marker for the automated |
344 | | extraction of messages, but does not call gettext(). The run-time |
345 | | translation is done at a different place in the code. |
346 | | The argument, String, should be a literal string. Concatenated strings |
347 | | and other string expressions won't work. |
348 | | The macro's expansion is not parenthesized, so that it is suitable as |
349 | | initializer for static 'char[]' or 'const char[]' variables. */ |
350 | | #define gettext_noop(String) String |
351 | | |
352 | | |
353 | | /* The separator between msgctxt and msgid in a .mo file. */ |
354 | | #define GETTEXT_CONTEXT_GLUE "\004" |
355 | | |
356 | | /* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a |
357 | | MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be |
358 | | short and rarely need to change. |
359 | | The letter 'p' stands for 'particular' or 'special'. */ |
360 | | |
361 | | #include <locale.h> /* for LC_MESSAGES */ |
362 | | /* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C. |
363 | | On systems that don't define it, use the same value as GNU libintl. */ |
364 | | #if !defined LC_MESSAGES |
365 | | # define LC_MESSAGES 1729 |
366 | | #endif |
367 | | |
368 | | #ifdef DEFAULT_TEXT_DOMAIN |
369 | | # define pgettext(Msgctxt, Msgid) \ |
370 | | pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) |
371 | | #else |
372 | | # define pgettext(Msgctxt, Msgid) \ |
373 | | pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) |
374 | | #endif |
375 | | #define dpgettext(Domainname, Msgctxt, Msgid) \ |
376 | | pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) |
377 | | #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ |
378 | | pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) |
379 | | #ifdef DEFAULT_TEXT_DOMAIN |
380 | | # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ |
381 | | npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) |
382 | | #else |
383 | | # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ |
384 | | npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) |
385 | | #endif |
386 | | #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ |
387 | | npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) |
388 | | #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ |
389 | | npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) |
390 | | |
391 | | #if defined __GNUC__ || defined __clang__ |
392 | | __inline |
393 | | #elif defined __cplusplus |
394 | | inline |
395 | | #endif |
396 | | static const char * |
397 | | pgettext_aux (const char *domain, |
398 | | const char *msg_ctxt_id, const char *msgid, |
399 | | int category) |
400 | 0 | { |
401 | 0 | const char *translation = dcgettext (domain, msg_ctxt_id, category); |
402 | 0 | if (translation == msg_ctxt_id) |
403 | 0 | return msgid; |
404 | 0 | else |
405 | 0 | return translation; |
406 | 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 |
407 | | |
408 | | #if defined __GNUC__ || defined __clang__ |
409 | | __inline |
410 | | #elif defined __cplusplus |
411 | | inline |
412 | | #endif |
413 | | static const char * |
414 | | npgettext_aux (const char *domain, |
415 | | const char *msg_ctxt_id, const char *msgid, |
416 | | const char *msgid_plural, unsigned long int n, |
417 | | int category) |
418 | 0 | { |
419 | 0 | const char *translation = |
420 | 0 | dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); |
421 | 0 | if (translation == msg_ctxt_id || translation == msgid_plural) |
422 | 0 | return (n == 1 ? msgid : msgid_plural); |
423 | 0 | else |
424 | 0 | return translation; |
425 | 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 |
426 | | |
427 | | |
428 | | /* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID |
429 | | can be arbitrary expressions. But for string literals these macros are |
430 | | less efficient than those above. */ |
431 | | |
432 | | #include <string.h> /* for memcpy */ |
433 | | |
434 | | /* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported. |
435 | | This relates to the -Wvla and -Wvla-larger-than warnings, enabled in |
436 | | the default GCC many warnings set. This allows programs to disable use |
437 | | of VLAs, which may be unintended, or may be awkward to support portably, |
438 | | or may have security implications due to non-deterministic stack usage. */ |
439 | | |
440 | | #if (!defined GNULIB_NO_VLA \ |
441 | | && (((__GNUC__ >= 3 || defined __clang__) \ |
442 | | && !defined __STRICT_ANSI__ && !defined __cplusplus) \ |
443 | | /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc) |
444 | | || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )) |
445 | | # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 |
446 | | #else |
447 | | # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 |
448 | | #endif |
449 | | |
450 | | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS |
451 | | # include <stdlib.h> /* for malloc, free */ |
452 | | #endif |
453 | | |
454 | | #define pgettext_expr(Msgctxt, Msgid) \ |
455 | | dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) |
456 | | #define dpgettext_expr(Domainname, Msgctxt, Msgid) \ |
457 | | dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) |
458 | | |
459 | | #if defined __GNUC__ || defined __clang__ |
460 | | __inline |
461 | | #elif defined __cplusplus |
462 | | inline |
463 | | #endif |
464 | | static const char * |
465 | | dcpgettext_expr (const char *domain, |
466 | | const char *msgctxt, const char *msgid, |
467 | | int category) |
468 | 0 | { |
469 | 0 | size_t msgctxt_len = strlen (msgctxt) + 1; |
470 | 0 | size_t msgid_len = strlen (msgid) + 1; |
471 | 0 | const char *translation; |
472 | 0 | #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS |
473 | 0 | char msg_ctxt_id[msgctxt_len + msgid_len]; |
474 | 0 | #else |
475 | 0 | char buf[1024]; |
476 | 0 | char *msg_ctxt_id = |
477 | 0 | (msgctxt_len + msgid_len <= sizeof (buf) |
478 | 0 | ? buf |
479 | 0 | : (char *) malloc (msgctxt_len + msgid_len)); |
480 | 0 | if (msg_ctxt_id != NULL) |
481 | 0 | #endif |
482 | 0 | { |
483 | 0 | memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); |
484 | 0 | msg_ctxt_id[msgctxt_len - 1] = '\004'; |
485 | 0 | memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); |
486 | 0 | translation = dcgettext (domain, msg_ctxt_id, category); |
487 | 0 | int found_translation = (translation != msg_ctxt_id); |
488 | 0 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS |
489 | 0 | if (msg_ctxt_id != buf) |
490 | 0 | free (msg_ctxt_id); |
491 | 0 | #endif |
492 | 0 | if (found_translation) |
493 | 0 | return translation; |
494 | 0 | } |
495 | 0 | return msgid; |
496 | 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 |
497 | | |
498 | | #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ |
499 | | dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) |
500 | | #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ |
501 | | dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) |
502 | | |
503 | | #if defined __GNUC__ || defined __clang__ |
504 | | __inline |
505 | | #elif defined __cplusplus |
506 | | inline |
507 | | #endif |
508 | | static const char * |
509 | | dcnpgettext_expr (const char *domain, |
510 | | const char *msgctxt, const char *msgid, |
511 | | const char *msgid_plural, unsigned long int n, |
512 | | int category) |
513 | 0 | { |
514 | 0 | size_t msgctxt_len = strlen (msgctxt) + 1; |
515 | 0 | size_t msgid_len = strlen (msgid) + 1; |
516 | 0 | const char *translation; |
517 | 0 | #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS |
518 | 0 | char msg_ctxt_id[msgctxt_len + msgid_len]; |
519 | 0 | #else |
520 | 0 | char buf[1024]; |
521 | 0 | char *msg_ctxt_id = |
522 | 0 | (msgctxt_len + msgid_len <= sizeof (buf) |
523 | 0 | ? buf |
524 | 0 | : (char *) malloc (msgctxt_len + msgid_len)); |
525 | 0 | if (msg_ctxt_id != NULL) |
526 | 0 | #endif |
527 | 0 | { |
528 | 0 | memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); |
529 | 0 | msg_ctxt_id[msgctxt_len - 1] = '\004'; |
530 | 0 | memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); |
531 | 0 | translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); |
532 | 0 | int found_translation = !(translation == msg_ctxt_id || translation == msgid_plural); |
533 | 0 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS |
534 | 0 | if (msg_ctxt_id != buf) |
535 | 0 | free (msg_ctxt_id); |
536 | 0 | #endif |
537 | 0 | if (found_translation) |
538 | 0 | return translation; |
539 | 0 | } |
540 | 0 | return (n == 1 ? msgid : msgid_plural); |
541 | 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 |
542 | | |
543 | | |
544 | | #endif /* _LIBGETTEXT_H */ |