[PATCH 1/3] intl: Remove IN_LIBGLOCALE dead code

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed May 13 14:16:32 GMT 2026



On 05/05/26 12:11, Avinal Kumar wrote:
> Remove all IN_LIBGLOCALE conditional blocks from intl/.  libglocale
> was a proposed API from 2005 that was never completed or shipped.
> The macro is never defined in glibc or in current GNU gettext, making
> every #ifdef IN_LIBGLOCALE block dead code.
> 
> GNU gettext removed these in commits starting from 2023.  Removing
> them from glibc reduces noise and eases future syncs with gettext.
> 
> Imported from GNU gettext commit d6a6801c1.
> Original author: Bruno Haible <bruno@clisp.org>
> 
> Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  intl/dcigettext.c  | 116 +++++----------------------------------------
>  intl/gettextP.h    |  21 --------
>  intl/loadmsgcat.c  |   5 --
>  intl/localealias.c |   9 +---
>  intl/plural-exp.h  |   2 +-
>  5 files changed, 15 insertions(+), 138 deletions(-)
> 
> diff --git a/intl/dcigettext.c b/intl/dcigettext.c
> index 9ebc54eeec..17bb8af444 100644
> --- a/intl/dcigettext.c
> +++ b/intl/dcigettext.c
> @@ -95,9 +95,6 @@ extern int errno;
>  #ifdef _LIBC
>  # include <libintl.h>
>  #else
> -# ifdef IN_LIBGLOCALE
> -#  include <libintl.h>
> -# endif
>  # include "libgnuintl.h"
>  #endif
>  #include "hash-string.h"
> @@ -228,7 +225,7 @@ static void *mempcpy (void *dest, const void *src, size_t n);
>  #endif
>  
>  /* Whether to support different locales in different threads.  */
> -#if defined _LIBC || HAVE_USELOCALE || defined IN_LIBGLOCALE
> +#if defined _LIBC || HAVE_USELOCALE
>  # define HAVE_PER_THREAD_LOCALE
>  #endif
>  
> @@ -247,11 +244,6 @@ struct known_translation_t
>    const char *localename;
>  #endif
>  
> -#ifdef IN_LIBGLOCALE
> -  /* The character encoding.  */
> -  const char *encoding;
> -#endif
> -
>    /* State of the catalog counter at the point the string was found.  */
>    int counter;
>  
> @@ -299,10 +291,6 @@ transcmp (const void *p1, const void *p2)
>  	  if (result == 0)
>  #endif
>  	    {
> -#ifdef IN_LIBGLOCALE
> -	      result = strcmp (s1->encoding, s2->encoding);
> -	      if (result == 0)
> -#endif
>  		/* We compare the category last (though this is the cheapest
>  		   operation) since it is hopefully always the same (namely
>  		   LC_MESSAGES).  */
> @@ -318,11 +306,9 @@ transcmp (const void *p1, const void *p2)
>     textdomain(3).  The default value for this is "messages".  */
>  const char _nl_default_default_domain[] attribute_hidden = "messages";
>  
> -#ifndef IN_LIBGLOCALE
>  /* Value used as the default domain for gettext(3).  */
>  const char *_nl_current_default_domain attribute_hidden
>       = _nl_default_default_domain;
> -#endif
>  
>  /* Contains the default location of the message catalogs.  */
>  #if defined __EMX__
> @@ -338,25 +324,17 @@ libc_hidden_data_def (_nl_default_dirname)
>  # endif
>  #endif
>  
> -#ifndef IN_LIBGLOCALE
>  /* List with bindings of specific domains created by bindtextdomain()
>     calls.  */
>  struct binding *_nl_domain_bindings;
> -#endif
>  
>  /* Prototypes for local functions.  */
>  static char *plural_lookup (struct loaded_l10nfile *domain,
>  			    unsigned long int n,
>  			    const char *translation, size_t translation_len);
>  
> -#ifdef IN_LIBGLOCALE
> -static const char *guess_category_value (int category,
> -					 const char *categoryname,
> -					 const char *localename);
> -#else
>  static const char *guess_category_value (int category,
>  					 const char *categoryname);
> -#endif
>  
>  #ifdef _LIBC
>  # include "../locale/localeinfo.h"
> @@ -364,7 +342,7 @@ static const char *guess_category_value (int category,
>  #else
>  static const char *category_to_name (int category);
>  #endif
> -#if (defined _LIBC || HAVE_ICONV) && !defined IN_LIBGLOCALE
> +#if (defined _LIBC || HAVE_ICONV)
>  static const char *get_output_charset (struct binding *domainbinding);
>  #endif
>  
> @@ -443,18 +421,9 @@ static int enable_secure;
>  /* Look up MSGID in the DOMAINNAME message catalog for the current
>     CATEGORY locale and, if PLURAL is nonzero, search over string
>     depending on the plural form determined by N.  */
> -#ifdef IN_LIBGLOCALE
> -char *
> -gl_dcigettext (const char *domainname,
> -	       const char *msgid1, const char *msgid2,
> -	       int plural, unsigned long int n,
> -	       int category,
> -	       const char *localename, const char *encoding)
> -#else
>  char *
>  DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
>  	    int plural, unsigned long int n, int category)
> -#endif
>  {
>    struct loaded_l10nfile *domain;
>    struct binding *binding;
> @@ -469,7 +438,7 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
>    int saved_errno;
>    struct known_translation_t search;
>    struct known_translation_t **foundp = NULL;
> -#if defined HAVE_PER_THREAD_LOCALE && !defined IN_LIBGLOCALE
> +#if defined HAVE_PER_THREAD_LOCALE
>    const char *localename;
>  #endif
>    size_t domainname_len;
> @@ -516,21 +485,16 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
>    search.domainname = domainname;
>    search.category = category;
>  #ifdef HAVE_PER_THREAD_LOCALE
> -# ifndef IN_LIBGLOCALE
> -#  ifdef _LIBC
> +# ifdef _LIBC
>    localename = __current_locale_name (category);
> -#  else
> +# else
>    categoryname = category_to_name (category);
> -#   define CATEGORYNAME_INITIALIZED
> +#  define CATEGORYNAME_INITIALIZED
>    localename = _nl_locale_name_thread_unsafe (category, categoryname);
>    if (localename == NULL)
>      localename = "";
> -#  endif
>  # endif
>    search.localename = localename;
> -# ifdef IN_LIBGLOCALE
> -  search.encoding = encoding;
> -# endif
>  
>    /* Since tfind/tsearch manage a balanced tree, concurrent tfind and
>       tsearch calls can be fatal.  */
> @@ -562,12 +526,6 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
>    DETERMINE_SECURE;
>  
>    /* First find matching binding.  */
> -#ifdef IN_LIBGLOCALE
> -  /* We can use a trivial binding, since _nl_find_msg will ignore it anyway,
> -     and _nl_load_domain and _nl_find_domain just pass it through.  */
> -  binding = NULL;
> -  dirname = bindtextdomain (domainname, NULL);
> -#else
>    for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
>      {
>        int compare = strcmp (domainname, binding->domainname);
> @@ -587,7 +545,6 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
>    else
>      {
>        dirname = binding->dirname;
> -#endif
>        if (!IS_ABSOLUTE_PATH (dirname))
>  	{
>  	  /* We have a relative path.  Make it absolute now.  */
> @@ -603,20 +560,13 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
>  	    goto return_untranslated;
>  	  dirname = xdirname;
>  	}
> -#ifndef IN_LIBGLOCALE
>      }
> -#endif
>  
>    /* Now determine the symbolic name of CATEGORY and its value.  */
>  #ifndef CATEGORYNAME_INITIALIZED
>    categoryname = category_to_name (category);
>  #endif
> -#ifdef IN_LIBGLOCALE
> -  categoryvalue = guess_category_value (category, categoryname, localename);
> -#else
>    categoryvalue = guess_category_value (category, categoryname);
> -#endif
> -
>    domainname_len = strlen (domainname);
>    xdomainname = (char *) malloc (strlen (categoryname)
>  				 + domainname_len + 5);
> @@ -675,11 +625,7 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
>  
>        if (domain != NULL)
>  	{
> -#if defined IN_LIBGLOCALE
> -	  retval = _nl_find_msg (domain, binding, encoding, msgid1, &retlen);
> -#else
>  	  retval = _nl_find_msg (domain, binding, msgid1, 1, &retlen);
> -#endif
>  
>  	  if (retval == NULL)
>  	    {
> @@ -687,13 +633,8 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
>  
>  	      for (cnt = 0; domain->successor[cnt] != NULL; ++cnt)
>  		{
> -#if defined IN_LIBGLOCALE
> -		  retval = _nl_find_msg (domain->successor[cnt], binding,
> -					 encoding, msgid1, &retlen);
> -#else
>  		  retval = _nl_find_msg (domain->successor[cnt], binding,
>  					 msgid1, 1, &retlen);
> -#endif
>  
>  		  /* Resource problems are not fatal, instead we return no
>  		     translation.  */
> @@ -754,9 +695,6 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
>  		      newp->category = category;
>  #ifdef HAVE_PER_THREAD_LOCALE
>  		      newp->localename = new_localename;
> -#endif
> -#ifdef IN_LIBGLOCALE
> -		      newp->encoding = encoding;
>  #endif
>  		      newp->counter = _nl_msg_cat_cntr;
>  		      newp->domain = domain;
> @@ -837,17 +775,10 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
>     in case of a memory allocation failure during conversion (only if
>     ENCODING != NULL resp. CONVERT == true).  */
>  char *
> -#ifdef IN_LIBGLOCALE
> -_nl_find_msg (struct loaded_l10nfile *domain_file,
> -	      struct binding *domainbinding, const char *encoding,
> -	      const char *msgid,
> -	      size_t *lengthp)
> -#else
>  _nl_find_msg (struct loaded_l10nfile *domain_file,
>  	      struct binding *domainbinding,
>  	      const char *msgid, int convert,
>  	      size_t *lengthp)
> -#endif
>  {
>    struct loaded_domain *domain;
>    nls_uint32 nstrings;
> @@ -953,16 +884,10 @@ _nl_find_msg (struct loaded_l10nfile *domain_file,
>      }
>  
>  #if defined _LIBC || HAVE_ICONV
> -# ifdef IN_LIBGLOCALE
> -  if (encoding != NULL)
> -# else
>    if (convert)
> -# endif
>      {
>        /* We are supposed to do a conversion.  */
> -# ifndef IN_LIBGLOCALE
>        const char *encoding = get_output_charset (domainbinding);
> -# endif
>        size_t nconversions;
>        struct converted_domain *convd;
>        size_t i;
> @@ -1056,12 +981,7 @@ _nl_find_msg (struct loaded_l10nfile *domain_file,
>  		 reallocate domain->conversions because we pass
>  		 encoding = NULL or convert = 0, respectively.  */
>  	      nullentry =
> -# ifdef IN_LIBGLOCALE
> -		_nl_find_msg (domain_file, domainbinding, NULL, "",
> -			      &nullentrylen);
> -# else
>  		_nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
> -# endif
>  
>  	      /* Resource problems are fatal.  If we continue onwards we will
>  	         only attempt to calloc a new conv_tab and fail later.  */
> @@ -1470,21 +1390,13 @@ category_to_name (int category)
>  /* Guess value of current locale from value of the environment variables
>     or system-dependent defaults.  */
>  static const char *
> -#ifdef IN_LIBGLOCALE
> -guess_category_value (int category, const char *categoryname,
> -		      const char *locale)
> -
> -#else
>  guess_category_value (int category, const char *categoryname)
> -#endif
>  {
>    const char *language;
> -#ifndef IN_LIBGLOCALE
>    const char *locale;
> -# ifndef _LIBC
> +#ifndef _LIBC
>    const char *language_default;
>    int locale_defaulted;
> -# endif
>  #endif
>  
>    /* We use the settings in the following order:
> @@ -1501,18 +1413,17 @@ guess_category_value (int category, const char *categoryname)
>         - If the system provides both a list of languages and a default locale,
>           the former is used.  */
>  
> -#ifndef IN_LIBGLOCALE
>    /* Fetch the locale name, through the POSIX method of looking to `LC_ALL',
>       `LC_xxx', and `LANG'.  On some systems this can be done by the
>       `setlocale' function itself.  */
> -# ifdef _LIBC
> +#ifdef _LIBC
>    locale = __current_locale_name (category);
> -# else
> +#else
>    locale_defaulted = 0;
> -#  if HAVE_USELOCALE
> +# if HAVE_USELOCALE
>    locale = _nl_locale_name_thread_unsafe (category, categoryname);
>    if (locale == NULL)
> -#  endif
> +# endif
>      {
>        locale = _nl_locale_name_posix (category, categoryname);
>        if (locale == NULL)
> @@ -1521,7 +1432,6 @@ guess_category_value (int category, const char *categoryname)
>  	  locale_defaulted = 1;
>  	}
>      }
> -# endif
>  #endif
>  
>    /* Ignore LANGUAGE and its system-dependent analogon if the locale is set
> @@ -1547,7 +1457,7 @@ guess_category_value (int category, const char *categoryname)
>    language = getenv ("LANGUAGE");
>    if (language != NULL && language[0] != '\0')
>      return language;
> -#if !defined IN_LIBGLOCALE && !defined _LIBC
> +#ifndef _LIBC
>    /* The next priority value is the locale name, if not defaulted.  */
>    if (locale_defaulted)
>      {
> @@ -1561,7 +1471,7 @@ guess_category_value (int category, const char *categoryname)
>    return locale;
>  }
>  
> -#if (defined _LIBC || HAVE_ICONV) && !defined IN_LIBGLOCALE
> +#if (defined _LIBC || HAVE_ICONV)
>  /* Returns the output charset.  */
>  static const char *
>  get_output_charset (struct binding *domainbinding)
> diff --git a/intl/gettextP.h b/intl/gettextP.h
> index 9de46847ef..bc007e40e2 100644
> --- a/intl/gettextP.h
> +++ b/intl/gettextP.h
> @@ -70,18 +70,10 @@ extern void _nl_unload_domain (struct loaded_domain *__domain)
>  # undef _INTL_REDIRECT_MACROS
>  # define _INTL_REDIRECT_MACROS
>  # include "libgnuintl.h"
> -# ifdef IN_LIBGLOCALE
> -extern char *gl_dcigettext (const char *__domainname,
> -			    const char *__msgid1, const char *__msgid2,
> -			    int __plural, unsigned long int __n,
> -			    int __category,
> -			    const char *__localename, const char *__encoding);
> -# else
>  extern char *libintl_dcigettext (const char *__domainname,
>  				 const char *__msgid1, const char *__msgid2,
>  				 int __plural, unsigned long int __n,
>  				 int __category);
> -# endif
>  #endif
>  
>  #include "loadinfo.h"
> @@ -216,12 +208,7 @@ struct binding
>  /* A counter which is incremented each time some previous translations
>     become invalid.
>     This variable is part of the external ABI of the GNU libintl.  */
> -#ifdef IN_LIBGLOCALE
> -# include <glocale/config.h>
> -extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr;
> -#else
>  extern LIBINTL_DLL_EXPORTED int _nl_msg_cat_cntr;
> -#endif
>  
>  #ifndef _LIBC
>  extern const char *_nl_language_preferences_default (void);
> @@ -258,18 +245,10 @@ void _nl_load_domain (struct loaded_l10nfile *__domain,
>  		      struct binding *__domainbinding)
>       attribute_hidden;
>  
> -#ifdef IN_LIBGLOCALE
> -char *_nl_find_msg (struct loaded_l10nfile *domain_file,
> -		    struct binding *domainbinding, const char *encoding,
> -		    const char *msgid,
> -		    size_t *lengthp)
> -     attribute_hidden;
> -#else
>  char *_nl_find_msg (struct loaded_l10nfile *domain_file,
>  		    struct binding *domainbinding, const char *msgid,
>  		    int convert, size_t *lengthp)
>       attribute_hidden;
> -#endif
>  
>  /* The internal variables in the standalone libintl.a must have different
>     names than the internal variables in GNU libc, otherwise programs
> diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
> index f0afa37363..2bb339f3b9 100644
> --- a/intl/loadmsgcat.c
> +++ b/intl/loadmsgcat.c
> @@ -1256,12 +1256,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
>  #endif
>  
>    /* Get the header entry and look for a plural specification.  */
> -#ifdef IN_LIBGLOCALE
> -  nullentry =
> -    _nl_find_msg (domain_file, domainbinding, NULL, "", &nullentrylen);
> -#else
>    nullentry = _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
> -#endif
>    if (__builtin_expect (nullentry == (char *) -1, 0))
>      {
>  #ifdef _LIBC
> diff --git a/intl/localealias.c b/intl/localealias.c
> index 5ab48d317d..fbb26d9efd 100644
> --- a/intl/localealias.c
> +++ b/intl/localealias.c
> @@ -294,14 +294,7 @@ read_alias_file (const char *fname, int fname_len)
>  	      else if (cp[0] != '\0')
>  		*cp++ = '\0';
>  
> -#ifdef IN_LIBGLOCALE
> -	      /* glibc's locale.alias contains entries for ja_JP and ko_KR
> -		 that make it impossible to use a Japanese or Korean UTF-8
> -		 locale under the name "ja_JP" or "ko_KR".  Ignore these
> -		 entries.  */
> -	      if (strchr (alias, '_') == NULL)
> -#endif
> -		{
> +	      {
>  		  size_t alias_len;
>  		  size_t value_len;
>  
> diff --git a/intl/plural-exp.h b/intl/plural-exp.h
> index f0d3a611e1..e5fea8949a 100644
> --- a/intl/plural-exp.h
> +++ b/intl/plural-exp.h
> @@ -109,7 +109,7 @@ extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
>  				       unsigned long int *npluralsp)
>       attribute_hidden;
>  
> -#if !defined (_LIBC) && !defined (IN_LIBINTL) && !defined (IN_LIBGLOCALE)
> +#if !defined (_LIBC) && !defined (IN_LIBINTL)
>  extern unsigned long int plural_eval (const struct expression *pexp,
>  				      unsigned long int n);
>  #endif



More information about the Libc-alpha mailing list