From: Karl Heuer Date: Mon, 22 Jun 1998 17:39:25 +0000 (+0000) Subject: (print_string): Properly compute number of chars X-Git-Tag: emacs-20.3~535 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=375fcc095fc5a4417fed9cbe2816db214350513b;p=emacs.git (print_string): Properly compute number of chars in multibyte case, before calling strout. --- diff --git a/src/print.c b/src/print.c index e60cdfb2fff..8df254c4059 100644 --- a/src/print.c +++ b/src/print.c @@ -573,11 +573,24 @@ print_string (string, printcharfun) Lisp_Object printcharfun; { if (EQ (printcharfun, Qt) || NILP (printcharfun)) - /* strout is safe for output to a frame (echo area) or to print_buffer. */ - strout (XSTRING (string)->data, - XSTRING (string)->size, - STRING_BYTES (XSTRING (string)), - printcharfun, STRING_MULTIBYTE (string)); + { + int chars; + + if (STRING_MULTIBYTE (string)) + chars = XSTRING (string)->size; + else if (EQ (printcharfun, Qt) + ? ! NILP (buffer_defaults.enable_multibyte_characters) + : ! NILP (current_buffer->enable_multibyte_characters)) + chars = multibyte_chars_in_text (XSTRING (string)->data, + STRING_BYTES (XSTRING (string))); + else + chars = STRING_BYTES (XSTRING (string)); + + /* strout is safe for output to a frame (echo area) or to print_buffer. */ + strout (XSTRING (string)->data, + chars, STRING_BYTES (XSTRING (string)), + printcharfun, STRING_MULTIBYTE (string)); + } else { /* Otherwise, string may be relocated by printing one char.