annotate src/print.c @ 278:90d73dddcdc4 r21-0b37

Import from CVS: tag r21-0b37
author cvs
date Mon, 13 Aug 2007 10:31:29 +0200
parents 6330739388db
children 7df0dd720c89
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Lisp object printing and output streams.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1988, 1992-1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995, 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Synched up with: Not synched with FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* This file has been Mule-ized. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 /* Seriously hacked on by Ben Wing for Mule. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "backtrace.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "bytecode.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "console-tty.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include "console-stream.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include "extents.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "frame.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #include "insdel.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 #include "lstream.h"
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
40 #include "sysfile.h"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
42 #include <float.h>
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
43 /* Define if not in float.h */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
44 #ifndef DBL_DIG
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
45 #define DBL_DIG 16
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
46 #endif
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
47
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
48 static void print_error_message (Lisp_Object data, Lisp_Object stream);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
49
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 Lisp_Object Vstandard_output, Qstandard_output;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 /* The subroutine object for external-debugging-output is kept here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 for the convenience of the debugger. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 Lisp_Object Qexternal_debugging_output;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 Lisp_Object Qalternate_debugging_output;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
56
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 /* Avoid actual stack overflow in print. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 static int print_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
60 /* Detect most circularities to print finite output. */
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
61 #define PRINT_CIRCLE 200
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
62 Lisp_Object being_printed[PRINT_CIRCLE];
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
63
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 /* Maximum length of list or vector to print in full; noninteger means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 effectively infinity */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 Lisp_Object Vprint_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Lisp_Object Qprint_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 /* Maximum length of string to print in full; noninteger means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 effectively infinity */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 Lisp_Object Vprint_string_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 Lisp_Object Qprint_string_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 /* Maximum depth of list to print in full; noninteger means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 effectively infinity. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 Lisp_Object Vprint_level;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 /* Label to use when making echo-area messages. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 Lisp_Object Vprint_message_label;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 /* Nonzero means print newlines in strings as \n. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 int print_escape_newlines;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 int print_readably;
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
89
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
90 /* Non-nil means print #: before uninterned symbols.
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
91 Neither t nor nil means so that and don't clear Vprint_gensym_alist
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
92 on entry to and exit from print functions. */
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
93 Lisp_Object Vprint_gensym;
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
94 Lisp_Object Vprint_gensym_alist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 Lisp_Object Qprint_escape_newlines;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 Lisp_Object Qprint_readably;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
99 Lisp_Object Qdisplay_error;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
100 Lisp_Object Qprint_message_label;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
101
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 /* Force immediate output of all printed data. Used for debugging. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 int print_unbuffered;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 FILE *termscript; /* Stdio stream being used for copy of all output. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 int stdout_needs_newline;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 /* Write a string (in internal format) to stdio stream STREAM. */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
112
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 write_string_to_stdio_stream (FILE *stream, struct console *con,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 CONST Bufbyte *str,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 Bytecount offset, Bytecount len,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 enum external_data_format fmt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 int extlen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 CONST Extbyte *extptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 GET_CHARPTR_EXT_DATA_ALLOCA (str + offset, len, fmt, extptr, extlen);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 if (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 fwrite (extptr, 1, extlen, stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 assert (CONSOLE_TTY_P (con));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 Lstream_write (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 extptr, extlen);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 if (stream == stdout || stream == stderr ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (!stream && CONSOLE_TTY_DATA (con)->is_stdio))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 if (termscript)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 fwrite (extptr, 1, extlen, termscript);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 fflush (termscript);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 stdout_needs_newline = (extptr[extlen - 1] != '\n');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 /* Write a string to the output location specified in FUNCTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 Arguments NONRELOC, RELOC, OFFSET, and LEN are as in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 buffer_insert_string_1() in insdel.c. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 output_string (Lisp_Object function, CONST Bufbyte *nonreloc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 Lisp_Object reloc, Bytecount offset, Bytecount len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 /* This function can GC */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
152 Charcount cclen;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 /* We change the value of nonreloc (fetching it from reloc as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 necessary), but we don't want to pass this changed value on to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 other functions that take both a nonreloc and a reloc, or things
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 may get confused and an assertion failure in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 fixup_internal_substring() may get triggered. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 CONST Bufbyte *newnonreloc = nonreloc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 struct gcpro gcpro1, gcpro2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 /* Emacs won't print whilst GCing, but an external debugger might */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 if (gc_in_progress) return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 /* Perhaps not necessary but probably safer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 GCPRO2 (function, reloc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 fixup_internal_substring (newnonreloc, reloc, offset, &len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 if (STRINGP (reloc))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
170 newnonreloc = XSTRING_DATA (reloc);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 cclen = bytecount_to_charcount (newnonreloc + offset, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 if (LSTREAMP (function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 if (STRINGP (reloc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 {
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
178 /* Protect against Lstream_write() causing a GC and
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
179 relocating the string. For small strings, we do it by
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
180 alloc'ing the string and using a copy; for large strings,
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
181 we inhibit GC. */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
182 if (len < 65536)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
183 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
184 Bufbyte *copied = alloca_array (Bufbyte, len);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
185 memcpy (copied, newnonreloc + offset, len);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
186 Lstream_write (XLSTREAM (function), copied, len);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
187 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
188 else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
189 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
190 int speccount = specpdl_depth ();
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
191 record_unwind_protect (restore_gc_inhibit,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
192 make_int (gc_currently_forbidden));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
193 gc_currently_forbidden = 1;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
194 Lstream_write (XLSTREAM (function), newnonreloc + offset, len);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
195 unbind_to (speccount, Qnil);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
196 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 Lstream_write (XLSTREAM (function), newnonreloc + offset, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 if (print_unbuffered)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 Lstream_flush (XLSTREAM (function));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 else if (BUFFERP (function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 CHECK_LIVE_BUFFER (function);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 buffer_insert_string (XBUFFER (function), nonreloc, reloc, offset, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 else if (MARKERP (function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
211 /* marker_position() will err if marker doesn't point anywhere. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 Bufpos spoint = marker_position (function);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
214 buffer_insert_string_1 (XMARKER (function)->buffer,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 spoint, nonreloc, reloc, offset, len,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 Fset_marker (function, make_int (spoint + cclen),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 Fmarker_buffer (function));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 else if (FRAMEP (function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
222 /* This gets used by functions not invoking print_prepare(),
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
223 such as Fwrite_char. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 struct frame *f = XFRAME (function);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
225 CHECK_LIVE_FRAME (function);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
226
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 if (!EQ (Vprint_message_label, echo_area_status (f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 clear_echo_area_from_print (f, Qnil, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 echo_area_append (f, nonreloc, reloc, offset, len, Vprint_message_label);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 else if (EQ (function, Qt) || EQ (function, Qnil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 write_string_to_stdio_stream (stdout, 0, newnonreloc, offset, len,
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
234 FORMAT_TERMINAL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
238 Charcount ccoff = bytecount_to_charcount (newnonreloc, offset);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 Charcount iii;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 for (iii = ccoff; iii < cclen + ccoff; iii++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 call1 (function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 make_char (charptr_emchar_n (newnonreloc, iii)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 if (STRINGP (reloc))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
246 newnonreloc = XSTRING_DATA (reloc);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 }
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
252
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
253 #define RESET_PRINT_GENSYM do { \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
254 if (!CONSP (Vprint_gensym)) \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
255 Vprint_gensym_alist = Qnil; \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
256 } while (0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 canonicalize_printcharfun (Lisp_Object printcharfun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 if (NILP (printcharfun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 printcharfun = Vstandard_output;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 if (EQ (printcharfun, Qt) || NILP (printcharfun))
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
265 printcharfun = Fselected_frame (Qnil); /* print to minibuffer */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
266
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
267 return printcharfun;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 static Lisp_Object
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
271 print_prepare (Lisp_Object printcharfun, Lisp_Object *frame_kludge)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 /* Emacs won't print whilst GCing, but an external debugger might */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 if (gc_in_progress)
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
275 return Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
277 RESET_PRINT_GENSYM;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
278
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 printcharfun = canonicalize_printcharfun (printcharfun);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
280
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
281 /* Here we could safely return the canonicalized PRINTCHARFUN.
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
282 However, if PRINTCHARFUN is a frame, printing of complex
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
283 structures becomes very expensive, because `append-message'
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
284 (called by echo_area_append) gets called as many times as
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
285 output_string() is called (and that's a *lot*). append-message
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
286 tries to keep top of the message-stack in sync with the contents
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
287 of " *Echo Area" buffer, consing a new string for each component
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
288 of the printed structure. For instance, if you print (a a),
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
289 append-message will cons up the following strings:
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
290
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
291 "("
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
292 "(a"
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
293 "(a "
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
294 "(a a"
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
295 "(a a)"
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
296
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
297 and will use only the last one. With larger objects, this turns
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
298 into an O(n^2) consing frenzy that locks up XEmacs in incessant
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
299 garbage collection.
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
300
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
301 We prevent this by creating a resizing_buffer stream and letting
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
302 the printer write into it. print_finish() will notice this
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
303 stream, and invoke echo_area_append() with the stream's buffer,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
304 only once. */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
305 if (FRAMEP (printcharfun))
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
306 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
307 CHECK_LIVE_FRAME (printcharfun);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
308 *frame_kludge = printcharfun;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
309 printcharfun = make_resizing_buffer_output_stream ();
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
310 }
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
311
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
312 return printcharfun;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 static void
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
316 print_finish (Lisp_Object stream, Lisp_Object frame_kludge)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 /* Emacs won't print whilst GCing, but an external debugger might */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 if (gc_in_progress)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
322 RESET_PRINT_GENSYM;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
323
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
324 /* See the comment in print_prepare(). */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
325 if (FRAMEP (frame_kludge))
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
326 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
327 struct frame *f = XFRAME (frame_kludge);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
328 Lstream *str = XLSTREAM (stream);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
329 CHECK_LIVE_FRAME (frame_kludge);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
330
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
331 Lstream_flush (str);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
332 if (!EQ (Vprint_message_label, echo_area_status (f)))
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
333 clear_echo_area_from_print (f, Qnil, 1);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
334 echo_area_append (f, resizing_buffer_stream_ptr (str),
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
335 Qnil, 0, Lstream_byte_count (str),
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
336 Vprint_message_label);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
337 Lstream_delete (str);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
338 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
341 /* Used for printing a character. STRING_OF_LENGTH_1 must contain a
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
342 single-byte character, not just any emchar. */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
343 #define write_char_internal(string_of_length_1, stream) \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
344 output_string ((stream), (CONST Bufbyte *) (string_of_length_1), \
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
345 Qnil, 0, 1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 /* NOTE: Do not call this with the data of a Lisp_String,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 * as printcharfun might cause a GC, which might cause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 * the string's data to be relocated.
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
350 * Use print_internal (string, printcharfun, 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 * to princ a Lisp_String
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 * Note: "stream" should be the result of "canonicalize_printcharfun"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 * (ie Qnil means stdout, not Vstandard_output, etc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 write_string_1 (CONST Bufbyte *str, Bytecount size, Lisp_Object stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 /* This function can GC */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
359 #ifdef ERROR_CHECK_BUFPOS
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 assert (size >= 0);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
361 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 output_string (stream, str, Qnil, 0, size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 write_c_string (CONST char *str, Lisp_Object stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 write_string_1 ((CONST Bufbyte *) str, strlen (str), stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
373 DEFUN ("write-char", Fwrite_char, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 Output character CH to stream STREAM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 STREAM defaults to the value of `standard-output' (which see).
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
376 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
377 (ch, stream))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 Bufbyte str[MAX_EMCHAR_LEN];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 Bytecount len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 CHECK_CHAR_COERCE_INT (ch);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
384 RESET_PRINT_GENSYM;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 len = set_charptr_emchar (str, XCHAR (ch));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 output_string (canonicalize_printcharfun (stream), str, Qnil, 0, len);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
387 RESET_PRINT_GENSYM;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 return ch;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 temp_output_buffer_setup (CONST char *bufname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 struct buffer *old = current_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 Lisp_Object buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 /* #### This function should accept a Lisp_Object instead of a char *,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 so that proper translation on the buffer name can occur. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 Fset_buffer (Fget_buffer_create (build_string (bufname)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 current_buffer->read_only = Qnil;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
406 Ferase_buffer (Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 XSETBUFFER (buf, current_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 specbind (Qstandard_output, buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 set_buffer_internal (old);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 Lisp_Object
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
415 internal_with_output_to_temp_buffer (CONST char *bufname,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 Lisp_Object (*function) (Lisp_Object arg),
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
417 Lisp_Object arg,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 Lisp_Object same_frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 struct gcpro gcpro1, gcpro2, gcpro3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 Lisp_Object buf = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 GCPRO3 (buf, arg, same_frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 temp_output_buffer_setup (GETTEXT (bufname));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 buf = Vstandard_output;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 arg = (*function) (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 temp_output_buffer_show (buf, same_frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 return unbind_to (speccount, arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
437 DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, 1, UNEVALLED, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 The buffer is cleared out initially, and marked as unmodified when done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 All output done by BODY is inserted in that buffer by default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 The buffer is displayed in another window, but not selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 The value of the last form in BODY is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 If BODY does not finish normally, the buffer BUFNAME is not displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 If variable `temp-buffer-show-function' is non-nil, call it at the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 to get the buffer displayed. It gets one argument, the buffer to display.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
447 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
448 (args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 Lisp_Object name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 int speccount = specpdl_depth ();
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
454 Lisp_Object val;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 /* #### should set the buffer to be translating. See print_internal(). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 GCPRO1 (args);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
461 name = Feval (XCAR (args));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 CHECK_STRING (name);
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
465 temp_output_buffer_setup ((char *) XSTRING_DATA (name));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
467 val = Fprogn (XCDR (args));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
469 temp_output_buffer_show (Vstandard_output, Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 return unbind_to (speccount, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
474 DEFUN ("terpri", Fterpri, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 Output a newline to STREAM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 If STREAM is omitted or nil, the value of `standard-output' is used.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
477 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
478 (stream))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 Bufbyte str[1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 str[0] = '\n';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 output_string (canonicalize_printcharfun (stream), str, Qnil, 0, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 return Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
487 DEFUN ("prin1", Fprin1, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 Output the printed representation of OBJECT, any Lisp object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 Quoting characters are printed when needed to make output that `read'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 can handle, whenever this is possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 Output stream is STREAM, or value of `standard-output' (which see).
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
492 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
493 (object, stream))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 /* This function can GC */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
496 Lisp_Object the_stream = Qnil, frame = Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 struct gcpro gcpro1, gcpro2, gcpro3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 GCPRO3 (object, stream, the_stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 print_depth = 0;
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
501 the_stream = print_prepare (stream, &frame);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 print_internal (object, the_stream, 1);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
503 print_finish (the_stream, frame);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 return object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
508 DEFUN ("prin1-to-string", Fprin1_to_string, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 Return a string containing the printed representation of OBJECT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 any Lisp object. Quoting characters are used when needed to make output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 that `read' can handle, whenever this is possible, unless the optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 second argument NOESCAPE is non-nil.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
513 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
514 (object, noescape))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 /* This function can GC */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
517 Lisp_Object stream;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
518 Lstream *str;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
519 struct gcpro gcpro1, gcpro2;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
520
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
521 stream = make_resizing_buffer_output_stream ();
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
522 str = XLSTREAM (stream);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
523
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
524 /* Protect OBJECT, in case a caller forgot to protect. */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
525 GCPRO2 (object, stream);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 print_depth = 0;
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
527 RESET_PRINT_GENSYM;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
528 print_internal (object, stream, NILP (noescape));
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
529 RESET_PRINT_GENSYM;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
530 Lstream_flush (str);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 UNGCPRO;
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
532 return make_string (resizing_buffer_stream_ptr (str),
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
533 Lstream_byte_count (str));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
536 DEFUN ("princ", Fprinc, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 Output the printed representation of OBJECT, any Lisp object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 No quoting characters are used; no delimiters are printed around
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 the contents of strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 Output stream is STREAM, or value of standard-output (which see).
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
541 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
542 (obj, stream))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 /* This function can GC */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
545 Lisp_Object the_stream = Qnil, frame = Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 struct gcpro gcpro1, gcpro2, gcpro3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 GCPRO3 (obj, stream, the_stream);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
549 the_stream = print_prepare (stream, &frame);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 print_depth = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 print_internal (obj, the_stream, 0);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
552 print_finish (the_stream, frame);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 UNGCPRO;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
554 return obj;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
557 DEFUN ("print", Fprint, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 Output the printed representation of OBJECT, with newlines around it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 Quoting characters are printed when needed to make output that `read'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 can handle, whenever this is possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 Output stream is STREAM, or value of `standard-output' (which see).
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
562 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
563 (obj, stream))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 /* This function can GC */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
566 Lisp_Object the_stream = Qnil, frame = Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 struct gcpro gcpro1, gcpro2, gcpro3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 GCPRO3 (obj, stream, the_stream);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
570 the_stream = print_prepare (stream, &frame);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 print_depth = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 write_char_internal ("\n", the_stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 print_internal (obj, the_stream, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 write_char_internal ("\n", the_stream);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
575 print_finish (the_stream, frame);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 return obj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
580
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
581 /* Synched with Emacs 19.34 -- underlying implementation (incarnated
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
582 in print_error_message) is completely divergent, though. */
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
583 DEFUN ("error-message-string", Ferror_message_string, 1, 1, 0, /*
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
584 Convert an error value (ERROR-SYMBOL . DATA) to an error message.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
585 */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 149
diff changeset
586 (data))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
587 {
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
588 /* This function can GC */
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
589 Lisp_Object stream = make_resizing_buffer_output_stream ();
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
590 struct gcpro gcpro1;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
591 GCPRO1 (stream);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
592
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
593 print_error_message (data, stream);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
594 Lstream_flush (XLSTREAM (stream));
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
595 UNGCPRO;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
596 return make_string (resizing_buffer_stream_ptr (XLSTREAM (stream)),
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
597 Lstream_byte_count (XLSTREAM (stream)));
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
598 }
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
599
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
600 /* Print an error message for the error DATA onto Lisp output stream
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
601 STREAM (suitable for the print functions).
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
602
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
603 This is a complete implementation of `display-error', which used to
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
604 be in Lisp (see prim/cmdloop.el). It was ported to C so we can use
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
605 it in Ferror_message_string. Fdisplay_error and
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
606 Ferror_message_string are trivial wrappers to this function. */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
607 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
608 print_error_message (Lisp_Object error_object, Lisp_Object stream)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
609 {
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
610 /* This function can GC */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
611 Lisp_Object type;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
612 Lisp_Object method = Qnil;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
613 Lisp_Object tail = Qnil;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
614 struct gcpro gcpro1;
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
615
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
616 GCPRO1 (tail);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
617
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
618 type = Fcar_safe (error_object);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
619
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
620 if (! (CONSP (error_object) && SYMBOLP (type)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
621 && CONSP (Fget (type, Qerror_conditions, Qnil))))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
622 goto error_throw;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
623
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
624 tail = XCDR (error_object);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
625 while (!NILP (tail))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
626 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
627 if (CONSP (tail))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
628 tail = XCDR (tail);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
629 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
630 goto error_throw;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
631 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
632 tail = Fget (type, Qerror_conditions, Qnil);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
633 while (!NILP (tail))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
634 {
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
635 if (!(CONSP (tail) && SYMBOLP (XCAR (tail))))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
636 goto error_throw;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
637 else if (!NILP (Fget (XCAR (tail), Qdisplay_error, Qnil)))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
638 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
639 method = Fget (XCAR (tail), Qdisplay_error, Qnil);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
640 goto error_throw;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
641 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
642 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
643 tail = XCDR (tail);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
644 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
645 /* Default method */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
646 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
647 int first = 1;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
648 Lisp_Object printcharfun = canonicalize_printcharfun (stream);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
649 int speccount = specpdl_depth ();
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
650
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
651 specbind (Qprint_message_label, Qerror);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
652 tail = Fcdr (error_object);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
653 if (EQ (type, Qerror))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
654 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
655 Fprinc (Fcar (tail), stream);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
656 tail = Fcdr (tail);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
657 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
658 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
659 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
660 Lisp_Object errmsg = Fget (type, Qerror_message, Qnil);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
661 if (NILP (errmsg))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
662 Fprinc (type, stream);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
663 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
664 Fprinc (errmsg, stream);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
665 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
666 while (!NILP (tail))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
667 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
668 write_c_string (first ? ": " : ", ", printcharfun);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
669 Fprin1 (Fcar (tail), stream);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
670 tail = Fcdr (tail);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
671 first = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
672 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
673 unbind_to (speccount, Qnil);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
674 UNGCPRO;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
675 return;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
676 /* Unreached */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
677 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
678
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
679 error_throw:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
680 UNGCPRO;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
681 if (NILP (method))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
682 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
683 write_c_string ("Peculiar error ",
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
684 canonicalize_printcharfun (stream));
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
685 Fprin1 (error_object, stream);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
686 return;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
687 }
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
688 else
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
689 {
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
690 call2 (method, error_object, stream);
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
691 }
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
692 }
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
693
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
694 DEFUN ("display-error", Fdisplay_error, 2, 2, 0, /*
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
695 Display an error message for ERROR-OBJECT to STREAM.
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
696 */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
697 (error_object, stream))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
698 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
699 /* This function can GC */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
700 print_error_message (error_object, stream);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
701 return Qnil;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
702 }
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
703
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
704
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 Lisp_Object Vfloat_output_format;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 Lisp_Object Qfloat_output_format;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 float_to_string (char *buf, double data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 * This buffer should be at least as large as the max string size of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 * largest float, printed in the biggest notation. This is undoubtably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 * 20d float_output_format, with the negative of the C-constant "HUGE"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 * from <math.h>.
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
717 *
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 * On the vax the worst case is -1e38 in 20d format which takes 61 bytes.
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
719 *
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 * I assume that IEEE-754 format numbers can take 329 bytes for the worst
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 * case of -1e307 in 20d float_output_format. What is one to do (short of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 * re-writing _doprnt to be more sane)?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 * -wsr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 Bufbyte *cp, c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 int width;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
728
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 if (NILP (Vfloat_output_format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 || !STRINGP (Vfloat_output_format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 lose:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 sprintf (buf, "%.16g", data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 else /* oink oink */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 /* Check that the spec we have is fully valid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 This means not only valid for printf,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 but meant for floats, and reasonable. */
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
738 cp = XSTRING_DATA (Vfloat_output_format);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 if (cp[0] != '%')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 goto lose;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 if (cp[1] != '.')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 goto lose;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 cp += 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 for (width = 0; (c = *cp, isdigit (c)); cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 width *= 10;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 width += c - '0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
752 if (*cp != 'e' && *cp != 'f' && *cp != 'g' && *cp != 'E' && *cp != 'G')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 goto lose;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 if (width < (int) (*cp != 'e' && *cp != 'E') || width > DBL_DIG)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 goto lose;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 if (cp[1] != 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 goto lose;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
761 sprintf (buf, (char *) XSTRING_DATA (Vfloat_output_format),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 /* added by jwz: don't allow "1.0" to print as "1"; that destroys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 the read-equivalence of lisp objects. (* x 1) and (* x 1.0) do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 not do the same thing, so it's important that the printed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 representation of that form not be corrupted by the printer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 Bufbyte *s = (Bufbyte *) buf; /* don't use signed chars here!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 isdigit() can't hack them! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 if (*s == '-') s++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 for (; *s; s++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 /* if there's a non-digit, then there is a decimal point, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 it's in exponential notation, both of which are ok. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 if (!isdigit (*s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 goto DONE_LABEL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 /* otherwise, we need to hack it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 *s++ = '.';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 *s++ = '0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 *s = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 DONE_LABEL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 /* Some machines print "0.4" as ".4". I don't like that. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 if (buf [0] == '.' || (buf [0] == '-' && buf [1] == '.'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 for (i = strlen (buf) + 1; i >= 0; i--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 buf [i+1] = buf [i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 buf [(buf [0] == '-' ? 1 : 0)] = '0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 #endif /* LISP_FLOAT_TYPE */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
796
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
797 /* Print NUMBER to BUFFER. The digits are first written in reverse
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
798 order (the least significant digit first), and are then reversed.
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
799 This is equivalent to sprintf(buffer, "%ld", number), only much
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
800 faster. */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
801 void
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
802 long_to_string (char *buffer, long number)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
803 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
804 char *p;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
805 int i, l;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
806
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
807 if (number < 0)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
808 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
809 *buffer++ = '-';
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
810 number = -number;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
811 }
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
812 p = buffer;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
813 /* Print the digits to the string. */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
814 do
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
815 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
816 *p++ = number % 10 + '0';
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
817 number /= 10;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
818 }
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
819 while (number);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
820 /* And reverse them. */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
821 l = p - buffer - 1;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
822 for (i = l/2; i >= 0; i--)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
823 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
824 char c = buffer[i];
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
825 buffer[i] = buffer[l - i];
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
826 buffer[l - i] = c;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
827 }
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
828 buffer[l + 1] = '\0';
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
829 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 print_vector_internal (CONST char *start, CONST char *end,
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
833 Lisp_Object obj,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 Lisp_Object printcharfun, int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 int i;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
838 int len = XVECTOR_LENGTH (obj);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 int last = len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 struct gcpro gcpro1, gcpro2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 GCPRO2 (obj, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 if (INTP (Vprint_length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 int max = XINT (Vprint_length);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 if (max < len) last = max;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 write_c_string (start, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 for (i = 0; i < last; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
852 Lisp_Object elt = XVECTOR_DATA (obj)[i];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 if (i != 0) write_char_internal (" ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 print_internal (elt, printcharfun, escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 if (last != len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 write_c_string (" ...", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 write_c_string (end, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
862 void
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
863 print_cons (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
864 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
865 /* This function can GC */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
866 struct gcpro gcpro1, gcpro2;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
867
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
868 /* If print_readably is on, print (quote -foo-) as '-foo-
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
869 (Yeah, this should really be what print-pretty does, but we
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
870 don't have the rest of a pretty printer, and this actually
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
871 has non-negligible impact on size/speed of .elc files.)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
872 */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
873 if (print_readably &&
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
874 EQ (XCAR (obj), Qquote) &&
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
875 CONSP (XCDR (obj)) &&
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
876 NILP (XCDR (XCDR (obj))))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
877 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
878 obj = XCAR (XCDR (obj));
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
879 GCPRO2 (obj, printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
880 write_char_internal ("'", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
881 UNGCPRO;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
882 print_internal (obj, printcharfun, escapeflag);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
883 return;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
884 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
885
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
886 GCPRO2 (obj, printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
887 write_char_internal ("(", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
888 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
889 int i = 0;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
890 int max = 0;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
891
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
892 if (INTP (Vprint_length))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
893 max = XINT (Vprint_length);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
894 while (CONSP (obj))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
895 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
896 if (i++)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
897 write_char_internal (" ", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
898 if (max && i > max)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
899 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
900 write_c_string ("...", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
901 break;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
902 }
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
903 print_internal (XCAR (obj), printcharfun,
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
904 escapeflag);
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
905 obj = XCDR (obj);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
906 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
907 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
908 if (!LISTP (obj))
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
909 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
910 write_c_string (" . ", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
911 print_internal (obj, printcharfun, escapeflag);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
912 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
913 UNGCPRO;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
914 write_char_internal (")", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
915 return;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
916 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
917
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
918 void
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
919 print_vector (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
920 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
921 print_vector_internal ("[", "]", obj, printcharfun, escapeflag);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
922 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
923
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
924 void
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
925 print_string (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
926 {
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
927 struct Lisp_String *s = XSTRING (obj);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
928 /* We distinguish between Bytecounts and Charcounts, to make
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
929 Vprint_string_length work correctly under Mule. */
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
930 Charcount size = string_char_length (s);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
931 Charcount max = size;
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
932 Bytecount bcmax = string_length (s);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
933 struct gcpro gcpro1, gcpro2;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
934 GCPRO2 (obj, printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
935
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
936 if (INTP (Vprint_string_length) &&
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
937 XINT (Vprint_string_length) < max)
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
938 {
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
939 max = XINT (Vprint_string_length);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
940 bcmax = charcount_to_bytecount (string_data (s), max);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
941 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
942 if (max < 0)
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
943 {
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
944 max = 0;
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
945 bcmax = 0;
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
946 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
947
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
948 if (!escapeflag)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
949 {
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
950 /* This deals with GC-relocation and Mule. */
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
951 output_string (printcharfun, 0, obj, 0, bcmax);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
952 if (max < size)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
953 write_c_string (" ...", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
954 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
955 else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
956 {
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
957 Bytecount i, last = 0;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
958
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
959 write_char_internal ("\"", printcharfun);
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
960 for (i = 0; i < bcmax; i++)
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
961 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
962 Bufbyte ch = string_byte (s, i);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
963 if (ch == '\"' || ch == '\\'
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
964 || (ch == '\n' && print_escape_newlines))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
965 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
966 if (i > last)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
967 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
968 output_string (printcharfun, 0, obj, last,
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
969 i - last);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
970 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
971 if (ch == '\n')
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
972 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
973 write_c_string ("\\n", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
974 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
975 else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
976 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
977 write_char_internal ("\\", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
978 /* This is correct for Mule because the
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
979 character is either \ or " */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
980 write_char_internal (string_data (s) + i, printcharfun);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
981 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
982 last = i + 1;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
983 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
984 }
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
985 if (bcmax > last)
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
986 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
987 output_string (printcharfun, 0, obj, last,
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
988 bcmax - last);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
989 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
990 if (max < size)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
991 write_c_string (" ...", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
992 write_char_internal ("\"", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
993 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
994 UNGCPRO;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
995 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
996
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 default_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 struct lcrecord_header *header =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (struct lcrecord_header *) XPNTR (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 char buf[200];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 if (print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 error ("printing unreadable object #<%s 0x%x>",
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
1007 LHEADER_IMPLEMENTATION (&header->lheader)->name,
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
1008 header->uid);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
1010 sprintf (buf, "#<%s 0x%x>",
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
1011 LHEADER_IMPLEMENTATION (&header->lheader)->name,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 header->uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 internal_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 char buf[200];
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1021 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (%s) 0x%lx>",
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
1022 XRECORD_LHEADER_IMPLEMENTATION (obj)->name,
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1023 (unsigned long) XPNTR (obj));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 print_internal (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 char buf[256];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 /* Emacs won't print whilst GCing, but an external debugger might */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 if (gc_in_progress) return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 /* #### Both input and output streams should have a flag associated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 with them indicating whether output to that stream, or strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 read from the stream, get translated using Fgettext(). Such a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 stream is called a "translating stream". For the minibuffer and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 external-debugging-output this is always true on output, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 with-output-to-temp-buffer sets the flag to true for the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 it creates. This flag should also be user-settable. Perhaps it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 should be split up into two flags, one for input and one for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 output. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1050 /* Detect circularities and truncate them.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1051 No need to offer any alternative--this is better than an error. */
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1052 if (CONSP (obj) || VECTORP (obj) || COMPILED_FUNCTIONP (obj))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1053 {
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1054 int i;
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1055 for (i = 0; i < print_depth; i++)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1056 if (EQ (obj, being_printed[i]))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1057 {
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1058 sprintf (buf, "#%d", i);
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1059 write_c_string (buf, printcharfun);
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1060 return;
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1061 }
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1062 }
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1063
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1064
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1065 being_printed[print_depth] = obj;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 print_depth++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
1068 if (print_depth > PRINT_CIRCLE)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 error ("Apparently circular structure being printed");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 switch (XTYPE (obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 {
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1073 #ifdef USE_MINIMAL_TAGBITS
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1074 case Lisp_Type_Int_Even:
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1075 case Lisp_Type_Int_Odd:
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1076 #else
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
1077 case Lisp_Type_Int:
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1078 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 {
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1080 long_to_string (buf, XINT (obj));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
1085 case Lisp_Type_Char:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1086 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1087 /* God intended that this be #\..., you know. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1088 Emchar ch = XCHAR (obj);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1089 char *p = buf;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1090 *p++ = '?';
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1091 if (ch == '\n')
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1092 *p++ = '\\', *p++ = 'n';
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1093 else if (ch == '\r')
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1094 *p++ = '\\', *p++ = 'r';
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1095 else if (ch == '\t')
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1096 *p++ = '\\', *p++ = 't';
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1097 else if (ch < 32)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1098 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1099 *p++ = '\\', *p++ = '^';
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1100 *p++ = ch + 64;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1101 if ((ch + 64) == '\\')
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1102 *p++ = '\\';
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
1103 }
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1104 else if (ch == 127)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1105 *p++ = '\\', *p++ = '^', *p++ = '?';
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1106 else if (ch >= 128 && ch < 160)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1107 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1108 *p++ = '\\', *p++ = '^';
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1109 p += set_charptr_emchar ((Bufbyte *)p, ch + 64);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1110 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1111 else if (ch < 127
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1112 && !isdigit (ch)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1113 && !isalpha (ch)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1114 && ch != '^') /* must not backslash this or it will
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1115 be interpreted as the start of a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1116 control char */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1117 *p++ = '\\', *p++ = ch;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1118 else
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1119 p += set_charptr_emchar ((Bufbyte *)p, ch);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1120 output_string (printcharfun, (Bufbyte *)buf, Qnil, 0, p - buf);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1121 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1122 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 56
diff changeset
1123
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1124 #ifndef LRECORD_STRING
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
1125 case Lisp_Type_String:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1127 print_string (obj, printcharfun, escapeflag);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1130 #endif /* ! LRECORD_STRING */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1132 #ifndef LRECORD_CONS
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
1133 case Lisp_Type_Cons:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 struct gcpro gcpro1, gcpro2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 /* If deeper than spec'd depth, print placeholder. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 if (INTP (Vprint_level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 && print_depth > XINT (Vprint_level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 {
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1141 GCPRO2 (obj, printcharfun);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 write_c_string ("...", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1147 print_cons (obj, printcharfun, escapeflag);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1150 #endif /* ! LRECORD_CONS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 #ifndef LRECORD_VECTOR
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
1153 case Lisp_Type_Vector:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 /* If deeper than spec'd depth, print placeholder. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 if (INTP (Vprint_level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 && print_depth > XINT (Vprint_level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1159 struct gcpro gcpro1, gcpro2;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1160 GCPRO2 (obj, printcharfun);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 write_c_string ("...", printcharfun);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1162 UNGCPRO;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 /* God intended that this be #(...), you know. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 print_vector_internal ("[", "]", obj, printcharfun, escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 #endif /* !LRECORD_VECTOR */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 #ifndef LRECORD_SYMBOL
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
1173 case Lisp_Type_Symbol:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 print_symbol (obj, printcharfun, escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 #endif /* !LRECORD_SYMBOL */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
1180 case Lisp_Type_Record:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 struct lrecord_header *lheader = XRECORD_LHEADER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 struct gcpro gcpro1, gcpro2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1185 #if defined(LRECORD_CONS) || defined(LRECORD_VECTOR)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1186 if (CONSP (obj) || VECTORP(obj))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1187 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1188 /* If deeper than spec'd depth, print placeholder. */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1189 if (INTP (Vprint_level)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1190 && print_depth > XINT (Vprint_level))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1191 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1192 GCPRO2 (obj, printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1193 write_c_string ("...", printcharfun);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1194 UNGCPRO;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1195 break;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1196 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1197 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1198 #endif
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 187
diff changeset
1199
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 GCPRO2 (obj, printcharfun);
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
1201 if (LHEADER_IMPLEMENTATION (lheader)->printer)
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
1202 ((LHEADER_IMPLEMENTATION (lheader)->printer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (obj, printcharfun, escapeflag));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 default_object_printer (obj, printcharfun, escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 /* We're in trouble if this happens!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 Probably should just abort () */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 if (print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 error ("printing illegal data type #o%03o",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (int) XTYPE (obj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 write_c_string ("#<EMACS BUG: ILLEGAL DATATYPE ",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 sprintf (buf, "(#o%3o)", (int) XTYPE (obj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 write_c_string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (" Save your buffers immediately and please report this bug>",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 print_depth--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 print_compiled_function_internal (CONST char *start, CONST char *end,
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
1233 Lisp_Object obj,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 Lisp_Object printcharfun, int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 struct Lisp_Compiled_Function *b =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 XCOMPILED_FUNCTION (obj); /* GC doesn't relocate */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 int docp = b->flags.documentationp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 int intp = b->flags.interactivep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 struct gcpro gcpro1, gcpro2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 char buf[100];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 GCPRO2 (obj, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 write_c_string (start, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 if (!print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 Lisp_Object ann = compiled_function_annotation (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 if (!NILP (ann))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 write_c_string ("(from ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 print_internal (ann, printcharfun, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 write_c_string (") ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 #endif /* COMPILED_FUNCTION_ANNOTATION_HACK */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 /* COMPILED_ARGLIST = 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 print_internal (b->arglist, printcharfun, escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 /* COMPILED_BYTECODE = 1 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 write_char_internal (" ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 /* we don't really want to see that junk in the bytecode instructions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 if (STRINGP (b->bytecodes) && !print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 {
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1265 sprintf (buf, "\"...(%ld)\"", (long) XSTRING_LENGTH (b->bytecodes));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 print_internal (b->bytecodes, printcharfun, escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 /* COMPILED_CONSTANTS = 2 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 write_char_internal (" ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 print_internal (b->constants, printcharfun, escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 /* COMPILED_STACK_DEPTH = 3 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 sprintf (buf, " %d", b->maxdepth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 /* COMPILED_DOC_STRING = 4 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 if (docp || intp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 write_char_internal (" ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 print_internal (compiled_function_documentation (b), printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 /* COMPILED_INTERACTIVE = 5 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 if (intp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 write_char_internal (" ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 print_internal (compiled_function_interactive (b), printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 write_c_string (end, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 print_compiled_function (Lisp_Object obj, Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 print_compiled_function_internal (((print_readably) ? "#[" :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 "#<compiled-function "),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 ((print_readably) ? "]" : ">"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 obj, printcharfun, escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 print_float (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 char pigbuf[350]; /* see comments in float_to_string */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 float_to_string (pigbuf, float_data (XFLOAT (obj)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 write_c_string (pigbuf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 print_symbol (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 /* #### Bug!! (intern "") isn't printed in some distinguished way */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 /* #### (the reader also loses on it) */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1322 struct Lisp_String *name = symbol_name (XSYMBOL (obj));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 Bytecount size = string_length (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 struct gcpro gcpro1, gcpro2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 if (!escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 /* This deals with GC-relocation */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 Lisp_Object nameobj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 XSETSTRING (nameobj, name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 output_string (printcharfun, 0, nameobj, 0, size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 GCPRO2 (obj, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1336 /* If we print an uninterned symbol as part of a complex object and
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1337 the flag print-gensym is non-nil, prefix it with #n= to read the
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1338 object back with the #n# reader syntax later if needed. */
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1339 if (!NILP (Vprint_gensym) && NILP (XSYMBOL (obj)->obarray))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 {
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1341 if (print_depth > 1)
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1342 {
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1343 Lisp_Object tem = Fassq (obj, Vprint_gensym_alist);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1344 if (CONSP (tem))
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1345 {
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1346 write_char_internal ("#", printcharfun);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1347 print_internal (XCDR (tem), printcharfun, escapeflag);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1348 write_char_internal ("#", printcharfun);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1349 return;
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1350 }
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1351 else
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1352 {
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1353 if (CONSP (Vprint_gensym_alist))
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 245
diff changeset
1354 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 245
diff changeset
1355 /* Vprint_gensym_alist is exposed to Lisp, so we
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 245
diff changeset
1356 have to be careful. */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 245
diff changeset
1357 CHECK_CONS (XCAR (Vprint_gensym_alist));
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 245
diff changeset
1358 CHECK_INT (XCDR (XCAR (Vprint_gensym_alist)));
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 245
diff changeset
1359 XSETINT (tem, XINT (XCDR (XCAR (Vprint_gensym_alist))) + 1);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 245
diff changeset
1360 }
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1361 else
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1362 XSETINT (tem, 1);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1363 Vprint_gensym_alist = Fcons (Fcons (obj, tem), Vprint_gensym_alist);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1364
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1365 write_char_internal ("#", printcharfun);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1366 print_internal (tem, printcharfun, escapeflag);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1367 write_char_internal ("=", printcharfun);
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1368 }
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1369 }
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1370 write_c_string ("#:", printcharfun);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 /* Does it look like an integer or a float? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 Bufbyte *data = string_data (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 Bytecount confusing = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 if (size == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 goto not_yet_confused; /* Really confusing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 else if (isdigit (data[0]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 confusing = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 else if (size == 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 goto not_yet_confused;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 else if (data[0] == '-' || data[0] == '+')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 confusing = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 goto not_yet_confused;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 for (; confusing < size; confusing++)
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
1390 {
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 if (!isdigit (data[confusing]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 confusing = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 not_yet_confused:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 if (!confusing)
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1401 /* #### Ugh, this is needlessly complex and slow for what we
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1402 need here. It might be a good idea to copy equivalent code
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1403 from FSF. --hniksic */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 confusing = isfloat_string ((char *) data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 if (confusing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 write_char_internal ("\\", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 Lisp_Object nameobj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 Bytecount i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 Bytecount last = 0;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 171
diff changeset
1414
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 XSETSTRING (nameobj, name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 for (i = 0; i < size; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 Bufbyte c = string_byte (name, i);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 if (c == '\"' || c == '\\' || c == '\'' || c == ';' || c == '#' ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 c == '(' || c == ')' || c == ',' || c =='.' || c == '`' ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 c == '[' || c == ']' || c == '?' || c <= 040)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 if (i > last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 output_string (printcharfun, 0, nameobj, last,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 i - last);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 write_char_internal ("\\", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 last = i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 output_string (printcharfun, 0, nameobj, last, size - last);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1438 /* #ifdef DEBUG_XEMACS */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1439 /* I don't like seeing `Note: Strange doc (not fboundp) for function */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1440 /* alternate-debugging-output @ 429542' -slb */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 int alternate_do_pointer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 char alternate_do_string[5000];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1444 DEFUN ("alternate-debugging-output", Falternate_debugging_output, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 Append CHARACTER to the array `alternate_do_string'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 This can be used in place of `external-debugging-output' as a function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 to be passed to `print'. Before calling `print', set `alternate_do_pointer'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 to 0.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1449 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1450 (character))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 Bufbyte str[MAX_EMCHAR_LEN];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 Bytecount len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 int extlen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 CONST Extbyte *extptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 CHECK_CHAR_COERCE_INT (character);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 len = set_charptr_emchar (str, XCHAR (character));
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1459 GET_CHARPTR_EXT_DATA_ALLOCA (str, len, FORMAT_TERMINAL, extptr, extlen);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 memcpy (alternate_do_string + alternate_do_pointer, extptr, extlen);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 alternate_do_pointer += extlen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 alternate_do_string[alternate_do_pointer] = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 return character;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 }
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1465 /* #endif /* DEBUG_XEMACS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1467 DEFUN ("external-debugging-output", Fexternal_debugging_output, 1, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 Write CHAR-OR-STRING to stderr or stdout.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 If optional arg STDOUT-P is non-nil, write to stdout; otherwise, write
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 to stderr. You can use this function to write directly to the terminal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 This function can be used as the STREAM argument of Fprint() or the like.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 If you have opened a termscript file (using `open-termscript'), then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 the output also will be logged to this file.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1475 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1476 (char_or_string, stdout_p, device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 FILE *file = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 struct console *con = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 if (NILP (device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 if (!NILP (stdout_p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 file = stdout;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 file = stderr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 CHECK_LIVE_DEVICE (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 if (!DEVICE_TTY_P (XDEVICE (device)) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 !DEVICE_STREAM_P (XDEVICE (device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 signal_simple_error ("Must be tty or stream device", device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 con = XCONSOLE (DEVICE_CONSOLE (XDEVICE (device)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 if (DEVICE_TTY_P (XDEVICE (device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 file = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 else if (!NILP (stdout_p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 file = CONSOLE_STREAM_DATA (con)->outfd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 file = CONSOLE_STREAM_DATA (con)->errfd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 if (STRINGP (char_or_string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 write_string_to_stdio_stream (file, con,
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1505 XSTRING_DATA (char_or_string),
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1506 0, XSTRING_LENGTH (char_or_string),
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1507 FORMAT_TERMINAL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 Bufbyte str[MAX_EMCHAR_LEN];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 Bytecount len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 CHECK_CHAR_COERCE_INT (char_or_string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 len = set_charptr_emchar (str, XCHAR (char_or_string));
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1515 write_string_to_stdio_stream (file, con, str, 0, len, FORMAT_TERMINAL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 return char_or_string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1521 DEFUN ("open-termscript", Fopen_termscript, 1, 1, "FOpen termscript file: ", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 Start writing all terminal output to FILE as well as the terminal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 FILE = nil means just close any termscript file currently open.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1524 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1525 (file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 if (termscript != 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 fclose (termscript);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 termscript = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 if (! NILP (file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 file = Fexpand_file_name (file, Qnil);
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1535 termscript = fopen ((char *) XSTRING_DATA (file), "w");
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 177
diff changeset
1536 if (termscript == NULL)
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1537 report_file_error ("Opening termscript", list1 (file));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 #if 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 /* Debugging kludge -- unbuffered */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 static int debug_print_length = 50;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 static int debug_print_level = 15;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 Lisp_Object debug_temp;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
1547
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
1548 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 debug_print_no_newline (Lisp_Object debug_print_obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 int old_print_readably = print_readably;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 int old_print_depth = print_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 Lisp_Object old_print_length = Vprint_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 Lisp_Object old_print_level = Vprint_level;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 Lisp_Object old_inhibit_quit = Vinhibit_quit;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 struct gcpro gcpro1, gcpro2, gcpro3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 GCPRO3 (old_print_level, old_print_length, old_inhibit_quit);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 if (gc_in_progress)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 stderr_out ("** gc-in-progress! Bad idea to print anything! **\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 print_depth = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 print_readably = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 print_unbuffered++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 /* Could use unwind-protect, but why bother? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 if (debug_print_length > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 Vprint_length = make_int (debug_print_length);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 if (debug_print_level > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 Vprint_level = make_int (debug_print_level);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 print_internal (debug_print_obj, Qexternal_debugging_output, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 Vinhibit_quit = old_inhibit_quit;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 Vprint_level = old_print_level;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 Vprint_length = old_print_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 print_depth = old_print_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 print_readably = old_print_readably;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 print_unbuffered--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 debug_print (Lisp_Object debug_print_obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 debug_print_no_newline (debug_print_obj);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
1585 stderr_out ("\n");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 fflush (stderr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 /* Debugging kludge -- unbuffered */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
1590 /* This function provided for the benefit of the debugger. */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
1591 void debug_backtrace (void);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 debug_backtrace (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 int old_print_readably = print_readably;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 int old_print_depth = print_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 Lisp_Object old_print_length = Vprint_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 Lisp_Object old_print_level = Vprint_level;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 Lisp_Object old_inhibit_quit = Vinhibit_quit;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 struct gcpro gcpro1, gcpro2, gcpro3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 GCPRO3 (old_print_level, old_print_length, old_inhibit_quit);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 if (gc_in_progress)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 stderr_out ("** gc-in-progress! Bad idea to print anything! **\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 print_depth = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 print_readably = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 print_unbuffered++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 /* Could use unwind-protect, but why bother? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 if (debug_print_length > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 Vprint_length = make_int (debug_print_length);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 if (debug_print_level > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 Vprint_level = make_int (debug_print_level);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 Fbacktrace (Qexternal_debugging_output, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 stderr_out ("\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 fflush (stderr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 Vinhibit_quit = old_inhibit_quit;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 Vprint_level = old_print_level;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 Vprint_length = old_print_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 print_depth = old_print_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 print_readably = old_print_readably;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 print_unbuffered--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 debug_short_backtrace (int length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 int first = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 struct backtrace *bt = backtrace_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 stderr_out (" [");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 fflush (stderr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 while (length > 0 && bt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 if (!first)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 stderr_out (", ");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 fflush (stderr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 if (COMPILED_FUNCTIONP (*bt->function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 {
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 223
diff changeset
1643 #if defined(COMPILED_FUNCTION_ANNOTATION_HACK)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 Lisp_Object ann = Fcompiled_function_annotation (*bt->function);
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 223
diff changeset
1645 #else
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 223
diff changeset
1646 Lisp_Object ann = Qnil;
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 223
diff changeset
1647 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 if (!NILP (ann))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 stderr_out ("<compiled-function from ");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 fflush (stderr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 debug_print_no_newline (ann);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 stderr_out (">");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 fflush (stderr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 stderr_out ("<compiled-function of unknown origin>");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 fflush (stderr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 debug_print_no_newline (*bt->function);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 first = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 length--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 bt = bt->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 stderr_out ("]\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 fflush (stderr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 #endif /* debugging kludge */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 syms_of_print (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 defsymbol (&Qprint_escape_newlines, "print-escape-newlines");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 defsymbol (&Qprint_readably, "print-readably");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 defsymbol (&Qstandard_output, "standard-output");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 defsymbol (&Qfloat_output_format, "float-output-format");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 defsymbol (&Qprint_length, "print-length");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 defsymbol (&Qprint_string_length, "print-string-length");
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
1690
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
1691 defsymbol (&Qdisplay_error, "display-error");
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
1692 defsymbol (&Qprint_message_label, "print-message-label");
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
1693
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1694 DEFSUBR (Fprin1);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1695 DEFSUBR (Fprin1_to_string);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1696 DEFSUBR (Fprinc);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1697 DEFSUBR (Fprint);
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1698 DEFSUBR (Ferror_message_string);
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 167
diff changeset
1699 DEFSUBR (Fdisplay_error);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1700 DEFSUBR (Fterpri);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1701 DEFSUBR (Fwrite_char);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1702 DEFSUBR (Falternate_debugging_output);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 defsymbol (&Qalternate_debugging_output, "alternate-debugging-output");
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1704 DEFSUBR (Fexternal_debugging_output);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1705 DEFSUBR (Fopen_termscript);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 defsymbol (&Qexternal_debugging_output, "external-debugging-output");
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1707 DEFSUBR (Fwith_output_to_temp_buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 vars_of_print (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 alternate_do_pointer = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 DEFVAR_LISP ("standard-output", &Vstandard_output /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 Output stream `print' uses by default for outputting a character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 This may be any function of one argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 It may also be a buffer (output is inserted before point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 or a marker (output is inserted and the marker is advanced)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 or the symbol t (output appears in the minibuffer line).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 Vstandard_output = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 #ifdef LISP_FLOAT_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 DEFVAR_LISP ("float-output-format", &Vfloat_output_format /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 The format descriptor string that lisp uses to print floats.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 This is a %-spec like those accepted by `printf' in C,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 but with some restrictions. It must start with the two characters `%.'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 After that comes an integer precision specification,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 and then a letter which controls the format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 The letters allowed are `e', `f' and `g'.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
1732 Use `e' for exponential notation "DIG.DIGITSeEXPT"
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
1733 Use `f' for decimal point notation "DIGITS.DIGITS".
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 Use `g' to choose the shorter of those two formats for the number at hand.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 The precision in any of these cases is the number of digits following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 the decimal point. With `f', a precision of 0 means to omit the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 decimal point. 0 is not allowed with `f' or `g'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 A value of nil means to use `%.16g'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 Regardless of the value of `float-output-format', a floating point number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 will never be printed in such a way that it is ambiguous with an integer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 that is, a floating-point number will always be printed with a decimal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 point and/or an exponent, even if the digits following the decimal point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 are all zero. This is to preserve read-equivalence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 Vfloat_output_format = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 #endif /* LISP_FLOAT_TYPE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 DEFVAR_LISP ("print-length", &Vprint_length /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 Maximum length of list or vector to print before abbreviating.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 A value of nil means no limit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 Vprint_length = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 DEFVAR_LISP ("print-string-length", &Vprint_string_length /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 Maximum length of string to print before abbreviating.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 A value of nil means no limit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 Vprint_string_length = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 DEFVAR_LISP ("print-level", &Vprint_level /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 Maximum depth of list nesting to print before abbreviating.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 A value of nil means no limit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 Vprint_level = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 DEFVAR_BOOL ("print-escape-newlines", &print_escape_newlines /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 Non-nil means print newlines in strings as backslash-n.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 print_escape_newlines = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 DEFVAR_BOOL ("print-readably", &print_readably /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 If non-nil, then all objects will be printed in a readable form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 If an object has no readable representation, then an error is signalled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 When print-readably is true, compiled-function objects will be written in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 #[...] form instead of in #<compiled-function [...]> form, and two-element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 lists of the form (quote object) will be written as the equivalent 'object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 Do not SET this variable; bind it instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 print_readably = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1783 /* #### I think this should default to t. But we'd better wait
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1784 until we see that it works out. */
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1785 DEFVAR_LISP ("print-gensym", &Vprint_gensym /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 If non-nil, then uninterned symbols will be printed specially.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 Uninterned symbols are those which are not present in `obarray', that is,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 those which were made with `make-symbol' or by calling `intern' with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 second argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1791 When print-gensym is true, such symbols will be preceded by "#:",
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1792 which causes the reader to create a new symbol instead of interning
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1793 and returning an existing one. Beware: the #: syntax creates a new
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1794 symbol each time it is seen, so if you print an object which contains
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1795 two pointers to the same uninterned symbol, `read' will not duplicate
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1796 that structure.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1798 If the value of `print-gensym' is a cons cell, then in addition
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1799 refrain from clearing `print-gensym-alist' on entry to and exit from
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1800 printing functions, so that the use of #...# and #...= can carry over
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1801 for several separately printed objects.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 */ );
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1803 Vprint_gensym = Qnil;
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1804
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1805 DEFVAR_LISP ("print-gensym-alist", &Vprint_gensym_alist /*
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1806 Association list of elements (GENSYM . N) to guide use of #N# and #N=.
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1807 In each element, GENSYM is an uninterned symbol that has been associated
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1808 with #N= for the specified value of N.
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1809 */ );
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 233
diff changeset
1810 Vprint_gensym_alist = Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 DEFVAR_LISP ("print-message-label", &Vprint_message_label /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 Label for minibuffer messages created with `print'. This should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 generally be bound with `let' rather than set. (See `display-message'.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 Vprint_message_label = Qprint;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 }