aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2014-01-29 19:52:16 +0200
committerEli Zaretskii2014-01-29 19:52:16 +0200
commit198af6dfe2ff8766ec50338ef88a171bf58a9fb7 (patch)
tree6fbfaf1691378aaa3f73e973f1d75eaa6f4883e4 /src
parent908df335d0ccb2779f23c695f355a9939fe07bf2 (diff)
downloademacs-198af6dfe2ff8766ec50338ef88a171bf58a9fb7.tar.gz
emacs-198af6dfe2ff8766ec50338ef88a171bf58a9fb7.zip
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')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/print.c15
2 files changed, 9 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 04f5f0d6bbe..33ffc40d8c1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12014-01-29 Eli Zaretskii <eliz@gnu.org>
2
3 * print.c (print_object): Use FETCH_STRING_CHAR_ADVANCE, not
4 STRING_CHAR_AND_LENGTH, so that if the string is relocated by GC,
5 we still use correct addresses. (Bug#16576)
6
12014-01-27 K. Handa <handa@gnu.org> 72014-01-27 K. Handa <handa@gnu.org>
2 8
3 Fix bug#16286 by the different way than revno:116158 to preserve 9 Fix bug#16286 by the different way than revno:116158 to preserve
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)
1389 print_string (obj, printcharfun); 1389 print_string (obj, printcharfun);
1390 else 1390 else
1391 { 1391 {
1392 register ptrdiff_t i_byte; 1392 register ptrdiff_t i, i_byte;
1393 struct gcpro gcpro1; 1393 struct gcpro gcpro1;
1394 unsigned char *str;
1395 ptrdiff_t size_byte; 1394 ptrdiff_t size_byte;
1396 /* 1 means we must ensure that the next character we output 1395 /* 1 means we must ensure that the next character we output
1397 cannot be taken as part of a hex character escape. */ 1396 cannot be taken as part of a hex character escape. */
@@ -1410,23 +1409,15 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1410 } 1409 }
1411 1410
1412 PRINTCHAR ('\"'); 1411 PRINTCHAR ('\"');
1413 str = SDATA (obj);
1414 size_byte = SBYTES (obj); 1412 size_byte = SBYTES (obj);
1415 1413
1416 for (i_byte = 0; i_byte < size_byte;) 1414 for (i = 0, i_byte = 0; i_byte < size_byte;)
1417 { 1415 {
1418 /* Here, we must convert each multi-byte form to the 1416 /* Here, we must convert each multi-byte form to the
1419 corresponding character code before handing it to PRINTCHAR. */ 1417 corresponding character code before handing it to PRINTCHAR. */
1420 int len;
1421 int c; 1418 int c;
1422 1419
1423 if (multibyte) 1420 FETCH_STRING_CHAR_ADVANCE (c, obj, i, i_byte);
1424 {
1425 c = STRING_CHAR_AND_LENGTH (str + i_byte, len);
1426 i_byte += len;
1427 }
1428 else
1429 c = str[i_byte++];
1430 1421
1431 QUIT; 1422 QUIT;
1432 1423