178
177
return translation;
180
/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
181
can be arbitrary expressions. But for string literals these macros are
182
less efficient than those above. */
186
#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
187
(((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
188
/* || __STDC_VERSION__ >= 199901L */ )
190
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
194
#define pgettext_expr(Msgctxt, Msgid) \
195
dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
196
#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
197
dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
207
dcpgettext_expr (const char *domain,
208
const char *msgctxt, const char *msgid,
211
size_t msgctxt_len = strlen (msgctxt) + 1;
212
size_t msgid_len = strlen (msgid) + 1;
213
const char *translation;
214
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
215
char msg_ctxt_id[msgctxt_len + msgid_len];
219
(msgctxt_len + msgid_len <= sizeof (buf)
221
: (char *) malloc (msgctxt_len + msgid_len));
222
if (msg_ctxt_id != NULL)
225
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
226
msg_ctxt_id[msgctxt_len - 1] = '\004';
227
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
228
translation = dcgettext (domain, msg_ctxt_id, category);
229
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
230
if (msg_ctxt_id != buf)
233
if (translation != msg_ctxt_id)
239
#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
240
dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
241
#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
242
dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
252
dcnpgettext_expr (const char *domain,
253
const char *msgctxt, const char *msgid,
254
const char *msgid_plural, unsigned long int n,
257
size_t msgctxt_len = strlen (msgctxt) + 1;
258
size_t msgid_len = strlen (msgid) + 1;
259
const char *translation;
260
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
261
char msg_ctxt_id[msgctxt_len + msgid_len];
265
(msgctxt_len + msgid_len <= sizeof (buf)
267
: (char *) malloc (msgctxt_len + msgid_len));
268
if (msg_ctxt_id != NULL)
271
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
272
msg_ctxt_id[msgctxt_len - 1] = '\004';
273
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
274
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
275
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
276
if (msg_ctxt_id != buf)
279
if (!(translation == msg_ctxt_id || translation == msgid_plural))
282
return (n == 1 ? msgid : msgid_plural);
181
285
#endif /* _LIBGETTEXT_H */