[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
patch to make c_strtod reentrant on glibc platforms
From: |
Paul Eggert |
Subject: |
patch to make c_strtod reentrant on glibc platforms |
Date: |
Mon, 12 Jul 2004 10:53:38 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
I installed the following patch into my private copy of coreutils.
2004-07-12 Paul Eggert <address@hidden>
* lib/c-strtod.c (STRTOD_L): New macro.
(C_STRTOD) [defined LC_ALL_MASK]: Use it, so that the
code is reentrant on platforms that have strtod_l.
* m4/c-strtod.m4 (gl_C_STRTOD): Add gl_USE_SYSTEM_EXTENSIONS.
Index: lib/c-strtod.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/c-strtod.c,v
retrieving revision 1.4
diff -p -u -r1.4 c-strtod.c
--- lib/c-strtod.c 12 Jul 2004 06:30:36 -0000 1.4
+++ lib/c-strtod.c 12 Jul 2004 17:49:35 -0000
@@ -32,9 +32,11 @@
#if LONG
# define C_STRTOD c_strtold
# define DOUBLE long double
+# define STRTOD_L strtold_l
#else
# define C_STRTOD c_strtod
# define DOUBLE double
+# define STRTOD_L strtod_l
#endif
/* c_strtold falls back on strtod if strtold isn't declared. */
@@ -48,6 +50,15 @@ DOUBLE
C_STRTOD (char const *nptr, char **endptr)
{
DOUBLE r;
+
+#ifdef LC_ALL_MASK
+
+ locale_t c_locale = newlocale (LC_ALL_MASK, "C", 0);
+ r = STRTOD_L (nptr, endptr, c_locale);
+ freelocale (c_locale);
+
+#else
+
char *saved_locale = setlocale (LC_NUMERIC, NULL);
if (saved_locale)
@@ -63,6 +74,8 @@ C_STRTOD (char const *nptr, char **endpt
setlocale (LC_NUMERIC, saved_locale);
free (saved_locale);
}
+
+#endif
return r;
}
Index: m4/c-strtod.m4
===================================================================
RCS file: /home/eggert/coreutils/cu/m4/c-strtod.m4,v
retrieving revision 1.1
diff -p -u -r1.1 c-strtod.m4
--- m4/c-strtod.m4 12 Jul 2004 06:39:23 -0000 1.1
+++ m4/c-strtod.m4 12 Jul 2004 06:56:33 -0000
@@ -1,4 +1,4 @@
-# c-strtod.m4 serial 1
+# c-strtod.m4 serial 2
# Copyright (C) 2004 Free Software Foundation, Inc.
@@ -21,6 +21,7 @@
AC_DEFUN([gl_C_STRTOD],
[
dnl Prerequisites of lib/c-strtod.c.
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
:
])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- patch to make c_strtod reentrant on glibc platforms,
Paul Eggert <=