comparison src/editfns.c @ 42484:717eee813b2c

(Fformat): Update thissize from field_width based on the actual width, in the string case.
author Richard M. Stallman <rms@gnu.org>
date Wed, 02 Jan 2002 19:56:50 +0000
parents 37b724c77b98
children 63639e690611
comparison
equal deleted inserted replaced
42483:52015642068d 42484:717eee813b2c
3215 n = 0; 3215 n = 0;
3216 while (format != end) 3216 while (format != end)
3217 if (*format++ == '%') 3217 if (*format++ == '%')
3218 { 3218 {
3219 int thissize = 0; 3219 int thissize = 0;
3220 int actual_width = 0;
3220 unsigned char *this_format_start = format - 1; 3221 unsigned char *this_format_start = format - 1;
3221 int field_width, precision; 3222 int field_width, precision;
3222 3223
3223 /* General format specifications look like 3224 /* General format specifications look like
3224 3225
3295 { 3296 {
3296 string: 3297 string:
3297 if (*format != 's' && *format != 'S') 3298 if (*format != 's' && *format != 'S')
3298 error ("Format specifier doesn't match argument type"); 3299 error ("Format specifier doesn't match argument type");
3299 thissize = CONVERTED_BYTE_SIZE (multibyte, args[n]); 3300 thissize = CONVERTED_BYTE_SIZE (multibyte, args[n]);
3301 actual_width = lisp_string_width (args[n], -1, NULL, NULL);
3300 } 3302 }
3301 /* Would get MPV otherwise, since Lisp_Int's `point' to low memory. */ 3303 /* Would get MPV otherwise, since Lisp_Int's `point' to low memory. */
3302 else if (INTEGERP (args[n]) && *format != 's') 3304 else if (INTEGERP (args[n]) && *format != 's')
3303 { 3305 {
3304 /* The following loop assumes the Lisp type indicates 3306 /* The following loop assumes the Lisp type indicates
3348 } 3350 }
3349 args[n] = tem; 3351 args[n] = tem;
3350 goto string; 3352 goto string;
3351 } 3353 }
3352 3354
3353 thissize = max (field_width, thissize); 3355 thissize += max (0, field_width - actual_width);
3354 total += thissize + 4; 3356 total += thissize + 4;
3355 } 3357 }
3356 3358
3357 /* Now we can no longer jump to retry. 3359 /* Now we can no longer jump to retry.
3358 TOTAL and LONGEST_FORMAT are known for certain. */ 3360 TOTAL and LONGEST_FORMAT are known for certain. */