[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ftoastr: new module, for lossless conversion of floats to sh
From: |
Paul Eggert |
Subject: |
Re: [PATCH] ftoastr: new module, for lossless conversion of floats to short strings |
Date: |
Thu, 18 Nov 2010 16:53:37 -0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101027 Thunderbird/3.0.10 |
On 11/18/10 13:59, Paul Eggert wrote:
> Something
> like the following patch should address that issue, I expect.
I installed this slightly-different patch:
>From a632f45b2e5ce87e0aad94a39c658dac1a29fcd2 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Thu, 18 Nov 2010 16:49:05 -0800
Subject: [PATCH] ftoastr: port to hosts lacking strtof and strtold
Problem reported by Bruno Haible in
<http://lists.gnu.org/archive/html/bug-gnulib/2010-11/msg00242.html>.
* lib/ftoastr.c (STRTOF): Define to strtod if in a pre-C99
environment and strtold (and presumably strtof) are not available.
* modules/ftoastr (Files): Add m4/c-strtod.m4.
(configure.ac): Require gl_C99_STRTOLD.
---
ChangeLog | 10 ++++++++++
lib/ftoastr.c | 8 ++++++++
modules/ftoastr | 2 ++
3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0ab0af3..c923b68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-11-18 Paul Eggert <address@hidden>
+
+ ftoastr: port to hosts lacking strtof and strtold
+ Problem reported by Bruno Haible in
+ <http://lists.gnu.org/archive/html/bug-gnulib/2010-11/msg00242.html>.
+ * lib/ftoastr.c (STRTOF): Define to strtod if in a pre-C99
+ environment and strtold (and presumably strtof) are not available.
+ * modules/ftoastr (Files): Add m4/c-strtod.m4.
+ (configure.ac): Require gl_C99_STRTOLD.
+
2010-11-17 Paul Eggert <address@hidden>
intprops: new macro INT_BITS_STRLEN_BOUND
diff --git a/lib/ftoastr.c b/lib/ftoastr.c
index 25e0705..ddc5251 100644
--- a/lib/ftoastr.c
+++ b/lib/ftoastr.c
@@ -48,6 +48,14 @@
# define STRTOF strtof
#endif
+/* On pre-C99 hosts, approximate strtof and strtold with strtod. This
+ may generate one or two extra digits, but that's better than not
+ working at all. Assume that strtof works if strtold does. */
+#if LENGTH != 2 && ! HAVE_C99_STRTOLD
+# undef STRTOF
+# define STRTOF strtod
+#endif
+
int
FTOASTR (char *buf, size_t bufsize, int flags, int width, FLOAT x)
{
diff --git a/modules/ftoastr b/modules/ftoastr
index fbc0cba..64d0a77 100644
--- a/modules/ftoastr
+++ b/modules/ftoastr
@@ -6,11 +6,13 @@ lib/ftoastr.h
lib/ftoastr.c
lib/dtoastr.c
lib/ldtoastr.c
+m4/c-strtod.m4
Depends-on:
intprops
configure.ac:
+AC_REQUIRE([gl_C99_STRTOLD])
Makefile.am:
lib_SOURCES += ftoastr.h ftoastr.c dtoastr.c ldtoastr.c
--
1.7.2