Mercurial > hg > xemacs-beta
diff src/print.c @ 4394:cacc942c0d0f
Avoid clearing print-gensym-alist inappropriately when printing hash tables.
2008-01-15 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el (thing):
Check that printing a hash table literal doesn't clear
print-gensym-alist.
2008-01-15 Aidan Kehoe <kehoea@parhasard.net>
* print.c (prin1_to_string): New.
The guts of Fprin1_to_string, without resetting
Vprint_gensym_alist.
(Fprin1_to_string):
Call prin1_to_string, wrapped with RESET_PRINT_GENSYM calls.
* doprnt.c (emacs_doprnt_1):
Call prin1_to_string, not Fprin1_to_string (dos veces). Avoids an
inappropriate reset of print-gensym-alist.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Tue, 15 Jan 2008 21:35:01 +0100 |
parents | d9eb5ea14f65 |
children | 383ab474a241 |
line wrap: on
line diff
--- a/src/print.c Sat Jan 12 18:04:13 2008 +0100 +++ b/src/print.c Tue Jan 15 21:35:01 2008 +0100 @@ -867,6 +867,26 @@ return object; } +Lisp_Object +prin1_to_string (Lisp_Object object, int noescape) +{ + /* This function can GC */ + Lisp_Object result = Qnil; + Lisp_Object stream = make_resizing_buffer_output_stream (); + Lstream *str = XLSTREAM (stream); + /* gcpro OBJECT in case a caller forgot to do so */ + struct gcpro gcpro1, gcpro2, gcpro3; + GCPRO3 (object, stream, result); + + print_internal (object, stream, !noescape); + Lstream_flush (str); + UNGCPRO; + result = make_string (resizing_buffer_stream_ptr (str), + Lstream_byte_count (str)); + Lstream_delete (str); + return result; +} + DEFUN ("prin1-to-string", Fprin1_to_string, 1, 2, 0, /* Return a string containing the printed representation of OBJECT, any Lisp object. Quoting characters are used when needed to make output @@ -877,20 +897,11 @@ { /* This function can GC */ Lisp_Object result = Qnil; - Lisp_Object stream = make_resizing_buffer_output_stream (); - Lstream *str = XLSTREAM (stream); - /* gcpro OBJECT in case a caller forgot to do so */ - struct gcpro gcpro1, gcpro2, gcpro3; - GCPRO3 (object, stream, result); RESET_PRINT_GENSYM; - print_internal (object, stream, NILP (noescape)); + result = prin1_to_string (object, !(EQ(noescape, Qnil))); RESET_PRINT_GENSYM; - Lstream_flush (str); - UNGCPRO; - result = make_string (resizing_buffer_stream_ptr (str), - Lstream_byte_count (str)); - Lstream_delete (str); + return result; }