summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2009-01-23 23:41:16 +0100
committerBruno Haible <bruno@clisp.org>2009-01-23 23:41:16 +0100
commit5965a9b1d0011a0340b57e1faa0b8a3f7997c519 (patch)
treee08d76fba9b8c9c66f0abd402b2838a9da64ebd8
parent9977632d05c1d68363901d6a4f4743ce06f153d2 (diff)
downloadgnulib-5965a9b1d0011a0340b57e1faa0b8a3f7997c519.tar.gz
Change c_strtod, c_strtold to no longer call xalloc_die().
-rw-r--r--ChangeLog11
-rw-r--r--NEWS9
-rw-r--r--doc/c-strtod.texi3
-rw-r--r--lib/c-strtod.c13
-rw-r--r--modules/c-strtod2
-rw-r--r--modules/c-strtold2
6 files changed, 32 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 66a6632c26..42c3aca0aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-01-23 Bruno Haible <bruno@clisp.org>
+
+ Make c-strtod, c-strtold usable in libraries.
+ * lib/c-strtod.c: Include string.h instead of xalloc.h.
+ (C_STRTOD): Call strdup instead of xstrdup.
+ * modules/c-strtod (Depends-on): Add strdup-posix, remove xalloc.
+ * modules/c-strtold (Depends-on): Likewise.
+ * doc/c-strtod.texi: Remove the sentence mentioning xalloc_die.
+ * NEWS: Mention the change.
+ Reported by Michael Gold <mgold@ncf.ca>.
+
2009-01-23 Jim Meyering <meyering@redhat.com>
c-strtod: when ENDPTR is non-NULL, set *ENDPTR in new failure path
diff --git a/NEWS b/NEWS
index 650c4161fb..bf48451f5b 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,15 @@ User visible incompatible changes
Date Modules Changes
+2009-01-22 c-strtod This function no longer calls xalloc_die(). If
+ c-strtold you want to exit the program in case of out-of-
+ memory, the calling function needs to arrange
+ for it, like this:
+ errno = 0;
+ val = c_strtod (...);
+ if (val == 0 && errno == ENOMEM)
+ xalloc_die ();
+
2009-01-17 relocatable-prog In the Makefile.am or Makefile.in, you now also
need to set RELOCATABLE_STRIP = :.
diff --git a/doc/c-strtod.texi b/doc/c-strtod.texi
index 486b6e0b69..9d22e93603 100644
--- a/doc/c-strtod.texi
+++ b/doc/c-strtod.texi
@@ -23,6 +23,5 @@ In particular, only a period @samp{.} is accepted as decimal point, even
when the current locale's notion of decimal point is a comma @samp{,},
and no characters outside the basic character set are accepted.
-This function aborts via @code{xalloc_die} if it cannot allocate memory.
-On platforms without @code{strtod_l}, it is not safe for use in
+On platforms without @code{strtod_l}, this function is not safe for use in
multi-threaded applications since it calls @code{setlocale}.
diff --git a/lib/c-strtod.c b/lib/c-strtod.c
index 77e5aaf80d..9723e0b788 100644
--- a/lib/c-strtod.c
+++ b/lib/c-strtod.c
@@ -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
@@ -74,7 +73,7 @@ C_STRTOD (char const *nptr, char **endptr)
if (!locale)
{
if (endptr)
- *endptr = nptr;
+ *endptr = nptr;
return 0; /* errno is set here */
}
@@ -86,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 = nptr;
+ return 0; /* errno is set here */
+ }
setlocale (LC_NUMERIC, "C");
}
diff --git a/modules/c-strtod b/modules/c-strtod
index f82a98863e..7212e09b02 100644
--- a/modules/c-strtod
+++ b/modules/c-strtod
@@ -8,7 +8,7 @@ m4/c-strtod.m4
Depends-on:
extensions
-xalloc
+strdup-posix
configure.ac:
gl_C_STRTOD
diff --git a/modules/c-strtold b/modules/c-strtold
index d9d5a18ce1..95439b1207 100644
--- a/modules/c-strtold
+++ b/modules/c-strtold
@@ -9,7 +9,7 @@ m4/c-strtod.m4
Depends-on:
extensions
-xalloc
+strdup-posix
configure.ac:
gl_C_STRTOLD