# HG changeset patch # User Chong Yidong # Date 1268510069 18000 # Node ID 969a1a50d14cb32ce51fc55bcff511ef571453ce # Parent 1b280b2e1b75096321bd85032e0e81686098f50b Fix bug in `format' (Bug#5710). * editfns.c (Fformat): Account for string precision when computing field width (Bug#5710). diff -r 1b280b2e1b75 -r 969a1a50d14c src/ChangeLog --- a/src/ChangeLog Sat Mar 13 10:29:13 2010 -0500 +++ b/src/ChangeLog Sat Mar 13 14:54:29 2010 -0500 @@ -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 -r 1b280b2e1b75 -r 969a1a50d14c src/editfns.c --- a/src/editfns.c Sat Mar 13 10:29:13 2010 -0500 +++ b/src/editfns.c Sat Mar 13 14:54:29 2010 -0500 @@ -3782,7 +3782,11 @@ 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')