diff options
| author | Kenichi Handa | 1998-01-30 11:05:41 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-01-30 11:05:41 +0000 |
| commit | 8d6179dc27330de09dff25ec54e21d57ac7db6e4 (patch) | |
| tree | dec8b0ec977e6b33514bc66e6272026a6468e3f3 /src | |
| parent | 4031e2bf0af27749dbbcace7ce0edad0bd34bcf7 (diff) | |
| download | emacs-8d6179dc27330de09dff25ec54e21d57ac7db6e4.tar.gz emacs-8d6179dc27330de09dff25ec54e21d57ac7db6e4.zip | |
(CONVERTED_BYTE_SIZE): Fix the logic.
(Fformat): Update the variable MULTIBYTE according to the result
of Fprin1_to_string. Free BUF after making Lisp string from it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/editfns.c b/src/editfns.c index 6f67b2b9e33..54171a19ccf 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2166,9 +2166,9 @@ DEFUN ("current-message", Fcurrent_message, Scurrent_message, 0, 0, 0, | |||
| 2166 | 2166 | ||
| 2167 | #define CONVERTED_BYTE_SIZE(MULTIBYTE, STRING) \ | 2167 | #define CONVERTED_BYTE_SIZE(MULTIBYTE, STRING) \ |
| 2168 | (((MULTIBYTE) && ! STRING_MULTIBYTE (STRING)) \ | 2168 | (((MULTIBYTE) && ! STRING_MULTIBYTE (STRING)) \ |
| 2169 | ? XSTRING (STRING)->size_byte \ | 2169 | ? count_size_as_multibyte (XSTRING (STRING)->data, \ |
| 2170 | : count_size_as_multibyte (XSTRING (STRING)->data, \ | 2170 | XSTRING (STRING)->size_byte) \ |
| 2171 | XSTRING (STRING)->size_byte)) | 2171 | : XSTRING (STRING)->size_byte) |
| 2172 | 2172 | ||
| 2173 | DEFUN ("format", Fformat, Sformat, 1, MANY, 0, | 2173 | DEFUN ("format", Fformat, Sformat, 1, MANY, 0, |
| 2174 | "Format a string out of a control-string and arguments.\n\ | 2174 | "Format a string out of a control-string and arguments.\n\ |
| @@ -2199,6 +2199,7 @@ Use %% to put a single % into the output.") | |||
| 2199 | int multibyte = 0; | 2199 | int multibyte = 0; |
| 2200 | unsigned char *this_format; | 2200 | unsigned char *this_format; |
| 2201 | int longest_format = 0; | 2201 | int longest_format = 0; |
| 2202 | Lisp_Object val; | ||
| 2202 | 2203 | ||
| 2203 | extern char *index (); | 2204 | extern char *index (); |
| 2204 | 2205 | ||
| @@ -2246,6 +2247,8 @@ Use %% to put a single % into the output.") | |||
| 2246 | /* For `S', prin1 the argument and then treat like a string. */ | 2247 | /* For `S', prin1 the argument and then treat like a string. */ |
| 2247 | register Lisp_Object tem; | 2248 | register Lisp_Object tem; |
| 2248 | tem = Fprin1_to_string (args[n], Qnil); | 2249 | tem = Fprin1_to_string (args[n], Qnil); |
| 2250 | if (STRING_MULTIBYTE (tem)) | ||
| 2251 | multibyte = 1; | ||
| 2249 | args[n] = tem; | 2252 | args[n] = tem; |
| 2250 | goto string; | 2253 | goto string; |
| 2251 | } | 2254 | } |
| @@ -2287,6 +2290,8 @@ Use %% to put a single % into the output.") | |||
| 2287 | /* Anything but a string, convert to a string using princ. */ | 2290 | /* Anything but a string, convert to a string using princ. */ |
| 2288 | register Lisp_Object tem; | 2291 | register Lisp_Object tem; |
| 2289 | tem = Fprin1_to_string (args[n], Qt); | 2292 | tem = Fprin1_to_string (args[n], Qt); |
| 2293 | if (STRING_MULTIBYTE (tem)) | ||
| 2294 | multibyte = 1; | ||
| 2290 | args[n] = tem; | 2295 | args[n] = tem; |
| 2291 | goto string; | 2296 | goto string; |
| 2292 | } | 2297 | } |
| @@ -2385,11 +2390,13 @@ Use %% to put a single % into the output.") | |||
| 2385 | *p++ = *format++, nchars++; | 2390 | *p++ = *format++, nchars++; |
| 2386 | } | 2391 | } |
| 2387 | 2392 | ||
| 2393 | val = make_multibyte_string (buf, nchars, p - buf); | ||
| 2394 | |||
| 2388 | /* If we allocated BUF with malloc, free it too. */ | 2395 | /* If we allocated BUF with malloc, free it too. */ |
| 2389 | if (total >= 1000) | 2396 | if (total >= 1000) |
| 2390 | xfree (buf); | 2397 | xfree (buf); |
| 2391 | 2398 | ||
| 2392 | return make_multibyte_string (buf, nchars, p - buf); | 2399 | return val; |
| 2393 | } | 2400 | } |
| 2394 | 2401 | ||
| 2395 | /* VARARGS 1 */ | 2402 | /* VARARGS 1 */ |