[PATCH 3/3] intl: Remove pre-C99 fallbacks from plural-exp.c

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed May 13 15:42:13 GMT 2026



On 05/05/26 12:11, Avinal Kumar wrote:
> glibc requires C11 since 2022, making pre-C99 compatibility
> paths in plural-exp.c dead code:
> 
> - init_germanic_plural(): With C99+, GERMANIC_PLURAL is
> initialized at compile time and this function is never called.
> Remove the function and the INIT_GERMANIC_PLURAL macro.
> 
> - HAVE_STRTOUL guard: Protected strtoul() usage with a manual
> digit-parsing fallback.  strtoul is in C89 <stdlib.h> and glibc
> provides it.  Remove the guard and the fallback loop.
> 
> Imported from GNU gettext commits ab5990532 and c1d84d656.
> 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/plural-exp.c | 44 --------------------------------------------
>  1 file changed, 44 deletions(-)
> 
> diff --git a/intl/plural-exp.c b/intl/plural-exp.c
> index c02e4b6a6d..8f910d7e7f 100644
> --- a/intl/plural-exp.c
> +++ b/intl/plural-exp.c
> @@ -25,10 +25,6 @@
>  
>  #include <plural-exp.h>
>  
> -#if (defined __GNUC__ && !(defined __APPLE_CC_ && __APPLE_CC__ > 1) && \
> -     !defined __cplusplus)					       \
> -    || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
> -
>  /* These structs are the constant expression for the germanic plural
>     form determination.  It represents the expression  "n != 1".  */
>  static const struct expression plvar =
> @@ -59,40 +55,6 @@ const struct expression GERMANIC_PLURAL =
>    }
>  };
>  
> -# define INIT_GERMANIC_PLURAL()
> -
> -#else
> -
> -/* For compilers without support for ISO C 99 struct/union initializers:
> -   Initialization at run-time.  */
> -
> -static struct expression plvar;
> -static struct expression plone;
> -struct expression GERMANIC_PLURAL;
> -
> -static void
> -init_germanic_plural (void)
> -{
> -  if (plone.val.num == 0)
> -    {
> -      plvar.nargs = 0;
> -      plvar.operation = var;
> -
> -      plone.nargs = 0;
> -      plone.operation = num;
> -      plone.val.num = 1;
> -
> -      GERMANIC_PLURAL.nargs = 2;
> -      GERMANIC_PLURAL.operation = not_equal;
> -      GERMANIC_PLURAL.val.args[0] = &plvar;
> -      GERMANIC_PLURAL.val.args[1] = &plone;
> -    }
> -}
> -
> -# define INIT_GERMANIC_PLURAL() init_germanic_plural ()
> -
> -#endif
> -
>  void
>  EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
>  			   const struct expression **pluralp,
> @@ -119,12 +81,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
>  	    ++nplurals;
>  	  if (!(*nplurals >= '0' && *nplurals <= '9'))
>  	    goto no_plural;
> -#if defined HAVE_STRTOUL || defined _LIBC
>  	  n = strtoul (nplurals, &endp, 10);
> -#else
> -	  for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
> -	    n = n * 10 + (*endp - '0');
> -#endif
>  	  if (nplurals == endp)
>  	    goto no_plural;
>  	  *npluralsp = n;
> @@ -146,7 +103,6 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
>           for `one', the plural form otherwise.  Yes, this is also what
>           English is using since English is a Germanic language.  */
>      no_plural:
> -      INIT_GERMANIC_PLURAL ();
>        *pluralp = &GERMANIC_PLURAL;
>        *npluralsp = 2;
>      }



More information about the Libc-alpha mailing list