mirror of
https://https.git.savannah.gnu.org/git/gnulib.git
synced 2026-09-01 02:34:55 +00:00
gettext-h: always define textdomain
Problem reported by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2026-08/msg00288.html * lib/gettext.h (textdomain, bindtextdomain, bind_textdomain_codeset) [!ENABLE_NLS && __GNUC__ && !__clang__ && !__cplusplus]: Define to no-ops in this case too. Move the definition of _LIBGETTEXT_FUNCAST up one level of ifdeffery so that it is defined for this case. * tests/test-gettext-h.c (main) [!ENABLE_NLS]: Call textdomain, reverting the previous change to this file.
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
2026-08-25 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
gettext-h: always define textdomain
|
||||
Problem reported by Bruno Haible in:
|
||||
https://lists.gnu.org/r/bug-gnulib/2026-08/msg00288.html
|
||||
* lib/gettext.h (textdomain, bindtextdomain, bind_textdomain_codeset)
|
||||
[!ENABLE_NLS && __GNUC__ && !__clang__ && !__cplusplus]:
|
||||
Define to no-ops in this case too.
|
||||
Move the definition of _LIBGETTEXT_FUNCAST up one level of
|
||||
ifdeffery so that it is defined for this case.
|
||||
* tests/test-gettext-h.c (main) [!ENABLE_NLS]: Call textdomain,
|
||||
reverting the previous change to this file.
|
||||
|
||||
getaddrinfo: getaddrinfo.c doesn’t need gettext.h
|
||||
* lib/getaddrinfo.c: Don’t include gettext.h.
|
||||
(_, N_): Remove; unused.
|
||||
|
||||
@@ -28,4 +28,8 @@ Portability problems not fixed by Gnulib:
|
||||
@item
|
||||
This function is missing on some platforms:
|
||||
macOS 14, FreeBSD 14.0, OpenBSD 7.9, Minix 3.1.8, HP-UX 11, Cygwin 2.9, mingw, MSVC 14, Android 9.0.
|
||||
|
||||
The @code{gettext-h} module has a partial workaround:
|
||||
@code{<gettext.h>} supplies the function,
|
||||
and makes it a no-op if internationalization is not in use.
|
||||
@end itemize
|
||||
|
||||
@@ -28,4 +28,8 @@ Portability problems not fixed by Gnulib:
|
||||
@item
|
||||
This function is missing on some platforms:
|
||||
macOS 14, FreeBSD 14.0, OpenBSD 7.9, Minix 3.1.8, HP-UX 11, Cygwin 2.9, mingw, MSVC 14, Android 9.0.
|
||||
|
||||
The @code{gettext-h} module has a partial workaround:
|
||||
@code{<gettext.h>} supplies the function,
|
||||
and makes it a no-op if internationalization is not in use.
|
||||
@end itemize
|
||||
|
||||
@@ -28,4 +28,8 @@ Portability problems not fixed by Gnulib:
|
||||
@item
|
||||
This function is missing on some platforms:
|
||||
macOS 14, FreeBSD 14.0, OpenBSD 7.9, Minix 3.1.8, HP-UX 11, Cygwin 2.9, mingw, MSVC 14, Android 9.0.
|
||||
|
||||
The @code{gettext-h} module has a partial workaround:
|
||||
@code{<gettext.h>} supplies the function,
|
||||
and makes it a no-op if internationalization is not in use.
|
||||
@end itemize
|
||||
|
||||
+20
-20
@@ -59,6 +59,15 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Like the C cast ((type) (expr)), but do only conversions that an
|
||||
ordinary assignment would do. This can diagnose invalid arguments
|
||||
better than a cast would. */
|
||||
# ifdef __cplusplus
|
||||
# define _LIBGETTEXT_FUNCAST(type, expr) static_cast <type> (expr)
|
||||
# else
|
||||
# define _LIBGETTEXT_FUNCAST(type, expr) (type) {(expr)}
|
||||
# endif
|
||||
|
||||
/* Disabled NLS. */
|
||||
/* When gcc is used with option -Wformat=2, we need to silence
|
||||
"warning: format not a string literal, argument types not checked [-Wformat-nonliteral]"
|
||||
@@ -173,15 +182,6 @@ dcgettext (const char *domain, const char *msgid, int category)
|
||||
|
||||
# else
|
||||
|
||||
/* Like the C cast ((type) (expr)), but do only conversions that an
|
||||
ordinary assignment would do. This can diagnose invalid arguments
|
||||
better than a cast would. */
|
||||
# ifdef __cplusplus
|
||||
# define _LIBGETTEXT_FUNCAST(type, expr) static_cast <type> (expr)
|
||||
# else
|
||||
# define _LIBGETTEXT_FUNCAST(type, expr) (type) {(expr)}
|
||||
# endif
|
||||
|
||||
# undef gettext
|
||||
# define gettext(Msgid) _LIBGETTEXT_FUNCAST (const char *, Msgid)
|
||||
# undef dgettext
|
||||
@@ -206,18 +206,18 @@ dcgettext (const char *domain, const char *msgid, int category)
|
||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
||||
((void) _LIBGETTEXT_FUNCAST (int, Category), \
|
||||
dngettext (Domainname, Msgid1, Msgid2, N))
|
||||
# undef textdomain
|
||||
# define textdomain(Domainname) _LIBGETTEXT_FUNCAST (const char *, Domainname)
|
||||
# undef bindtextdomain
|
||||
# define bindtextdomain(Domainname, Dirname) \
|
||||
((void) _LIBGETTEXT_FUNCAST (const char *, Domainname), \
|
||||
_LIBGETTEXT_FUNCAST (const char *, Dirname))
|
||||
# undef bind_textdomain_codeset
|
||||
# define bind_textdomain_codeset(Domainname, Codeset) \
|
||||
((void) _LIBGETTEXT_FUNCAT (const char *, Domainname), \
|
||||
_LIBGETTEXT_FUNCAT (const char *, Codeset))
|
||||
|
||||
# endif
|
||||
|
||||
# undef textdomain
|
||||
# define textdomain(Domainname) _LIBGETTEXT_FUNCAST (const char *, Domainname)
|
||||
# undef bindtextdomain
|
||||
# define bindtextdomain(Domainname, Dirname) \
|
||||
((void) _LIBGETTEXT_FUNCAST (const char *, Domainname), \
|
||||
_LIBGETTEXT_FUNCAST (const char *, Dirname))
|
||||
# undef bind_textdomain_codeset
|
||||
# define bind_textdomain_codeset(Domainname, Codeset) \
|
||||
((void) _LIBGETTEXT_FUNCAT (const char *, Domainname), \
|
||||
_LIBGETTEXT_FUNCAT (const char *, Codeset))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -27,9 +27,7 @@ main (void)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
#if ENABLE_NLS
|
||||
textdomain ("tzlof");
|
||||
#endif
|
||||
|
||||
s = gettext ("some text");
|
||||
if (!streq (s, "some text"))
|
||||
|
||||
Reference in New Issue
Block a user