]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: Drop argz processing outside of glibc.
authorBruno Haible <bruno@clisp.org>
Sun, 12 Apr 2020 17:29:36 +0000 (19:29 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 12 Apr 2020 17:29:36 +0000 (19:29 +0200)
* gettext-runtime/intl/l10nflist.c: Don't test HAVE_ARGZ_H.
(__argz_count, __argz_stringify, __argz_next): Remove definitions.
(_nl_make_l10nflist): Simplify !_LIBC case.
* gettext-runtime/m4/intl.m4 (gt_INTL_SUBDIR_CORE): Don't test for <argz.h>,
argz_count, argz_stringify, argz_next.

gettext-runtime/intl/l10nflist.c
gettext-runtime/m4/intl.m4

index 7d3c9690c12337b9e882acc2f2ecd7f8b24d9ab1..5add7ad8003e195c1d784a556dc3ff95d4f59169 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <string.h>
 
-#if defined _LIBC || defined HAVE_ARGZ_H
+#if defined _LIBC
 # include <argz.h>
 #endif
 #include <ctype.h>
@@ -67,77 +67,6 @@ static char *stpcpy (char *dest, const char *src);
 # include "filename.h"
 #endif
 
-/* Define function which are usually not available.  */
-
-#if defined HAVE_ARGZ_COUNT
-# undef __argz_count
-# define __argz_count argz_count
-#else
-/* Returns the number of strings in ARGZ.  */
-static size_t
-argz_count__ (const char *argz, size_t len)
-{
-  size_t count = 0;
-  while (len > 0)
-    {
-      size_t part_len = strlen (argz);
-      argz += part_len + 1;
-      len -= part_len + 1;
-      count++;
-    }
-  return count;
-}
-# undef __argz_count
-# define __argz_count(argz, len) argz_count__ (argz, len)
-#endif /* !_LIBC && !HAVE_ARGZ_COUNT */
-
-#if defined HAVE_ARGZ_STRINGIFY
-# undef __argz_stringify
-# define __argz_stringify argz_stringify
-#else
-/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
-   except the last into the character SEP.  */
-static void
-argz_stringify__ (char *argz, size_t len, int sep)
-{
-  while (len > 0)
-    {
-      size_t part_len = strlen (argz);
-      argz += part_len;
-      len -= part_len + 1;
-      if (len > 0)
-       *argz++ = sep;
-    }
-}
-# undef __argz_stringify
-# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
-#endif /* !_LIBC && !HAVE_ARGZ_STRINGIFY */
-
-#ifdef _LIBC
-#elif defined HAVE_ARGZ_NEXT
-# undef __argz_next
-# define __argz_next argz_next
-#else
-static char *
-argz_next__ (char *argz, size_t argz_len, const char *entry)
-{
-  if (entry)
-    {
-      if (entry < argz + argz_len)
-        entry = strchr (entry, '\0') + 1;
-
-      return entry >= argz + argz_len ? NULL : (char *) entry;
-    }
-  else
-    if (argz_len > 0)
-      return argz;
-    else
-      return 0;
-}
-# undef __argz_next
-# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry)
-#endif /* !_LIBC && !HAVE_ARGZ_NEXT */
-
 /* Return number of bits set in X.  */
 #ifndef ARCH_POP
 static inline int
@@ -196,7 +125,9 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
   if (dirlist_len > 0)
     {
       memcpy (cp, dirlist, dirlist_len);
+#ifdef _LIBC
       __argz_stringify (cp, dirlist_len, PATH_SEPARATOR);
+#endif
       cp += dirlist_len;
       cp[-1] = '/';
     }
@@ -253,7 +184,11 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
       return retval;
     }
 
+#ifdef _LIBC
   dirlist_count = (dirlist_len > 0 ? __argz_count (dirlist, dirlist_len) : 1);
+#else
+  dirlist_count = 1;
+#endif
 
   /* Allocate a new loaded_l10nfile.  */
   retval =
@@ -298,6 +233,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
     if ((cnt & ~mask) == 0
        && !((cnt & XPG_CODESET) != 0 && (cnt & XPG_NORM_CODESET) != 0))
       {
+#ifdef _LIBC
        if (dirlist_count > 1)
          {
            /* Iterate over all elements of the DIRLIST.  */
@@ -312,6 +248,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
                                      1);
          }
        else
+#endif
          retval->successor[entries++]
            = _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len,
                                  cnt, language, territory, codeset,
index 0e64adbf7286de4578fa29ab9e74638e52305b75..0b382b71a1ec709d00a2b0fe3c3c3253b3648c0c 100644 (file)
@@ -1,4 +1,4 @@
-# intl.m4 serial 39 (gettext-0.20.2)
+# intl.m4 serial 40 (gettext-0.20.2)
 dnl Copyright (C) 1995-2014, 2016-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -237,10 +237,9 @@ AC_DEFUN([gt_INTL_SUBDIR_CORE],
     [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1],
        [Define to 1 if the compiler understands __builtin_expect.])])
 
-  AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h])
+  AC_CHECK_HEADERS([inttypes.h limits.h unistd.h sys/param.h])
   AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \
-    stpcpy strcasecmp strdup strtoul tsearch argz_count argz_stringify \
-    argz_next __fsetlocking])
+    stpcpy strcasecmp strdup strtoul tsearch __fsetlocking])
 
   dnl Use the *_unlocked functions only if they are declared.
   dnl (because some of them were defined without being declared in Solaris