]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: Assume strdup exists.
authorBruno Haible <bruno@clisp.org>
Sun, 20 Jun 2021 01:43:50 +0000 (03:43 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 20 Jun 2021 01:43:50 +0000 (03:43 +0200)
* gettext-runtime/intl/bindtextdom.c (set_binding_values): Assume HAVE_STRDUP
to be 1.
* gettext-runtime/intl/finddomain.c (_nl_find_domain): Likewise.
* gettext-runtime/intl/textdomain.c (TEXTDOMAIN): Likewise.
* gettext-runtime/m4/intl.m4 (gt_INTL_SUBDIR_CORE): Don't test for strdup.

gettext-runtime/intl/bindtextdom.c
gettext-runtime/intl/finddomain.c
gettext-runtime/intl/textdomain.c
gettext-runtime/m4/intl.m4

index 81674eed5e4c2d4e94eacc5249ee1c84b58a6f15..62bd418805a56d0dc8ae64b151d10059303131f9 100644 (file)
@@ -133,16 +133,7 @@ set_binding_values (const char *domainname,
                  if (strcmp (dirname, _nl_default_dirname) == 0)
                    result = (char *) _nl_default_dirname;
                  else
-                   {
-#if defined _LIBC || defined HAVE_STRDUP
-                     result = strdup (dirname);
-#else
-                     size_t len = strlen (dirname) + 1;
-                     result = (char *) malloc (len);
-                     if (__builtin_expect (result != NULL, 1))
-                       memcpy (result, dirname, len);
-#endif
-                   }
+                   result = strdup (dirname);
 
                  if (__builtin_expect (result != NULL, 1))
                    {
@@ -212,15 +203,7 @@ set_binding_values (const char *domainname,
              char *result = binding->codeset;
              if (result == NULL || strcmp (codeset, result) != 0)
                {
-#if defined _LIBC || defined HAVE_STRDUP
                  result = strdup (codeset);
-#else
-                 size_t len = strlen (codeset) + 1;
-                 result = (char *) malloc (len);
-                 if (__builtin_expect (result != NULL, 1))
-                   memcpy (result, codeset, len);
-#endif
-
                  if (__builtin_expect (result != NULL, 1))
                    {
                      free (binding->codeset);
@@ -281,18 +264,9 @@ set_binding_values (const char *domainname,
                dirname = _nl_default_dirname;
              else
                {
-                 char *result;
-#if defined _LIBC || defined HAVE_STRDUP
-                 result = strdup (dirname);
+                 char *result = strdup (dirname);
                  if (__builtin_expect (result == NULL, 0))
                    goto failed_dirname;
-#else
-                 size_t len = strlen (dirname) + 1;
-                 result = (char *) malloc (len);
-                 if (__builtin_expect (result == NULL, 0))
-                   goto failed_dirname;
-                 memcpy (result, dirname, len);
-#endif
                  dirname = result;
                }
            }
@@ -335,19 +309,9 @@ set_binding_values (const char *domainname,
 
          if (codeset != NULL)
            {
-             char *result;
-
-#if defined _LIBC || defined HAVE_STRDUP
-             result = strdup (codeset);
+             char *result = strdup (codeset);
              if (__builtin_expect (result == NULL, 0))
                goto failed_codeset;
-#else
-             size_t len = strlen (codeset) + 1;
-             result = (char *) malloc (len);
-             if (__builtin_expect (result == NULL, 0))
-               goto failed_codeset;
-             memcpy (result, codeset, len);
-#endif
              codeset = result;
            }
          *codesetp = codeset;
index afc9201e08ad4f058f84ad9309a9462a17d54cf3..e54b7346fbc4793340594eff979e1c88dd8333e9 100644 (file)
@@ -136,18 +136,9 @@ _nl_find_domain (const char *dirname,
   alias_value = _nl_expand_alias (locale);
   if (alias_value != NULL)
     {
-#if defined _LIBC || defined HAVE_STRDUP
       locale = strdup (alias_value);
       if (locale == NULL)
        return NULL;
-#else
-      size_t len = strlen (alias_value) + 1;
-      locale = (char *) malloc (len);
-      if (locale == NULL)
-       return NULL;
-
-      memcpy (locale, alias_value, len);
-#endif
     }
 
   /* Now we determine the single parts of the locale name.  First
index a509aafd46054c2b827235b32ae6ca048ba9ae32..7e1569fc141024fc7447695bdc6bee9124e1740b 100644 (file)
@@ -87,18 +87,10 @@ TEXTDOMAIN (const char *domainname)
     new_domain = old_domain;
   else
     {
-      /* If the following malloc fails `_nl_current_default_domain'
+      /* If the following strdup fails '_nl_current_default_domain'
         will be NULL.  This value will be returned and so signals we
-        are out of core.  */
-#if defined _LIBC || defined HAVE_STRDUP
+        are out of memory.  */
       new_domain = strdup (domainname);
-#else
-      size_t len = strlen (domainname) + 1;
-      new_domain = (char *) malloc (len);
-      if (new_domain != NULL)
-       memcpy (new_domain, domainname, len);
-#endif
-
       if (new_domain != NULL)
        _nl_current_default_domain = new_domain;
     }
index 3a47f9b9c07b0b8fdf74727b88bf145f4c09ef35..9a5f315b4eb2ce5fc6cf75085f92ed7721140811 100644 (file)
@@ -1,4 +1,4 @@
-# intl.m4 serial 51 (gettext-0.21.1)
+# intl.m4 serial 52 (gettext-0.21.1)
 dnl Copyright (C) 1995-2014, 2016-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -56,7 +56,7 @@ AC_DEFUN([gt_INTL_SUBDIR_CORE],
 
   AC_CHECK_HEADERS([inttypes.h unistd.h sys/param.h])
   AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \
-    stpcpy strcasecmp strdup strtoul uselocale __fsetlocking])
+    stpcpy strcasecmp strtoul uselocale __fsetlocking])
 
   dnl Use the *_unlocked functions only if they are declared.
   dnl (because some of them were defined without being declared in Solaris