From 198af6dfe2ff8766ec50338ef88a171bf58a9fb7 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 29 Jan 2014 19:52:16 +0200 Subject: [PATCH] Fix bug #16576 with PRINTCHARFUN that conses output a lot. src/print.c (print_object): Use FETCH_STRING_CHAR_ADVANCE, not STRING_CHAR_AND_LENGTH, so that if the string is relocated by GC, we still use correct addresses. --- src/ChangeLog | 6 ++++++ src/print.c | 15 +++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 04f5f0d6bb..33ffc40d8c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2014-01-29 Eli Zaretskii + + * print.c (print_object): Use FETCH_STRING_CHAR_ADVANCE, not + STRING_CHAR_AND_LENGTH, so that if the string is relocated by GC, + we still use correct addresses. (Bug#16576) + 2014-01-27 K. Handa Fix bug#16286 by the different way than revno:116158 to preserve diff --git a/src/print.c b/src/print.c index 586c061577..71fa30da93 100644 --- a/src/print.c +++ b/src/print.c @@ -1389,9 +1389,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) print_string (obj, printcharfun); else { - register ptrdiff_t i_byte; + register ptrdiff_t i, i_byte; struct gcpro gcpro1; - unsigned char *str; ptrdiff_t size_byte; /* 1 means we must ensure that the next character we output cannot be taken as part of a hex character escape. */ @@ -1410,23 +1409,15 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) } PRINTCHAR ('\"'); - str = SDATA (obj); size_byte = SBYTES (obj); - for (i_byte = 0; i_byte < size_byte;) + for (i = 0, i_byte = 0; i_byte < size_byte;) { /* Here, we must convert each multi-byte form to the corresponding character code before handing it to PRINTCHAR. */ - int len; int c; - if (multibyte) - { - c = STRING_CHAR_AND_LENGTH (str + i_byte, len); - i_byte += len; - } - else - c = str[i_byte++]; + FETCH_STRING_CHAR_ADVANCE (c, obj, i, i_byte); QUIT; -- 2.20.1