diff options
| author | Kenichi Handa | 1998-03-04 07:41:41 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-03-04 07:41:41 +0000 |
| commit | f49a2d745257638152d17a75320c61c5109cab6f (patch) | |
| tree | 3ebcad54722f76c3554a07e7f5ccd0c622e62596 /src | |
| parent | e515b0a97ec150d54996700f9d6fffae5d1420f1 (diff) | |
| download | emacs-f49a2d745257638152d17a75320c61c5109cab6f.tar.gz emacs-f49a2d745257638152d17a75320c61c5109cab6f.zip | |
(Fformat): Format multibyte characters by "%c"
correctly. Handle padding for multibyte characters correctly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/editfns.c b/src/editfns.c index 9718c5aa153..5ae0c28be6d 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2299,7 +2299,17 @@ Use %% to put a single % into the output.") | |||
| 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') |
| @@ -2376,16 +2386,17 @@ Use %% to put a single % into the output.") | |||
| 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++ = ' '; |