From 925bf02167741d4c0e398e0f5907bbcecb4b4de5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 18 Nov 2010 21:30:29 -0800 Subject: [PATCH] ftoastr: depend on snprintf, improve comments * lib/ftoastr.c: Also mention Loitsch's draft. * lib/ftoastr.h: Require WIDTH to be nonnegative. This isn't needed in the current implementation, but it might simplify speeding up the code later. * modules/ftoastr: Depend on snprintf; this improves portability. Suggested by Bruno Haible in the same email. --- ChangeLog | 8 ++++++++ lib/ftoastr.c | 3 ++- lib/ftoastr.h | 4 ++-- modules/ftoastr | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1043bd70..217fbba01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2010-11-18 Paul Eggert + ftoastr: depend on snprintf, improve comments + * lib/ftoastr.c: Also mention Loitsch's draft. + * lib/ftoastr.h: Require WIDTH to be nonnegative. This isn't + needed in the current implementation, but it might simplify + speeding up the code later. + * modules/ftoastr: Depend on snprintf; this improves portability. + Suggested by Bruno Haible in the same email. + ftoastr: port to hosts lacking strtof and strtold Problem reported by Bruno Haible in . diff --git a/lib/ftoastr.c b/lib/ftoastr.c index ddc525168..f74740088 100644 --- a/lib/ftoastr.c +++ b/lib/ftoastr.c @@ -64,7 +64,8 @@ FTOASTR (char *buf, size_t bufsize, int flags, int width, FLOAT x) Florian Loitsch, Printing floating-point numbers quickly and accurately with integers. ACM SIGPLAN notices 46, 6 (June 2010), 233-243 - . */ + ; also see the + 2010-03-21 draft . */ char format[sizeof "%-+ 0*.*Lg"]; FLOAT abs_x = x < 0 ? -x : x; diff --git a/lib/ftoastr.h b/lib/ftoastr.h index 4c4f890cd..fd7a802db 100644 --- a/lib/ftoastr.h +++ b/lib/ftoastr.h @@ -26,8 +26,8 @@ /* Store into BUF (of size BUFSIZE) an accurate minimal-precision string representation of a floating point number. FLAGS affect the formatting of the number. Pad the output string with spaces as - necessary to width WIDTH bytes, in the style of printf. X is the - floating-point number to be converted. + necessary to width WIDTH bytes, in the style of printf. WIDTH must + be nonnegative. X is the floating-point number to be converted. Return the number of bytes stored into BUF, not counting the terminating null. However, do not overrun BUF: if BUF is too diff --git a/modules/ftoastr b/modules/ftoastr index 64d0a7790..862fb1aa2 100644 --- a/modules/ftoastr +++ b/modules/ftoastr @@ -10,6 +10,7 @@ m4/c-strtod.m4 Depends-on: intprops +snprintf configure.ac: AC_REQUIRE([gl_C99_STRTOLD]) -- 2.11.0