From: Chong Yidong Date: Sat, 13 Mar 2010 19:54:29 +0000 (-0500) Subject: Fix bug in `format' (Bug#5710). X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~744 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cef3058fee82cbd5b7dc3112250f4735c76f8fbf;p=emacs.git Fix bug in `format' (Bug#5710). * editfns.c (Fformat): Account for string precision when computing field width (Bug#5710). --- diff --git a/src/ChangeLog b/src/ChangeLog index 37a4cdb1b10..da4e336b0ae 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-03-13 Andreas Politz (tiny change) + + * editfns.c (Fformat): Account for string precision when computing + field width (Bug#5710). + 2010-03-12 Chong Yidong * xfns.c (Fx_create_frame): Set default to Qright. diff --git a/src/editfns.c b/src/editfns.c index 093f141bff2..9f30ea06411 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3782,7 +3782,11 @@ usage: (format STRING &rest OBJECTS) */) to be as large as is calculated here. Easy check for the case PRECISION = 0. */ thissize = precision[n] ? CONVERTED_BYTE_SIZE (multibyte, args[n]) : 0; + /* The precision also constrains how much of the argument + string will finally appear (Bug#5710). */ actual_width = lisp_string_width (args[n], -1, NULL, NULL); + if (precision[n] != -1) + actual_width = min(actual_width,precision[n]); } /* Would get MPV otherwise, since Lisp_Int's `point' to low memory. */ else if (INTEGERP (args[n]) && *format != 's')