From: Andreas Schwab Date: Fri, 16 Nov 2007 00:10:00 +0000 (+0000) Subject: (Fformat): When formatting an integer as float take precision into account. X-Git-Tag: emacs-pretest-23.0.90~9711 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8875d2c00e62b6cef44e2ca19627427103512dd9;p=emacs.git (Fformat): When formatting an integer as float take precision into account. --- diff --git a/src/ChangeLog b/src/ChangeLog index 6c22f16b189..3a74e58061e 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. * keyboard.c (Fevent_symbol_parse_modifiers): Fix declaration. diff --git a/src/editfns.c b/src/editfns.c index f049aa67c30..eaee2bfadfa 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3594,18 +3594,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]))