annotate src/print.c @ 371:cc15677e0335 r21-2b1

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