comparison src/editfns.c @ 21064:90bdbe2754c8

(Fformat): Format multibyte characters by "%c" correctly. Handle padding for multibyte characters correctly.
author Kenichi Handa <handa@m17n.org>
date Wed, 04 Mar 1998 07:41:41 +0000
parents eea2c6235bd1
children ea520c42a342
comparison
equal deleted inserted replaced
21063:44845df088bc 21064:90bdbe2754c8
2297 So make sure we have a flonum if the argument should 2297 So make sure we have a flonum if the argument should
2298 be a double. */ 2298 be a double. */
2299 if (*format == 'e' || *format == 'f' || *format == 'g') 2299 if (*format == 'e' || *format == 'f' || *format == 'g')
2300 args[n] = Ffloat (args[n]); 2300 args[n] = Ffloat (args[n]);
2301 #endif 2301 #endif
2302 thissize = 30; 2302 thissize = 30;
2303 if (*format == 'c' && ! SINGLE_BYTE_CHAR_P (XINT (args[n])))
2304 {
2305 if (! multibyte)
2306 {
2307 multibyte = 1;
2308 goto retry;
2309 }
2310 args[n] = Fchar_to_string (args[n]);
2311 thissize = XSTRING (args[n])->size_byte;
2312 }
2303 } 2313 }
2304 #ifdef LISP_FLOAT_TYPE 2314 #ifdef LISP_FLOAT_TYPE
2305 else if (FLOATP (args[n]) && *format != 's') 2315 else if (FLOATP (args[n]) && *format != 's')
2306 { 2316 {
2307 if (! (*format == 'e' || *format == 'f' || *format == 'g')) 2317 if (! (*format == 'e' || *format == 'f' || *format == 'g'))
2374 2384
2375 ++n; 2385 ++n;
2376 2386
2377 if (STRINGP (args[n])) 2387 if (STRINGP (args[n]))
2378 { 2388 {
2379 int padding, nbytes; 2389 int padding, nbytes, width;
2380 2390
2381 nbytes = copy_text (XSTRING (args[n])->data, p, 2391 nbytes = copy_text (XSTRING (args[n])->data, p,
2382 XSTRING (args[n])->size_byte, 2392 XSTRING (args[n])->size_byte,
2383 STRING_MULTIBYTE (args[n]), multibyte); 2393 STRING_MULTIBYTE (args[n]), multibyte);
2394 width = strwidth (p, nbytes);
2384 p += nbytes; 2395 p += nbytes;
2385 nchars += XSTRING (args[n])->size; 2396 nchars += XSTRING (args[n])->size;
2386 2397
2387 /* If spec requires it, pad on right with spaces. */ 2398 /* If spec requires it, pad on right with spaces. */
2388 padding = minlen - XSTRING (args[n])->size; 2399 padding = minlen - width;
2389 while (padding-- > 0) 2400 while (padding-- > 0)
2390 { 2401 {
2391 *p++ = ' '; 2402 *p++ = ' ';
2392 nchars++; 2403 nchars++;
2393 } 2404 }