1
0
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:
Paul Eggert
2026-08-25 13:26:06 -07:00
parent 0052b26849
commit a9fa600521
6 changed files with 43 additions and 22 deletions
+11
View File
@@ -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 doesnt need gettext.h
* lib/getaddrinfo.c: Dont 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
+4
View File
@@ -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
+4
View File
@@ -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
View File
@@ -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
-2
View File
@@ -27,9 +27,7 @@ main (void)
{
const char *s;
#if ENABLE_NLS
textdomain ("tzlof");
#endif
s = gettext ("some text");
if (!streq (s, "some text"))