]> 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, 9 Oct 2022 07:30:42 +0000 (09:30 +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 57cf1f486d9d715cb428b16496cb71a584665dc8..7eaf47072531123fb91d33c3ddf97f2b964369ea 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 830558d5935ac285840057b12aba1d0811f15a50..e4cab22464a2babc4f15e9fe6dce7c250e7a3192 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 fb2209dc09c20b7abc1366e998a7db2488185bda..e17cff10b6a73594cabd6b8b46ed98dc95b0d3d8 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 cd5a7287bcebe4db3ce43fe0db27170e604c9d14..dfe68638b32c8b4b950025fd1f4b94b0251ff124 100644 (file)
@@ -1,4 +1,4 @@
-# intl.m4 serial 49 (gettext-0.21.1)
+# intl.m4 serial 50 (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,
@@ -242,7 +242,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 tsearch __fsetlocking])
+    stpcpy strcasecmp 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