summaryrefslogtreecommitdiff
path: root/src/print.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2014-01-29 19:52:16 +0200
committerEli Zaretskii <eliz@gnu.org>2014-01-29 19:52:16 +0200
commit198af6dfe2ff8766ec50338ef88a171bf58a9fb7 (patch)
tree6fbfaf1691378aaa3f73e973f1d75eaa6f4883e4 /src/print.c
parent908df335d0ccb2779f23c695f355a9939fe07bf2 (diff)
downloademacs-198af6dfe2ff8766ec50338ef88a171bf58a9fb7.tar.gz
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.
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/print.c b/src/print.c
index 586c0615776..71fa30da93e 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;