From 375fcc095fc5a4417fed9cbe2816db214350513b Mon Sep 17 00:00:00 2001 From: Karl Heuer Date: Mon, 22 Jun 1998 17:39:25 +0000 Subject: [PATCH] (print_string): Properly compute number of chars in multibyte case, before calling strout. --- src/print.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) 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. -- 2.39.2