From 023843b23be2d285d7ccce4411bdded310c65155 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Fri, 16 Nov 2007 00:10:45 +0000 Subject: [PATCH] (Fformat): When formatting an integer as float take precision into account. --- src/ChangeLog | 1 + src/editfns.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c6c2db23f12..96b0d5f5e3f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,7 @@ 2007-11-15 Andreas Schwab * editfns.c (Fformat): Correctly format EMACS_INT values. + When formatting an integer as float take precision into account. 2007-11-15 Juanma Barranquero diff --git a/src/editfns.c b/src/editfns.c index deb95198978..c4b8aa073d3 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3596,18 +3596,23 @@ usage: (format STRING &rest OBJECTS) */) /* Would get MPV otherwise, since Lisp_Int's `point' to low memory. */ else if (INTEGERP (args[n]) && *format != 's') { + thissize = 30; + /* The following loop assumes the Lisp type indicates the proper way to pass the argument. So make sure we have a flonum if the argument should be a double. */ if (*format == 'e' || *format == 'f' || *format == 'g') - args[n] = Ffloat (args[n]); + { + args[n] = Ffloat (args[n]); + if (precision[n] > 0) + thissize += precision[n]; + } else if (*format != 'd' && *format != 'o' && *format != 'x' && *format != 'i' && *format != 'X' && *format != 'c') error ("Invalid format operation %%%c", *format); - thissize = 30; if (*format == 'c') { if (! SINGLE_BYTE_CHAR_P (XINT (args[n])) -- 2.39.2