summaryrefslogtreecommitdiffstats
path: root/gl/gettext.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/gettext.h')
-rw-r--r--gl/gettext.h43
1 files changed, 28 insertions, 15 deletions
diff --git a/gl/gettext.h b/gl/gettext.h
index d021571..f1c7a24 100644
--- a/gl/gettext.h
+++ b/gl/gettext.h
@@ -1,25 +1,26 @@
1/* Convenience header for conditional use of GNU <libintl.h>. 1/* Convenience header for conditional use of GNU <libintl.h>.
2 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2013 Free Software 2 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2021 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _LIBGETTEXT_H 18#ifndef _LIBGETTEXT_H
19#define _LIBGETTEXT_H 1 19#define _LIBGETTEXT_H 1
20 20
21/* NLS can be disabled through the configure --disable-nls option. */ 21/* NLS can be disabled through the configure --disable-nls option
22#if ENABLE_NLS 22 or through "#define ENABLE NLS 0" before including this file. */
23#if defined ENABLE_NLS && ENABLE_NLS
23 24
24/* Get declarations of GNU message catalog functions. */ 25/* Get declarations of GNU message catalog functions. */
25# include <libintl.h> 26# include <libintl.h>
@@ -183,8 +184,16 @@ npgettext_aux (const char *domain,
183 184
184#include <string.h> 185#include <string.h>
185 186
186#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ 187/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported.
187 /* || __STDC_VERSION__ >= 199901L */ ) 188 This relates to the -Wvla and -Wvla-larger-than warnings, enabled in
189 the default GCC many warnings set. This allows programs to disable use
190 of VLAs, which may be unintended, or may be awkward to support portably,
191 or may have security implications due to non-deterministic stack usage. */
192
193#if (!defined GNULIB_NO_VLA \
194 && (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
195 /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc)
196 || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ))
188# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 197# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
189#else 198#else
190# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 199# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
@@ -225,15 +234,17 @@ dcpgettext_expr (const char *domain,
225 if (msg_ctxt_id != NULL) 234 if (msg_ctxt_id != NULL)
226#endif 235#endif
227 { 236 {
237 int found_translation;
228 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); 238 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
229 msg_ctxt_id[msgctxt_len - 1] = '\004'; 239 msg_ctxt_id[msgctxt_len - 1] = '\004';
230 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); 240 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
231 translation = dcgettext (domain, msg_ctxt_id, category); 241 translation = dcgettext (domain, msg_ctxt_id, category);
242 found_translation = (translation != msg_ctxt_id);
232#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 243#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
233 if (msg_ctxt_id != buf) 244 if (msg_ctxt_id != buf)
234 free (msg_ctxt_id); 245 free (msg_ctxt_id);
235#endif 246#endif
236 if (translation != msg_ctxt_id) 247 if (found_translation)
237 return translation; 248 return translation;
238 } 249 }
239 return msgid; 250 return msgid;
@@ -271,15 +282,17 @@ dcnpgettext_expr (const char *domain,
271 if (msg_ctxt_id != NULL) 282 if (msg_ctxt_id != NULL)
272#endif 283#endif
273 { 284 {
285 int found_translation;
274 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); 286 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
275 msg_ctxt_id[msgctxt_len - 1] = '\004'; 287 msg_ctxt_id[msgctxt_len - 1] = '\004';
276 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); 288 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
277 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); 289 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
290 found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
278#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 291#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
279 if (msg_ctxt_id != buf) 292 if (msg_ctxt_id != buf)
280 free (msg_ctxt_id); 293 free (msg_ctxt_id);
281#endif 294#endif
282 if (!(translation == msg_ctxt_id || translation == msgid_plural)) 295 if (found_translation)
283 return translation; 296 return translation;
284 } 297 }
285 return (n == 1 ? msgid : msgid_plural); 298 return (n == 1 ? msgid : msgid_plural);