]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug #16576 with PRINTCHARFUN that conses output a lot.
authorEli Zaretskii <eliz@gnu.org>
Wed, 29 Jan 2014 17:52:16 +0000 (19:52 +0200)
committerEli Zaretskii <eliz@gnu.org>
Wed, 29 Jan 2014 17:52:16 +0000 (19:52 +0200)
 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
src/print.c

index 04f5f0d6bbe8786aa8983c831240f79f6af780c5..33ffc40d8c1cd362f73ae630cc216d07e2141ee1 100644 (file)
@@ -1,3 +1,9 @@
+2014-01-29  Eli Zaretskii  <eliz@gnu.org>
+
+       * 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  <handa@gnu.org>
 
        Fix bug#16286 by the different way than revno:116158 to preserve
index 586c06157768f5607431c57f0517cb11ec1d4947..71fa30da93e4281375da9de84e1ed19703b3499a 100644 (file)
@@ -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;