Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
4391:cbf129b005df | 4394:cacc942c0d0f |
---|---|
865 | 865 |
866 UNGCPRO; | 866 UNGCPRO; |
867 return object; | 867 return object; |
868 } | 868 } |
869 | 869 |
870 Lisp_Object | |
871 prin1_to_string (Lisp_Object object, int noescape) | |
872 { | |
873 /* This function can GC */ | |
874 Lisp_Object result = Qnil; | |
875 Lisp_Object stream = make_resizing_buffer_output_stream (); | |
876 Lstream *str = XLSTREAM (stream); | |
877 /* gcpro OBJECT in case a caller forgot to do so */ | |
878 struct gcpro gcpro1, gcpro2, gcpro3; | |
879 GCPRO3 (object, stream, result); | |
880 | |
881 print_internal (object, stream, !noescape); | |
882 Lstream_flush (str); | |
883 UNGCPRO; | |
884 result = make_string (resizing_buffer_stream_ptr (str), | |
885 Lstream_byte_count (str)); | |
886 Lstream_delete (str); | |
887 return result; | |
888 } | |
889 | |
870 DEFUN ("prin1-to-string", Fprin1_to_string, 1, 2, 0, /* | 890 DEFUN ("prin1-to-string", Fprin1_to_string, 1, 2, 0, /* |
871 Return a string containing the printed representation of OBJECT, | 891 Return a string containing the printed representation of OBJECT, |
872 any Lisp object. Quoting characters are used when needed to make output | 892 any Lisp object. Quoting characters are used when needed to make output |
873 that `read' can handle, whenever this is possible, unless the optional | 893 that `read' can handle, whenever this is possible, unless the optional |
874 second argument NOESCAPE is non-nil. | 894 second argument NOESCAPE is non-nil. |
875 */ | 895 */ |
876 (object, noescape)) | 896 (object, noescape)) |
877 { | 897 { |
878 /* This function can GC */ | 898 /* This function can GC */ |
879 Lisp_Object result = Qnil; | 899 Lisp_Object result = Qnil; |
880 Lisp_Object stream = make_resizing_buffer_output_stream (); | |
881 Lstream *str = XLSTREAM (stream); | |
882 /* gcpro OBJECT in case a caller forgot to do so */ | |
883 struct gcpro gcpro1, gcpro2, gcpro3; | |
884 GCPRO3 (object, stream, result); | |
885 | 900 |
886 RESET_PRINT_GENSYM; | 901 RESET_PRINT_GENSYM; |
887 print_internal (object, stream, NILP (noescape)); | 902 result = prin1_to_string (object, !(EQ(noescape, Qnil))); |
888 RESET_PRINT_GENSYM; | 903 RESET_PRINT_GENSYM; |
889 Lstream_flush (str); | 904 |
890 UNGCPRO; | |
891 result = make_string (resizing_buffer_stream_ptr (str), | |
892 Lstream_byte_count (str)); | |
893 Lstream_delete (str); | |
894 return result; | 905 return result; |
895 } | 906 } |
896 | 907 |
897 DEFUN ("princ", Fprinc, 1, 2, 0, /* | 908 DEFUN ("princ", Fprinc, 1, 2, 0, /* |
898 Output the printed representation of OBJECT, any Lisp object. | 909 Output the printed representation of OBJECT, any Lisp object. |