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

Message ID 20260505151142.1453614-4-avinal.xlvii@gmail.com (mailing list archive)
State New
Headers
Series intl: Remove dead code, sync with GNU gettext |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686

Commit Message

Avinal Kumar May 5, 2026, 3:11 p.m. UTC
  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>
---
 intl/plural-exp.c | 44 --------------------------------------------
 1 file changed, 44 deletions(-)
  

Patch

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;
     }