19# ifdef DEFAULT_TEXT_DOMAIN
21# define gettext(Msgid) \
22 dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
24# define ngettext(Msgid1, Msgid2, N) \
25 dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
29#define GETTEXT_CONTEXT_GLUE "\004"
35#ifdef DEFAULT_TEXT_DOMAIN
36# define pgettext(Msgctxt, Msgid) \
37 pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid)
39# define pgettext(Msgctxt, Msgid) \
40 pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid)
42#define dpgettext(Domainname, Msgctxt, Msgid) \
43 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid)
53pgettext_aux(
const char *domain,
54 const char *msg_ctxt_id,
const char *msgid)
56 const char *translation = dgettext(domain, msg_ctxt_id);
57 if (translation == msg_ctxt_id) {
70#ifndef __STRICT_ANSI__
71#define __STRICT_ANSI__
72#define __STRICT_ANSI_FORCED__
75#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
76 (__STRICT_ANSI__ - 0 == 0) && (__GNUC__ >= 3 || __GNUG__ >= 2 )
78#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
82#define pgettext_expr(Msgctxt, Msgid) \
83 dpgettext_expr (NULL, Msgctxt, Msgid)
84#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
85 dpgettext_expr (Domainname, Msgctxt, Msgid)
95dpgettext_expr(
const char *domain,
96 const char *msgctxt,
const char *msgid)
98 size_t msgctxt_len = strlen(msgctxt) + 1;
99 size_t msgid_len = strlen(msgid) + 1;
100 const char *translation;
101 int translation_found;
102#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
103 char msg_ctxt_id[msgctxt_len + msgid_len];
107 (msgctxt_len + msgid_len <=
sizeof(buf)
109 : (
char *) malloc(msgctxt_len + msgid_len));
110 if (msg_ctxt_id !=
nullptr)
113 memcpy(msg_ctxt_id, msgctxt, msgctxt_len - 1);
114 msg_ctxt_id[msgctxt_len - 1] =
'\004';
115 memcpy(msg_ctxt_id + msgctxt_len, msgid, msgid_len);
116 translation = dgettext(domain, msg_ctxt_id);
118 translation_found = translation != msg_ctxt_id;
119#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
120 if (msg_ctxt_id != buf) {
124 if (translation_found) {
131#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
132 dnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N)
133#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
134 dnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N)
144dnpgettext_expr(
const char *domain,
145 const char *msgctxt,
const char *msgid,
146 const char *msgid_plural,
unsigned long int n)
148 size_t msgctxt_len = strlen(msgctxt) + 1;
149 size_t msgid_len = strlen(msgid) + 1;
150 const char *translation;
151 int translation_found;
152#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
153 char msg_ctxt_id[msgctxt_len + msgid_len];
157 (msgctxt_len + msgid_len <=
sizeof(buf)
159 : (
char *) malloc(msgctxt_len + msgid_len));
160 if (msg_ctxt_id !=
nullptr)
163 memcpy(msg_ctxt_id, msgctxt, msgctxt_len - 1);
164 msg_ctxt_id[msgctxt_len - 1] =
'\004';
165 memcpy(msg_ctxt_id + msgctxt_len, msgid, msgid_len);
166 translation = dngettext(domain, msg_ctxt_id, msgid_plural, n);
168 translation_found = !(translation == msg_ctxt_id || translation == msgid_plural);
169#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
170 if (msg_ctxt_id != buf) {
174 if (translation_found) {
178 return (n == 1 ? msgid : msgid_plural);
181#ifdef __STRICT_ANSI_FORCED__
182#undef __STRICT_ANSI__
183#undef __STRICT_ANSI_FORCED__