update from texinfo
[gnulib.git] / lib / c-strtod.c
index 3d0fae9..51e996e 100644 (file)
@@ -24,8 +24,7 @@
 #include <errno.h>
 #include <locale.h>
 #include <stdlib.h>
-
-#include "xalloc.h"
+#include <string.h>
 
 #if LONG
 # define C_STRTOD c_strtold
@@ -72,7 +71,11 @@ C_STRTOD (char const *nptr, char **endptr)
 
   locale_t locale = c_locale ();
   if (!locale)
-    return 0; /* errno is set here */
+    {
+      if (endptr)
+       *endptr = (char *) nptr;
+      return 0; /* errno is set here */
+    }
 
   r = STRTOD_L (nptr, endptr, locale);
 
@@ -82,7 +85,13 @@ C_STRTOD (char const *nptr, char **endptr)
 
   if (saved_locale)
     {
-      saved_locale = xstrdup (saved_locale);
+      saved_locale = strdup (saved_locale);
+      if (saved_locale == NULL)
+       {
+         if (endptr)
+           *endptr = (char *) nptr;
+         return 0; /* errno is set here */
+       }
       setlocale (LC_NUMERIC, "C");
     }