From: Bruno Haible Date: Sun, 12 Apr 2020 17:29:36 +0000 (+0200) Subject: intl: Drop argz processing outside of glibc. X-Git-Tag: v0.21~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95a60ed2265e4eccc2380eab522c84f2cf93709d;p=thirdparty%2Fgettext.git intl: Drop argz processing outside of glibc. * 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_count, argz_stringify, argz_next. --- diff --git a/gettext-runtime/intl/l10nflist.c b/gettext-runtime/intl/l10nflist.c index 7d3c9690c..5add7ad80 100644 --- a/gettext-runtime/intl/l10nflist.c +++ b/gettext-runtime/intl/l10nflist.c @@ -27,7 +27,7 @@ #include -#if defined _LIBC || defined HAVE_ARGZ_H +#if defined _LIBC # include #endif #include @@ -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, diff --git a/gettext-runtime/m4/intl.m4 b/gettext-runtime/m4/intl.m4 index 0e64adbf7..0b382b71a 100644 --- a/gettext-runtime/m4/intl.m4 +++ b/gettext-runtime/m4/intl.m4 @@ -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