annotate src/print.c @ 3063:d30cd499e445

[xemacs-hg @ 2005-11-13 10:48:01 by ben] further error-checking, etc. alloc.c, lrecord.h: Move around the handling of setting of lheader->uid so it's in set_lheader_implementation() -- that way, even non-MC-ALLOC builds get useful uid's in their bare lrecords. Redo related code for strings so the non-ascii count that is stored in the uid isn't hosed. events.c: Save and restore the uid around event zeroing/deadbeefing. lisp.h: Set the correct value of MAX_STRING_ASCII_BEGIN under MC_ALLOC. lisp.h: rearrange the basic code handling ints and chars. basic int stuff goes first, followed by basic char stuff, followed in turn by stuff that mixes ints and chars. this is required since some basic defn's have become inline functions. XCHAR and CHARP have additional error-checking in that they check to make sure that the value in question is not just a character but a valid character (i.e. its numeric value is valid). print.c: debug_p4 now has a useful UID in all cases and uses it; but it also prints the raw header address (previously, you just got one of them). text.h: some basic char defn's that belonged in lisp.h have been moved there. valid_ichar_p() is moved too since the inline functions need it.
author ben
date Sun, 13 Nov 2005 10:48:04 +0000
parents b7f26b2f78bd
children d9ca850d40de 3742ea8250b5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Lisp object printing and output streams.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1988, 1992-1995 Free Software Foundation, Inc.
3063
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3024
diff changeset
3 Copyright (C) 1995, 1996, 2000, 2001, 2002, 2003, 2005 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Not synched with FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* This file has been Mule-ized. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
26 /* Seriously divergent from FSF by this point.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
27
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
28 Seriously hacked on by Ben Wing for Mule. All stdio code also by Ben,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
29 as well as the debugging code (initial version of debug_print(), though,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
30 by Jamie Zawinski) and the _fmt interfaces. Also a fair amount of work
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
31 by Hrvoje, e.g. floating-point code and rewriting to avoid O(N^2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
32 consing when outputting to the echo area. Print-circularity code by
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
33 Martin? */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include "backtrace.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "bytecode.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
41 #include "device-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #include "extents.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 #include "insdel.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 #include "lstream.h"
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
46 #include "opaque.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
47
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
48 #include "console-tty-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
49 #include "console-stream-impl.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
50 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
51 #include "console-msw.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
52 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
54 #include "sysfile.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
55
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 #include <float.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 /* Define if not in float.h */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 #ifndef DBL_DIG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #define DBL_DIG 16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 Lisp_Object Vstandard_output, Qstandard_output;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 /* The subroutine object for external-debugging-output is kept here
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 for the convenience of the debugger. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
66 Lisp_Object Qexternal_debugging_output, Qalternate_debugging_output;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
67
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
68 #ifdef HAVE_MS_WINDOWS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
69 Lisp_Object Qmswindows_debugging_output;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
70 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 /* Avoid actual stack overflow in print. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 static int print_depth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 /* Detect most circularities to print finite output. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 #define PRINT_CIRCLE 200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 static Lisp_Object being_printed[PRINT_CIRCLE];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 /* Maximum length of list or vector to print in full; noninteger means
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 effectively infinity */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 Lisp_Object Vprint_length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 Lisp_Object Qprint_length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 /* Maximum length of string to print in full; noninteger means
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 effectively infinity */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 Lisp_Object Vprint_string_length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 Lisp_Object Qprint_string_length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 /* Maximum depth of list to print in full; noninteger means
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 effectively infinity. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 Lisp_Object Vprint_level;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 /* Label to use when making echo-area messages. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 Lisp_Object Vprint_message_label;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 /* Nonzero means print newlines in strings as \n. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 int print_escape_newlines;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 int print_readably;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 /* Non-nil means print #: before uninterned symbols.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 Neither t nor nil means so that and don't clear Vprint_gensym_alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 on entry to and exit from print functions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 Lisp_Object Vprint_gensym;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 Lisp_Object Vprint_gensym_alist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 Lisp_Object Qdisplay_error;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 Lisp_Object Qprint_message_label;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 /* Force immediate output of all printed data. Used for debugging. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 int print_unbuffered;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 FILE *termscript; /* Stdio stream being used for copy of all output. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
119 static void write_string_to_alternate_debugging_output (const Ibyte *str,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
120 Bytecount len);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
121
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
122 /* To avoid consing in debug_prin1, we package up variables we need to bind
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
123 into an opaque object. */
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
124 struct debug_bindings
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
125 {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
126 int inhibit_non_essential_conversion_operations;
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
127 int print_depth;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
128 int print_readably;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
129 int print_unbuffered;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
130 int gc_currently_forbidden;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
131 Lisp_Object Vprint_length;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
132 Lisp_Object Vprint_level;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
133 Lisp_Object Vinhibit_quit;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
134 };
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
135
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
136 static Lisp_Object debug_prin1_bindings;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 int stdout_needs_newline;
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
140 int stdout_clear_before_next_output;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
142 /* Basic function to actually write to a stdio stream or TTY console. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
143
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144 static void
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
145 write_string_to_stdio_stream_1 (FILE *stream, struct console *con,
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
146 const Ibyte *ptr, Bytecount len,
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
147 int must_flush)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
149 Extbyte *extptr = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
150 Bytecount extlen = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
151 int output_is_std_handle =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
152 stream ? stream == stdout || stream == stderr :
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
153 CONSOLE_TTY_DATA (con)->is_stdio;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
154
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
155 if (stream || output_is_std_handle)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
156 {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
157 if (initialized && !inhibit_non_essential_conversion_operations)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
158 TO_EXTERNAL_FORMAT (DATA, (ptr, len),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
159 ALLOCA, (extptr, extlen),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
160 Qterminal);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
161 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
162 {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
163 #ifdef NON_ASCII_INTERNAL_FORMAT
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
164 #error Do something here
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
165 #else
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
166 extptr = (Extbyte *) ptr;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
167 extlen = (Bytecount) len;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
168 #endif
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
169 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
170 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
171
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 if (stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
174 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
175 HANDLE errhand = GetStdHandle (STD_INPUT_HANDLE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
176 int no_useful_stderr = errhand == 0 || errhand == INVALID_HANDLE_VALUE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
177
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
178 if (!no_useful_stderr)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
179 no_useful_stderr = !PeekNamedPipe (errhand, 0, 0, 0, 0, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
180 /* we typically have no useful stdout/stderr under windows if we're
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
181 being invoked graphically. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
182 if (no_useful_stderr)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
183 mswindows_output_console_string (ptr, len);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
184 else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
186 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
187 retry_fwrite (extptr, 1, extlen, stream);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
188 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
189 /* Q122442 says that pipes are "treated as files, not as
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
190 devices", and that this is a feature. Before I found that
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
191 article, I thought it was a bug. Thanks MS, I feel much
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
192 better now. - kkm */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
193 must_flush = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
194 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
195 if (must_flush)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
196 fflush (stream);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
197 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 else
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
200 /* The stream itself does conversion to external format */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
201 Lstream_write (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream), ptr, len);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
202
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
203 if (output_is_std_handle)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 if (termscript)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
207 retry_fwrite (extptr, 1, extlen, termscript);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 fflush (termscript);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 }
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
210 stdout_needs_newline = (ptr[len - 1] != '\n');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
214 /* Write to a stdio stream or TTY console, first clearing the left side
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
215 if necessary. */
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
216
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
217 static void
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
218 write_string_to_stdio_stream (FILE *stream, struct console *con,
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
219 const Ibyte *ptr, Bytecount len,
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
220 int must_flush)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
221 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
222 if (stdout_clear_before_next_output &&
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
223 (stream ? stream == stdout || stream == stderr :
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
224 CONSOLE_TTY_DATA (con)->is_stdio))
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
225 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
226 if (stdout_needs_newline)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
227 write_string_to_stdio_stream_1 (stream, con, (Ibyte *) "\n", 1,
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
228 must_flush);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
229 stdout_clear_before_next_output = 0;
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
230 }
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
231
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
232 write_string_to_stdio_stream_1 (stream, con, ptr, len, must_flush);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
233 }
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
234
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
235 /*
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
236 EXT_PRINT_STDOUT = stdout or its equivalent (may be a
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
237 console window under MS Windows)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
238 EXT_PRINT_STDERR = stderr or its equivalent (may be a
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
239 console window under MS Windows)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
240 EXT_PRINT_ALTERNATE = an internal character array; see
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
241 `alternate-debugging-output'
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
242 EXT_PRINT_MSWINDOWS = Under MS Windows, the "debugging output" that
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
243 debuggers can hook into; uses OutputDebugString()
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
244 system call
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
245 EXT_PRINT_ALL = all of the above except stdout
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
246 */
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
247
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
248 enum ext_print
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
249 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
250 EXT_PRINT_STDOUT = 1,
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
251 EXT_PRINT_STDERR = 2,
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
252 EXT_PRINT_ALTERNATE = 4,
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
253 EXT_PRINT_MSWINDOWS = 8,
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
254 EXT_PRINT_ALL = 14
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
255 };
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
256
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
257 static void
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
258 write_string_to_external_output (const Ibyte *ptr, Bytecount len,
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
259 int dest)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
260 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
261 if (dest & EXT_PRINT_STDOUT)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
262 write_string_to_stdio_stream (stdout, 0, ptr, len, 1);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
263 if (dest & EXT_PRINT_STDERR)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
264 write_string_to_stdio_stream (stderr, 0, ptr, len, 1);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
265 if (dest & EXT_PRINT_ALTERNATE)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
266 write_string_to_alternate_debugging_output (ptr, len);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
267 #ifdef WIN32_NATIVE
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
268 if (dest & EXT_PRINT_MSWINDOWS)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
269 write_string_to_mswindows_debugging_output (ptr, len);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
270 #endif
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
271 }
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
272
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
273 /* #### The following function should make use of a call to the
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
274 emacs_vsprintf_*() functions rather than just using vsprintf. This is
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
275 the only way to ensure that I18N3 works properly (many implementations
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
276 of the *printf() functions, including the ones included in glibc, do not
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
277 implement the %###$ argument-positioning syntax).
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
278
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
279 Note, however, that to do this, we'd have to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
280
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
281 1) pre-allocate all the lstreams and do whatever else was necessary
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
282 to make sure that no allocation occurs, since these functions may be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
283 called from fatal_error_signal().
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
284
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
285 2) (to be really correct) make a new lstream that outputs using
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
286 mswindows_output_console_string().
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
287
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
288 3) A reasonable compromise might be to use emacs_vsprintf() when we're
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
289 in a safe state, and when not, use plain vsprintf(). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
290
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
291 static void
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
292 write_string_to_external_output_va (const CIbyte *fmt, va_list args,
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
293 int dest)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
294 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
295 Ibyte kludge[8192];
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
296 Bytecount kludgelen;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
297
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
298 if (initialized && !inhibit_non_essential_conversion_operations)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
299 fmt = GETTEXT (fmt);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
300 vsprintf ((CIbyte *) kludge, fmt, args);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
301 kludgelen = qxestrlen (kludge);
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
302 write_string_to_external_output (kludge, kludgelen, dest);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
303 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
304
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
305 /* Output portably to stderr or its equivalent (i.e. may be a console
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
306 window under MS Windows); do external-format conversion and call GETTEXT
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
307 on the format string. Automatically flush when done.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
308
2731
3213c79d6672 [xemacs-hg @ 2005-04-14 09:44:24 by stephent]
stephent
parents: 2720
diff changeset
309 NOTE: CIbyte means "internal format" data. This includes the "..."
3213c79d6672 [xemacs-hg @ 2005-04-14 09:44:24 by stephent]
stephent
parents: 2720
diff changeset
310 arguments. For numerical arguments, we have to assume that vsprintf
3213c79d6672 [xemacs-hg @ 2005-04-14 09:44:24 by stephent]
stephent
parents: 2720
diff changeset
311 will be a good boy and format them as ASCII. For Mule internal coding
3213c79d6672 [xemacs-hg @ 2005-04-14 09:44:24 by stephent]
stephent
parents: 2720
diff changeset
312 (and UTF-8 internal coding, if/when we get it), it is safe to pass
3213c79d6672 [xemacs-hg @ 2005-04-14 09:44:24 by stephent]
stephent
parents: 2720
diff changeset
313 string values in internal format to be formatted, because zero octets
3213c79d6672 [xemacs-hg @ 2005-04-14 09:44:24 by stephent]
stephent
parents: 2720
diff changeset
314 only occur in the NUL character itself. Similarly, it is safe to pass
3213c79d6672 [xemacs-hg @ 2005-04-14 09:44:24 by stephent]
stephent
parents: 2720
diff changeset
315 pure ASCII literal strings for these functions. *Everything else must
3213c79d6672 [xemacs-hg @ 2005-04-14 09:44:24 by stephent]
stephent
parents: 2720
diff changeset
316 be converted, including all external data.*
3213c79d6672 [xemacs-hg @ 2005-04-14 09:44:24 by stephent]
stephent
parents: 2720
diff changeset
317
3213c79d6672 [xemacs-hg @ 2005-04-14 09:44:24 by stephent]
stephent
parents: 2720
diff changeset
318 This function is safe to use even when not initialized or when dying --
3213c79d6672 [xemacs-hg @ 2005-04-14 09:44:24 by stephent]
stephent
parents: 2720
diff changeset
319 we don't do conversion in such cases. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
320
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
321 void
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
322 stderr_out (const CIbyte *fmt, ...)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
323 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
324 va_list args;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
325 va_start (args, fmt);
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
326 write_string_to_external_output_va (fmt, args, EXT_PRINT_STDERR);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
327 va_end (args);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
328 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
329
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
330 /* Output portably to stdout or its equivalent (i.e. may be a console
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
331 window under MS Windows). Works like stderr_out(). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
332
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
333 void
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
334 stdout_out (const CIbyte *fmt, ...)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
335 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
336 va_list args;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
337 va_start (args, fmt);
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
338 write_string_to_external_output_va (fmt, args, EXT_PRINT_STDOUT);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
339 va_end (args);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
340 }
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
341
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
342 /* Output portably to print destination as specified by DEST. */
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
343
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
344 void
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
345 external_out (int dest, const CIbyte *fmt, ...)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
346 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
347 va_list args;
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
348 va_start (args, fmt);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
349 write_string_to_external_output_va (fmt, args, dest);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
350 va_end (args);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
351 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
352
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
353 /* Output portably to stderr or its equivalent (i.e. may be a console
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
354 window under MS Windows), as well as alternate-debugging-output and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
355 (under MS Windows) the C debugging output, i.e. OutputDebugString().
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
356 Works like stderr_out(). */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
357
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
358 void
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
359 debug_out (const CIbyte *fmt, ...)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
360 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
361 va_list args;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
362 va_start (args, fmt);
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
363 write_string_to_external_output_va (fmt, args, EXT_PRINT_ALL);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
364 va_end (args);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
365 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
366
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
367 DOESNT_RETURN
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
368 fatal (const CIbyte *fmt, ...)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
369 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
370 va_list args;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
371 va_start (args, fmt);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
372
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
373 stderr_out ("\nXEmacs: fatal error: ");
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
374 write_string_to_external_output_va (fmt, args, EXT_PRINT_STDERR);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
375 stderr_out ("\n");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
376
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
377 va_end (args);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
378 exit (1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
379 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
380
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 /* Write a string to the output location specified in FUNCTION.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 Arguments NONRELOC, RELOC, OFFSET, and LEN are as in
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
383 buffer_insert_string_1() in insdel.c.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
384
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
385 FUNCTION is one of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
386
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
387 -- an lstream
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
388 -- a buffer (insert at point and advance point)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
389 -- a marker (insert at marker and advance marker)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
390 -- a frame (append to echo area; clear echo area first if
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
391 `print-message-label' has changed since the last time)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
392 -- t or nil (send to stdout)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
393 -- a Lisp function of one argument (call to get data output)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
394
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
395 Use Qexternal_debugging_output to get output to stderr.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
396 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 static void
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
399 output_string (Lisp_Object function, const Ibyte *nonreloc,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 Lisp_Object reloc, Bytecount offset, Bytecount len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 Charcount cclen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 /* We change the value of nonreloc (fetching it from reloc as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 necessary), but we don't want to pass this changed value on to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 other functions that take both a nonreloc and a reloc, or things
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 may get confused and an assertion failure in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 fixup_internal_substring() may get triggered. */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
409 const Ibyte *newnonreloc = nonreloc;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 /* Emacs won't print while GCing, but an external debugger might */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
413 #ifdef NO_PRINT_DURING_GC
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 if (gc_in_progress) return;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
415 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 /* Perhaps not necessary but probably safer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 GCPRO2 (function, reloc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 fixup_internal_substring (newnonreloc, reloc, offset, &len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 if (STRINGP (reloc))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
423 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
424 cclen = string_offset_byte_to_char_len (reloc, offset, len);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
425 newnonreloc = XSTRING_DATA (reloc);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
426 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
427 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
428 cclen = bytecount_to_charcount (newnonreloc + offset, len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 if (LSTREAMP (function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 if (STRINGP (reloc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 /* Protect against Lstream_write() causing a GC and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 relocating the string. For small strings, we do it by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 alloc'ing the string and using a copy; for large strings,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 we inhibit GC. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 if (len < 65536)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
440 Ibyte *copied = alloca_ibytes (len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 memcpy (copied, newnonreloc + offset, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 Lstream_write (XLSTREAM (function), copied, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 }
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
444 else if (gc_currently_forbidden)
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
445 {
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
446 /* Avoid calling begin_gc_forbidden, which conses. We can reach
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
447 this point from the cons debug code, which will get us into
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
448 an infinite loop if we cons again. */
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
449 Lstream_write (XLSTREAM (function), newnonreloc + offset, len);
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
450 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
453 int speccount = begin_gc_forbidden ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 Lstream_write (XLSTREAM (function), newnonreloc + offset, len);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
455 unbind_to (speccount);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 Lstream_write (XLSTREAM (function), newnonreloc + offset, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 if (print_unbuffered)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 Lstream_flush (XLSTREAM (function));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 else if (BUFFERP (function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 CHECK_LIVE_BUFFER (function);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 buffer_insert_string (XBUFFER (function), nonreloc, reloc, offset, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 else if (MARKERP (function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 /* marker_position() will err if marker doesn't point anywhere. */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 603
diff changeset
472 Charbpos spoint = marker_position (function);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 buffer_insert_string_1 (XMARKER (function)->buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 spoint, nonreloc, reloc, offset, len,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 Fset_marker (function, make_int (spoint + cclen),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 Fmarker_buffer (function));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 else if (FRAMEP (function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 /* This gets used by functions not invoking print_prepare(),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 such as Fwrite_char, Fterpri, etc.. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 struct frame *f = XFRAME (function);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 CHECK_LIVE_FRAME (function);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 if (!EQ (Vprint_message_label, echo_area_status (f)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 clear_echo_area_from_print (f, Qnil, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 echo_area_append (f, nonreloc, reloc, offset, len, Vprint_message_label);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 else if (EQ (function, Qt) || EQ (function, Qnil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
493 write_string_to_stdio_stream (stdout, 0, newnonreloc + offset, len,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
494 print_unbuffered);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
495 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
496 else if (EQ (function, Qexternal_debugging_output))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
497 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
498 /* This is not strictly necessary, and somewhat of a hack, but it
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
499 avoids having each character passed separately to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
500 `external-debugging-output'. #### Why do we pass each character
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
501 separately, anyway?
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
502 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
503 write_string_to_stdio_stream (stderr, 0, newnonreloc + offset, len,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
504 print_unbuffered);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
508 Charcount ccoff;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 Charcount iii;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
511 if (STRINGP (reloc))
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
512 ccoff = string_index_byte_to_char (reloc, offset);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
513 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
514 ccoff = bytecount_to_charcount (newnonreloc, offset);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
515
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
516 if (STRINGP (reloc))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
518 for (iii = ccoff; iii < cclen + ccoff; iii++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
519 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
520 call1 (function, make_char (string_ichar (reloc, iii)));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
521 if (STRINGP (reloc))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
522 newnonreloc = XSTRING_DATA (reloc);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
523 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
524 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
525 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
526 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
527 for (iii = ccoff; iii < cclen + ccoff; iii++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
528 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
529 call1 (function,
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
530 make_char (itext_ichar_n (newnonreloc, iii)));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
531 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 #define RESET_PRINT_GENSYM do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 if (!CONSP (Vprint_gensym)) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 Vprint_gensym_alist = Qnil; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542
1261
465bd3c7d932 [xemacs-hg @ 2003-02-06 06:35:47 by ben]
ben
parents: 1204
diff changeset
543 Lisp_Object
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 canonicalize_printcharfun (Lisp_Object printcharfun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 if (NILP (printcharfun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 printcharfun = Vstandard_output;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548
1261
465bd3c7d932 [xemacs-hg @ 2003-02-06 06:35:47 by ben]
ben
parents: 1204
diff changeset
549 if (!noninteractive && (EQ (printcharfun, Qt) || NILP (printcharfun)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 printcharfun = Fselected_frame (Qnil); /* print to minibuffer */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 return printcharfun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 print_prepare (Lisp_Object printcharfun, Lisp_Object *frame_kludge)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 /* Emacs won't print while GCing, but an external debugger might */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
559 #ifdef NO_PRINT_DURING_GC
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 if (gc_in_progress)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 return Qnil;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
562 #endif
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
563
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 RESET_PRINT_GENSYM;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 printcharfun = canonicalize_printcharfun (printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 /* Here we could safely return the canonicalized PRINTCHARFUN.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 However, if PRINTCHARFUN is a frame, printing of complex
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 structures becomes very expensive, because `append-message'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 (called by echo_area_append) gets called as many times as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 output_string() is called (and that's a *lot*). append-message
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 tries to keep top of the message-stack in sync with the contents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 of " *Echo Area" buffer, consing a new string for each component
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 of the printed structure. For instance, if you print (a a),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 append-message will cons up the following strings:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 "("
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 "(a"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 "(a "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 "(a a"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 "(a a)"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 and will use only the last one. With larger objects, this turns
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 into an O(n^2) consing frenzy that locks up XEmacs in incessant
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 garbage collection.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 We prevent this by creating a resizing_buffer stream and letting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 the printer write into it. print_finish() will notice this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 stream, and invoke echo_area_append() with the stream's buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 only once. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 if (FRAMEP (printcharfun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 CHECK_LIVE_FRAME (printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 *frame_kludge = printcharfun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 printcharfun = make_resizing_buffer_output_stream ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 return printcharfun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 print_finish (Lisp_Object stream, Lisp_Object frame_kludge)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 /* Emacs won't print while GCing, but an external debugger might */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
606 #ifdef NO_PRINT_DURING_GC
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 if (gc_in_progress)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 return;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
609 #endif
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
610
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 RESET_PRINT_GENSYM;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 /* See the comment in print_prepare(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 if (FRAMEP (frame_kludge))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 struct frame *f = XFRAME (frame_kludge);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 Lstream *str = XLSTREAM (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 CHECK_LIVE_FRAME (frame_kludge);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 Lstream_flush (str);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 if (!EQ (Vprint_message_label, echo_area_status (f)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 clear_echo_area_from_print (f, Qnil, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 echo_area_append (f, resizing_buffer_stream_ptr (str),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 Qnil, 0, Lstream_byte_count (str),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 Vprint_message_label);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 Lstream_delete (str);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
631 /* Write internal-format data to STREAM. See output_string() for
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
632 interpretation of STREAM.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
633
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
634 NOTE: Do not call this with the data of a Lisp_String, as
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 printcharfun might cause a GC, which might cause the string's data
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 to be relocated. To princ a Lisp string, use:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 print_internal (string, printcharfun, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 Also note that STREAM should be the result of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 canonicalize_printcharfun() (i.e. Qnil means stdout, not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 Vstandard_output, etc.) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 void
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
644 write_string_1 (Lisp_Object stream, const Ibyte *str, Bytecount size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 /* This function can GC */
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
647 #ifdef ERROR_CHECK_TEXT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 assert (size >= 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 output_string (stream, str, Qnil, 0, size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 void
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
654 write_string (Lisp_Object stream, const Ibyte *str)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
655 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
656 /* This function can GC */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
657 write_string_1 (stream, str, qxestrlen (str));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
658 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
659
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
660 void
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
661 write_c_string (Lisp_Object stream, const CIbyte *str)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 /* This function can GC */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
664 write_string_1 (stream, (const Ibyte *) str, strlen (str));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
667 void
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
668 write_eistring (Lisp_Object stream, const Eistring *ei)
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
669 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
670 write_string_1 (stream, eidata (ei), eilen (ei));
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
671 }
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
672
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
673 /* Write a printf-style string to STREAM; see output_string(). */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
674
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
675 void
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
676 write_fmt_string (Lisp_Object stream, const CIbyte *fmt, ...)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
677 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
678 va_list va;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
679 Ibyte *str;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
680 Bytecount len;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
681 int count;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
682
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
683 va_start (va, fmt);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
684 str = emacs_vsprintf_malloc (fmt, va, &len);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
685 va_end (va);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
686 count = record_unwind_protect_freeing (str);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
687 write_string_1 (stream, str, len);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
688 unbind_to (count);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
689 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
690
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
691 /* Write a printf-style string to STREAM, where the arguments are
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
692 Lisp objects and not C strings or integers; see output_string().
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
693
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
694 #### It shouldn't be necessary to specify the number of arguments.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
695 This would require some rewriting of the doprnt() functions, though. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
696
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
697 void
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
698 write_fmt_string_lisp (Lisp_Object stream, const CIbyte *fmt, int nargs, ...)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
699 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
700 Lisp_Object *args = alloca_array (Lisp_Object, nargs);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
701 va_list va;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
702 int i;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
703 Ibyte *str;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
704 Bytecount len;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
705 int count;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
706
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
707 va_start (va, nargs);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
708 for (i = 0; i < nargs; i++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
709 args[i] = va_arg (va, Lisp_Object);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
710 va_end (va);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
711 str = emacs_vsprintf_malloc_lisp (fmt, Qnil, nargs, args, &len);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
712 count = record_unwind_protect_freeing (str);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
713 write_string_1 (stream, str, len);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
714 unbind_to (count);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
715 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
716
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
717 void
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
718 stderr_out_lisp (const CIbyte *fmt, int nargs, ...)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
719 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
720 Lisp_Object *args = alloca_array (Lisp_Object, nargs);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
721 va_list va;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
722 int i;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
723 Ibyte *str;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
724 Bytecount len;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
725 int count;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
726
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
727 va_start (va, nargs);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
728 for (i = 0; i < nargs; i++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
729 args[i] = va_arg (va, Lisp_Object);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
730 va_end (va);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
731 str = emacs_vsprintf_malloc_lisp (fmt, Qnil, nargs, args, &len);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
732 count = record_unwind_protect_freeing (str);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
733 write_string_1 (Qexternal_debugging_output, str, len);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
734 unbind_to (count);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
735 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
736
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 DEFUN ("write-char", Fwrite_char, 1, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
739 Output character CHARACTER to stream STREAM.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 STREAM defaults to the value of `standard-output' (which see).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
742 (character, stream))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 /* This function can GC */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
745 Ibyte str[MAX_ICHAR_LEN];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 Bytecount len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
748 CHECK_CHAR_COERCE_INT (character);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
749 len = set_itext_ichar (str, XCHAR (character));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 output_string (canonicalize_printcharfun (stream), str, Qnil, 0, len);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
751 return character;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 temp_output_buffer_setup (Lisp_Object bufname)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 struct buffer *old = current_buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 Lisp_Object buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 /* #### This function should accept a Lisp_Object instead of a char *,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 so that proper translation on the buffer name can occur. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 Fset_buffer (Fget_buffer_create (bufname));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 current_buffer->read_only = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 Ferase_buffer (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
771 buf = wrap_buffer (current_buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 specbind (Qstandard_output, buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 set_buffer_internal (old);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 internal_with_output_to_temp_buffer (Lisp_Object bufname,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 Lisp_Object (*function) (Lisp_Object arg),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 Lisp_Object arg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 Lisp_Object same_frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 int speccount = specpdl_depth ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 struct gcpro gcpro1, gcpro2, gcpro3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 Lisp_Object buf = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 GCPRO3 (buf, arg, same_frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 temp_output_buffer_setup (bufname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 buf = Vstandard_output;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 arg = (*function) (arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 temp_output_buffer_show (buf, same_frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
797 return unbind_to_1 (speccount, arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, 1, UNEVALLED, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 The buffer is cleared out initially, and marked as unmodified when done.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 All output done by BODY is inserted in that buffer by default.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 The buffer is displayed in another window, but not selected.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 The value of the last form in BODY is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 If BODY does not finish normally, the buffer BUFNAME is not displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 If variable `temp-buffer-show-function' is non-nil, call it at the end
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 to get the buffer displayed. It gets one argument, the buffer to display.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 (args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 Lisp_Object name = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 int speccount = specpdl_depth ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 Lisp_Object val = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 /* #### should set the buffer to be translating. See print_internal(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 GCPRO2 (name, val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 name = Feval (XCAR (args));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 CHECK_STRING (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 temp_output_buffer_setup (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 val = Fprogn (XCDR (args));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 temp_output_buffer_show (Vstandard_output, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
835 return unbind_to_1 (speccount, val);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 DEFUN ("terpri", Fterpri, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 Output a newline to STREAM.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 If STREAM is omitted or nil, the value of `standard-output' is used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 (stream))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 /* This function can GC */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
845 write_c_string (canonicalize_printcharfun (stream), "\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 DEFUN ("prin1", Fprin1, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 Output the printed representation of OBJECT, any Lisp object.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 Quoting characters are printed when needed to make output that `read'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 can handle, whenever this is possible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 Output stream is STREAM, or value of `standard-output' (which see).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 (object, stream))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 Lisp_Object frame = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 GCPRO2 (object, stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 stream = print_prepare (stream, &frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 print_internal (object, stream, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 print_finish (stream, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 return object;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 DEFUN ("prin1-to-string", Fprin1_to_string, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 Return a string containing the printed representation of OBJECT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 any Lisp object. Quoting characters are used when needed to make output
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 that `read' can handle, whenever this is possible, unless the optional
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 second argument NOESCAPE is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 (object, noescape))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 Lisp_Object result = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 Lisp_Object stream = make_resizing_buffer_output_stream ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 Lstream *str = XLSTREAM (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 /* gcpro OBJECT in case a caller forgot to do so */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 struct gcpro gcpro1, gcpro2, gcpro3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 GCPRO3 (object, stream, result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 RESET_PRINT_GENSYM;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 print_internal (object, stream, NILP (noescape));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 RESET_PRINT_GENSYM;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 Lstream_flush (str);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 result = make_string (resizing_buffer_stream_ptr (str),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 Lstream_byte_count (str));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 Lstream_delete (str);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 DEFUN ("princ", Fprinc, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 Output the printed representation of OBJECT, any Lisp object.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 No quoting characters are used; no delimiters are printed around
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 the contents of strings.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
901 Output stream is STREAM, or value of `standard-output' (which see).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 (object, stream))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 Lisp_Object frame = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 GCPRO2 (object, stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 stream = print_prepare (stream, &frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 print_internal (object, stream, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 print_finish (stream, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 return object;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 DEFUN ("print", Fprint, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 Output the printed representation of OBJECT, with newlines around it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 Quoting characters are printed when needed to make output that `read'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 can handle, whenever this is possible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 Output stream is STREAM, or value of `standard-output' (which see).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 (object, stream))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 Lisp_Object frame = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 GCPRO2 (object, stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 stream = print_prepare (stream, &frame);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
931 write_c_string (stream, "\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 print_internal (object, stream, 1);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
933 write_c_string (stream, "\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 print_finish (stream, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 return object;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 /* Print an error message for the error DATA to STREAM. This is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 complete implementation of `display-error', which used to be in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 Lisp (see prim/cmdloop.el). It was ported to C so it can be used
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 efficiently by Ferror_message_string. Fdisplay_error and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 Ferror_message_string are trivial wrappers around this function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 STREAM should be the result of canonicalize_printcharfun(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 print_error_message (Lisp_Object error_object, Lisp_Object stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 Lisp_Object type = Fcar_safe (error_object);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 Lisp_Object method = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 Lisp_Object tail;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 /* No need to GCPRO anything under the assumption that ERROR_OBJECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 is GCPRO'd. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 if (! (CONSP (error_object) && SYMBOLP (type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 && CONSP (Fget (type, Qerror_conditions, Qnil))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 goto error_throw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 tail = XCDR (error_object);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 while (!NILP (tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 if (CONSP (tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 tail = XCDR (tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 goto error_throw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 tail = Fget (type, Qerror_conditions, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 while (!NILP (tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 if (!(CONSP (tail) && SYMBOLP (XCAR (tail))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 goto error_throw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 else if (!NILP (Fget (XCAR (tail), Qdisplay_error, Qnil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 method = Fget (XCAR (tail), Qdisplay_error, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 goto error_throw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 tail = XCDR (tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 /* Default method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 int first = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 int speccount = specpdl_depth ();
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
986 Lisp_Object frame = Qnil;
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
987 struct gcpro gcpro1;
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
988 GCPRO1 (stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 specbind (Qprint_message_label, Qerror);
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
991 stream = print_prepare (stream, &frame);
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
992
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 tail = Fcdr (error_object);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 if (EQ (type, Qerror))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 print_internal (Fcar (tail), stream, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 tail = Fcdr (tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 Lisp_Object errmsg = Fget (type, Qerror_message, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 if (NILP (errmsg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 print_internal (type, stream, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 print_internal (LISP_GETTEXT (errmsg), stream, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 while (!NILP (tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1009 write_c_string (stream, first ? ": " : ", ");
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1010 /* Most errors have an explanatory string as their first argument,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1011 and it looks better not to put the quotes around it. */
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1012 print_internal (Fcar (tail), stream,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1013 !(first && STRINGP (Fcar (tail))) ||
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1014 !NILP (Fget (type, Qerror_lacks_explanatory_string,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1015 Qnil)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 tail = Fcdr (tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 first = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 }
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
1019 print_finish (stream, frame);
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
1020 UNGCPRO;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1021 unbind_to (speccount);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 /* not reached */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 error_throw:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 if (NILP (method))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1029 write_c_string (stream, GETTEXT ("Peculiar error "));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 print_internal (error_object, stream, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 call2 (method, error_object, stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 DEFUN ("error-message-string", Ferror_message_string, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 Convert ERROR-OBJECT to an error message, and return it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 The format of ERROR-OBJECT should be (ERROR-SYMBOL . DATA). The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 message is equivalent to the one that would be issued by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 `display-error' with the same argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 (error_object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 Lisp_Object result = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 Lisp_Object stream = make_resizing_buffer_output_stream ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 GCPRO1 (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 print_error_message (error_object, stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 Lstream_flush (XLSTREAM (stream));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 result = make_string (resizing_buffer_stream_ptr (XLSTREAM (stream)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 Lstream_byte_count (XLSTREAM (stream)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 Lstream_delete (XLSTREAM (stream));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 DEFUN ("display-error", Fdisplay_error, 2, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 Display ERROR-OBJECT on STREAM in a user-friendly way.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 (error_object, stream))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 print_error_message (error_object, canonicalize_printcharfun (stream));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 Lisp_Object Vfloat_output_format;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 * This buffer should be at least as large as the max string size of the
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1079 * largest float, printed in the biggest notation. This is undoubtedly
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 * 20d float_output_format, with the negative of the C-constant "HUGE"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 * from <math.h>.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 * On the vax the worst case is -1e38 in 20d format which takes 61 bytes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 * I assume that IEEE-754 format numbers can take 329 bytes for the worst
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 * case of -1e307 in 20d float_output_format. What is one to do (short of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 * re-writing _doprnt to be more sane)?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 * -wsr
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 float_to_string (char *buf, double data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1093 Ibyte *cp, c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 int width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 if (NILP (Vfloat_output_format)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 || !STRINGP (Vfloat_output_format))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 lose:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 sprintf (buf, "%.16g", data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 else /* oink oink */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 /* Check that the spec we have is fully valid.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 This means not only valid for printf,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 but meant for floats, and reasonable. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 cp = XSTRING_DATA (Vfloat_output_format);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 if (cp[0] != '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 goto lose;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 if (cp[1] != '.')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 goto lose;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 cp += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 for (width = 0; (c = *cp, isdigit (c)); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 width *= 10;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 width += c - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 if (*cp != 'e' && *cp != 'f' && *cp != 'g' && *cp != 'E' && *cp != 'G')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 goto lose;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 if (width < (int) (*cp != 'e' && *cp != 'E') || width > DBL_DIG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 goto lose;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 if (cp[1] != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 goto lose;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 sprintf (buf, (char *) XSTRING_DATA (Vfloat_output_format),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 /* added by jwz: don't allow "1.0" to print as "1"; that destroys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 the read-equivalence of lisp objects. (* x 1) and (* x 1.0) do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 not do the same thing, so it's important that the printed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 representation of that form not be corrupted by the printer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1138 Ibyte *s = (Ibyte *) buf; /* don't use signed chars here!
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 isdigit() can't hack them! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 if (*s == '-') s++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 for (; *s; s++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 /* if there's a non-digit, then there is a decimal point, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 it's in exponential notation, both of which are ok. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 if (!isdigit (*s))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 goto DONE_LABEL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 /* otherwise, we need to hack it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 *s++ = '.';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 *s++ = '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 *s = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 DONE_LABEL:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 /* Some machines print "0.4" as ".4". I don't like that. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 if (buf [0] == '.' || (buf [0] == '-' && buf [1] == '.'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 for (i = strlen (buf) + 1; i >= 0; i--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 buf [i+1] = buf [i];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 buf [(buf [0] == '-' ? 1 : 0)] = '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1163 #define ONE_DIGIT(figure) *p++ = (char) (n / (figure) + '0')
577
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1164 #define ONE_DIGIT_ADVANCE(figure) (ONE_DIGIT (figure), n %= (figure))
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1165
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1166 #define DIGITS_1(figure) ONE_DIGIT (figure)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1167 #define DIGITS_2(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_1 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1168 #define DIGITS_3(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_2 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1169 #define DIGITS_4(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_3 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1170 #define DIGITS_5(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_4 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1171 #define DIGITS_6(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_5 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1172 #define DIGITS_7(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_6 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1173 #define DIGITS_8(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_7 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1174 #define DIGITS_9(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_8 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1175 #define DIGITS_10(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_9 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1176
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1177 /* DIGITS_<11-20> are only used on machines with 64-bit longs. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178
577
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1179 #define DIGITS_11(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_10 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1180 #define DIGITS_12(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_11 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1181 #define DIGITS_13(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_12 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1182 #define DIGITS_14(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_13 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1183 #define DIGITS_15(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_14 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1184 #define DIGITS_16(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_15 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1185 #define DIGITS_17(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_16 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1186 #define DIGITS_18(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_17 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1187 #define DIGITS_19(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_18 ((figure) / 10)
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1188
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1189 /* Print NUMBER to BUFFER in base 10. This is completely equivalent
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1190 to `sprintf(buffer, "%ld", number)', only much faster.
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1191
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1192 The speedup may make a difference in programs that frequently
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1193 convert numbers to strings. Some implementations of sprintf,
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1194 particularly the one in GNU libc, have been known to be extremely
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1195 slow compared to this function.
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1196
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1197 BUFFER should accept as many bytes as you expect the number to take
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1198 up. On machines with 64-bit longs the maximum needed size is 24
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1199 bytes. That includes the worst-case digits, the optional `-' sign,
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1200 and the trailing \0. */
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1201
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1202 void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 long_to_string (char *buffer, long number)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 {
577
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1205 char *p = buffer;
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1206 long n = number;
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1207
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 #if (SIZEOF_LONG != 4) && (SIZEOF_LONG != 8)
577
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1209 /* We are running in a strange or misconfigured environment. Let
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1210 sprintf cope with it. */
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1211 sprintf (buffer, "%ld", n);
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1212 #else /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213
577
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1214 if (n < 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 *p++ = '-';
577
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1217 n = -n;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219
577
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1220 if (n < 10) { DIGITS_1 (1); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1221 else if (n < 100) { DIGITS_2 (10); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1222 else if (n < 1000) { DIGITS_3 (100); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1223 else if (n < 10000) { DIGITS_4 (1000); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1224 else if (n < 100000) { DIGITS_5 (10000); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1225 else if (n < 1000000) { DIGITS_6 (100000); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1226 else if (n < 10000000) { DIGITS_7 (1000000); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1227 else if (n < 100000000) { DIGITS_8 (10000000); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1228 else if (n < 1000000000) { DIGITS_9 (100000000); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1229 #if SIZEOF_LONG == 4
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1230 /* ``if (1)'' serves only to preserve editor indentation. */
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1231 else if (1) { DIGITS_10 (1000000000); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1232 #else /* SIZEOF_LONG != 4 */
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1233 else if (n < 10000000000L) { DIGITS_10 (1000000000L); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1234 else if (n < 100000000000L) { DIGITS_11 (10000000000L); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1235 else if (n < 1000000000000L) { DIGITS_12 (100000000000L); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1236 else if (n < 10000000000000L) { DIGITS_13 (1000000000000L); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1237 else if (n < 100000000000000L) { DIGITS_14 (10000000000000L); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1238 else if (n < 1000000000000000L) { DIGITS_15 (100000000000000L); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1239 else if (n < 10000000000000000L) { DIGITS_16 (1000000000000000L); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1240 else if (n < 100000000000000000L) { DIGITS_17 (10000000000000000L); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1241 else if (n < 1000000000000000000L) { DIGITS_18 (100000000000000000L); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1242 else { DIGITS_19 (1000000000000000000L); }
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1243 #endif /* SIZEOF_LONG != 4 */
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1244
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 #endif /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 }
577
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1248
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1249 #undef ONE_DIGIT
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1250 #undef ONE_DIGIT_ADVANCE
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1251
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1252 #undef DIGITS_1
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1253 #undef DIGITS_2
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1254 #undef DIGITS_3
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1255 #undef DIGITS_4
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1256 #undef DIGITS_5
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1257 #undef DIGITS_6
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1258 #undef DIGITS_7
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1259 #undef DIGITS_8
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1260 #undef DIGITS_9
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1261 #undef DIGITS_10
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1262 #undef DIGITS_11
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1263 #undef DIGITS_12
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1264 #undef DIGITS_13
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1265 #undef DIGITS_14
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1266 #undef DIGITS_15
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1267 #undef DIGITS_16
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1268 #undef DIGITS_17
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1269 #undef DIGITS_18
910449c92002 [xemacs-hg @ 2001-05-25 10:04:26 by hrvojen]
hrvojen
parents: 571
diff changeset
1270 #undef DIGITS_19
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1273 print_vector_internal (const char *start, const char *end,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 Lisp_Object obj,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 Lisp_Object printcharfun, int escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 int len = XVECTOR_LENGTH (obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 int last = len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 GCPRO2 (obj, printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 if (INTP (Vprint_length))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 int max = XINT (Vprint_length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 if (max < len) last = max;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1290 write_c_string (printcharfun, start);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 for (i = 0; i < last; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 Lisp_Object elt = XVECTOR_DATA (obj)[i];
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1294 if (i != 0) write_c_string (printcharfun, " ");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 print_internal (elt, printcharfun, escapeflag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 if (last != len)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1299 write_c_string (printcharfun, " ...");
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1300 write_c_string (printcharfun, end);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 print_cons (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 /* If print_readably is on, print (quote -foo-) as '-foo-
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 (Yeah, this should really be what print-pretty does, but we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 don't have the rest of a pretty printer, and this actually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 has non-negligible impact on size/speed of .elc files.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 if (print_readably &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 EQ (XCAR (obj), Qquote) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 CONSP (XCDR (obj)) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 NILP (XCDR (XCDR (obj))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 obj = XCAR (XCDR (obj));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 GCPRO2 (obj, printcharfun);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1321 write_c_string (printcharfun, "\'");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 print_internal (obj, printcharfun, escapeflag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 GCPRO2 (obj, printcharfun);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1328 write_c_string (printcharfun, "(");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 int max = INTP (Vprint_length) ? XINT (Vprint_length) : INT_MAX;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 Lisp_Object tortoise;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 /* Use tortoise/hare to make sure circular lists don't infloop */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 for (tortoise = obj, len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 CONSP (obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 obj = XCDR (obj), len++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 if (len > 0)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1341 write_c_string (printcharfun, " ");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 if (EQ (obj, tortoise) && len > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 if (print_readably)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1345 printing_unreadable_object ("circular list");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 else
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1347 write_c_string (printcharfun, "... <circular list>");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 if (len & 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 tortoise = XCDR (tortoise);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 if (len > max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1354 write_c_string (printcharfun, "...");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 print_internal (XCAR (obj), printcharfun, escapeflag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 if (!LISTP (obj))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1362 write_c_string (printcharfun, " . ");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 print_internal (obj, printcharfun, escapeflag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1367 write_c_string (printcharfun, ")");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 print_vector (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 print_vector_internal ("[", "]", obj, printcharfun, escapeflag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 print_string (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 /* We distinguish between Bytecounts and Charcounts, to make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 Vprint_string_length work correctly under Mule. */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1382 Charcount size = string_char_length (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 Charcount max = size;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1384 Bytecount bcmax = XSTRING_LENGTH (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 GCPRO2 (obj, printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 if (INTP (Vprint_string_length) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 XINT (Vprint_string_length) < max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 max = XINT (Vprint_string_length);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1392 bcmax = string_index_char_to_byte (obj, max);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 if (max < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 max = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 bcmax = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 if (!escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 /* This deals with GC-relocation and Mule. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 output_string (printcharfun, 0, obj, 0, bcmax);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 if (max < size)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1405 write_c_string (printcharfun, " ...");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 Bytecount i, last = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1411 write_c_string (printcharfun, "\"");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 for (i = 0; i < bcmax; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1414 Ibyte ch = string_byte (obj, i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 if (ch == '\"' || ch == '\\'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 || (ch == '\n' && print_escape_newlines))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 if (i > last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 output_string (printcharfun, 0, obj, last,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 i - last);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 if (ch == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1425 write_c_string (printcharfun, "\\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1429 Ibyte temp[2];
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1430 write_c_string (printcharfun, "\\");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 /* This is correct for Mule because the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 character is either \ or " */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1433 temp[0] = string_byte (obj, i);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1434 temp[1] = '\0';
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1435 write_string (printcharfun, temp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 last = i + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 if (bcmax > last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 output_string (printcharfun, 0, obj, last,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 bcmax - last);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 if (max < size)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1446 write_c_string (printcharfun, " ...");
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1447 write_c_string (printcharfun, "\"");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 default_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2001
diff changeset
1454 int UNUSED (escapeflag))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 {
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 2731
diff changeset
1456 struct LCRECORD_HEADER *header = (struct LCRECORD_HEADER *) XPNTR (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 if (print_readably)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1459 printing_unreadable_object
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1460 ("#<%s 0x%x>",
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
1461 #ifdef MC_ALLOC
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
1462 LHEADER_IMPLEMENTATION (header)->name,
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
1463 #else /* not MC_ALLOC */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1464 LHEADER_IMPLEMENTATION (&header->lheader)->name,
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
1465 #endif /* not MC_ALLOC */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1466 header->uid);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1468 write_fmt_string (printcharfun, "#<%s 0x%x>",
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
1469 #ifdef MC_ALLOC
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
1470 LHEADER_IMPLEMENTATION (header)->name,
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
1471 #else /* not MC_ALLOC */
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1472 LHEADER_IMPLEMENTATION (&header->lheader)->name,
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
1473 #endif /* not MC_ALLOC */
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1474 header->uid);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 internal_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2001
diff changeset
1479 int UNUSED (escapeflag))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 {
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1481 write_fmt_string (printcharfun,
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1482 "#<INTERNAL OBJECT (XEmacs bug?) (%s) 0x%lx>",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1483 XRECORD_LHEADER_IMPLEMENTATION (obj)->name,
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1484 (unsigned long) XPNTR (obj));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1487 enum printing_badness
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1488 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1489 BADNESS_INTEGER_OBJECT,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1490 BADNESS_POINTER_OBJECT,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1491 BADNESS_NO_TYPE
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1492 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1493
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1494 static void
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1495 printing_major_badness (Lisp_Object printcharfun,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1496 Ascbyte *badness_string, int type, void *val,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1497 enum printing_badness badness)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1498 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1499 Ibyte buf[666];
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1500
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1501 switch (badness)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1502 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1503 case BADNESS_INTEGER_OBJECT:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1504 qxesprintf (buf, "%s %d object %ld", badness_string, type,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1505 (EMACS_INT) val);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1506 break;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1507
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1508 case BADNESS_POINTER_OBJECT:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1509 qxesprintf (buf, "%s %d object %p", badness_string, type, val);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1510 break;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1511
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1512 case BADNESS_NO_TYPE:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1513 qxesprintf (buf, "%s object %p", badness_string, val);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1514 break;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1515 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1516
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1517 /* Don't abort or signal if called from debug_print() or already
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1518 crashing */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1519 if (!inhibit_non_essential_conversion_operations)
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1520 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1521 #ifdef ERROR_CHECK_TYPES
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
1522 ABORT ();
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1523 #else /* not ERROR_CHECK_TYPES */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1524 if (print_readably)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1525 signal_ferror (Qinternal_error, "printing %s", buf);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1526 #endif /* not ERROR_CHECK_TYPES */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1527 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1528 write_fmt_string (printcharfun,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1529 "#<EMACS BUG: %s Save your buffers immediately and "
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1530 "please report this bug>", buf);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1531 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1532
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 print_internal (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 /* This function can GC */
2001
cc5b615380f8 [xemacs-hg @ 2004-04-08 15:23:07 by james]
james
parents: 1957
diff changeset
1537 int specdepth = 0;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1538 struct gcpro gcpro1, gcpro2;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1542 #ifdef NO_PRINT_DURING_GC
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 /* Emacs won't print while GCing, but an external debugger might */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 if (gc_in_progress) return;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1545 #endif
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1546
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1547 /* Just to be safe ... */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1548 GCPRO2 (obj, printcharfun);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 /* #### Both input and output streams should have a flag associated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 with them indicating whether output to that stream, or strings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 read from the stream, get translated using Fgettext(). Such a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 stream is called a "translating stream". For the minibuffer and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 external-debugging-output this is always true on output, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 with-output-to-temp-buffer sets the flag to true for the buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 it creates. This flag should also be user-settable. Perhaps it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 should be split up into two flags, one for input and one for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 output. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 /* Detect circularities and truncate them.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 No need to offer any alternative--this is better than an error. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 if (CONSP (obj) || VECTORP (obj) || COMPILED_FUNCTIONP (obj))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 for (i = 0; i < print_depth; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 if (EQ (obj, being_printed[i]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 {
603
1c880911c386 [xemacs-hg @ 2001-06-01 08:23:09 by martinb]
martinb
parents: 579
diff changeset
1570 char buf[DECIMAL_PRINT_SIZE (long) + 1];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 *buf = '#';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 long_to_string (buf + 1, i);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1573 write_c_string (printcharfun, buf);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1574 UNGCPRO;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 being_printed[print_depth] = obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1581 /* Avoid calling internal_bind_int, which conses, when called from
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1582 debug_prin1. In that case, we have bound print_depth to 0 anyway. */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1583 if (!inhibit_non_essential_conversion_operations)
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1584 {
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1585 specdepth = internal_bind_int (&print_depth, print_depth + 1);
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1586
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1587 if (print_depth > PRINT_CIRCLE)
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1588 signal_error (Qstack_overflow, "Apparently circular structure being printed", Qunbound);
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1589 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 switch (XTYPE (obj))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 case Lisp_Type_Int_Even:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 case Lisp_Type_Int_Odd:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 {
603
1c880911c386 [xemacs-hg @ 2001-06-01 08:23:09 by martinb]
martinb
parents: 579
diff changeset
1596 char buf[DECIMAL_PRINT_SIZE (EMACS_INT)];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 long_to_string (buf, XINT (obj));
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1598 write_c_string (printcharfun, buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 case Lisp_Type_Char:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 /* God intended that this be #\..., you know. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 char buf[16];
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1606 Ichar ch = XCHAR (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 char *p = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 *p++ = '?';
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1609 if (ch < 32)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1610 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1611 *p++ = '\\';
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1612 switch (ch)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1613 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1614 case '\t': *p++ = 't'; break;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1615 case '\n': *p++ = 'n'; break;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1616 case '\r': *p++ = 'r'; break;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1617 default:
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1618 *p++ = '^';
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1619 *p++ = ch + 64;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1620 if ((ch + 64) == '\\')
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1621 *p++ = '\\';
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1622 break;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1623 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1624 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1625 else if (ch < 127)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1627 /* syntactically special characters should be escaped. */
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1628 switch (ch)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1629 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1630 case ' ':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1631 case '"':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1632 case '#':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1633 case '\'':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1634 case '(':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1635 case ')':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1636 case ',':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1637 case '.':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1638 case ';':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1639 case '?':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1640 case '[':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1641 case '\\':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1642 case ']':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1643 case '`':
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1644 *p++ = '\\';
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1645 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1646 *p++ = ch;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 else if (ch == 127)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1649 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1650 *p++ = '\\', *p++ = '^', *p++ = '?';
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1651 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1652 else if (ch < 160)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 *p++ = '\\', *p++ = '^';
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1655 p += set_itext_ichar ((Ibyte *) p, ch + 64);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 else
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1658 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1659 p += set_itext_ichar ((Ibyte *) p, ch);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1660 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1661
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1662 output_string (printcharfun, (Ibyte *) buf, Qnil, 0, p - buf);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1663
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 case Lisp_Type_Record:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 struct lrecord_header *lheader = XRECORD_LHEADER (obj);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1670
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1671 /* Try to check for various sorts of bogus pointers if we're in a
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1672 situation where it may be likely -- i.e. called from
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1673 debug_print() or we're already crashing. In such cases,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1674 (further) crashing is counterproductive. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1676 if (inhibit_non_essential_conversion_operations &&
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1677 !debug_can_access_memory (lheader, sizeof (*lheader)))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1678 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1679 write_fmt_string (printcharfun, "#<EMACS BUG: BAD MEMORY %p>",
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1680 lheader);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1681 break;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1682 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1683
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1684 if (CONSP (obj) || VECTORP (obj))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 /* If deeper than spec'd depth, print placeholder. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 if (INTP (Vprint_level)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 && print_depth > XINT (Vprint_level))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1690 write_c_string (printcharfun, "...");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
1695 #ifndef MC_ALLOC
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1696 if (lheader->type == lrecord_type_free)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1697 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1698 printing_major_badness (printcharfun, "freed lrecord", 0,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1699 lheader, BADNESS_NO_TYPE);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1700 break;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1701 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1702 else if (lheader->type == lrecord_type_undefined)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1703 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1704 printing_major_badness (printcharfun, "lrecord_type_undefined", 0,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1705 lheader, BADNESS_NO_TYPE);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1706 break;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1707 }
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
1708 #endif /* not MC_ALLOC */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1709 else if ((int) (lheader->type) >= lrecord_type_count)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1710 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1711 printing_major_badness (printcharfun, "illegal lrecord type",
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1712 (int) (lheader->type),
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1713 lheader, BADNESS_POINTER_OBJECT);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1714 break;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1715 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1716
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1717 /* Further checks for bad memory in critical situations. We don't
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1718 normally do these because they may be expensive or weird
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1719 (e.g. under Unix we typically have to set a SIGSEGV handler and
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1720 try to trigger a seg fault). */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1721
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1722 if (inhibit_non_essential_conversion_operations)
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1723 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1724 if (!debug_can_access_memory
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1725 (lheader, detagged_lisp_object_size (lheader)))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1726 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1727 write_fmt_string (printcharfun,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1728 "#<EMACS BUG: type %s BAD MEMORY %p>",
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1729 LHEADER_IMPLEMENTATION (lheader)->name,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1730 lheader);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1731 break;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1732 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1733
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1734 if (STRINGP (obj))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1735 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1736 Lisp_String *l = (Lisp_String *) lheader;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1737 if (!debug_can_access_memory (l->data_, l->size_))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1738 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1739 write_fmt_string
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1740 (printcharfun,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1741 "#<EMACS BUG: %p (BAD STRING DATA %p)>",
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1742 lheader, l->data_);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1743 break;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1744 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1745 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1746 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1747
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 if (LHEADER_IMPLEMENTATION (lheader)->printer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 ((LHEADER_IMPLEMENTATION (lheader)->printer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 (obj, printcharfun, escapeflag));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752 default_object_printer (obj, printcharfun, escapeflag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 /* We're in trouble if this happens! */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1759 printing_major_badness (printcharfun, "illegal data type", XTYPE (obj),
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1760 LISP_TO_VOID (obj), BADNESS_INTEGER_OBJECT);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1765 if (!inhibit_non_essential_conversion_operations)
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1766 unbind_to (specdepth);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
1767 UNGCPRO;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2001
diff changeset
1771 print_float (Lisp_Object obj, Lisp_Object printcharfun,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2001
diff changeset
1772 int UNUSED (escapeflag))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774 char pigbuf[350]; /* see comments in float_to_string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 float_to_string (pigbuf, XFLOAT_DATA (obj));
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1777 write_c_string (printcharfun, pigbuf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 print_symbol (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 /* #### Bug!! (intern "") isn't printed in some distinguished way */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785 /* #### (the reader also loses on it) */
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1786 Lisp_Object name = symbol_name (XSYMBOL (obj));
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1787 Bytecount size = XSTRING_LENGTH (name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790 if (!escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 /* This deals with GC-relocation */
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1793 output_string (printcharfun, 0, name, 0, size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 GCPRO2 (obj, printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 /* If we print an uninterned symbol as part of a complex object and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 the flag print-gensym is non-nil, prefix it with #n= to read the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 object back with the #n# reader syntax later if needed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 if (!NILP (Vprint_gensym)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1802 /* #### Test whether this produces a noticeable slow-down for
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803 printing when print-gensym is non-nil. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 && !EQ (obj, oblookup (Vobarray,
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1805 XSTRING_DATA (symbol_name (XSYMBOL (obj))),
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1806 XSTRING_LENGTH (symbol_name (XSYMBOL (obj))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 if (print_depth > 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810 Lisp_Object tem = Fassq (obj, Vprint_gensym_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 if (CONSP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1813 write_c_string (printcharfun, "#");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 print_internal (XCDR (tem), printcharfun, escapeflag);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1815 write_c_string (printcharfun, "#");
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1816 UNGCPRO;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821 if (CONSP (Vprint_gensym_alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 /* Vprint_gensym_alist is exposed to Lisp, so we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 have to be careful. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 CHECK_CONS (XCAR (Vprint_gensym_alist));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 CHECK_INT (XCDR (XCAR (Vprint_gensym_alist)));
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1827 tem = make_int (XINT (XCDR (XCAR (Vprint_gensym_alist))) + 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 else
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1830 tem = make_int (1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 Vprint_gensym_alist = Fcons (Fcons (obj, tem), Vprint_gensym_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1833 write_c_string (printcharfun, "#");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1834 print_internal (tem, printcharfun, escapeflag);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1835 write_c_string (printcharfun, "=");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 }
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1838 write_c_string (printcharfun, "#:");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1839 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 /* Does it look like an integer or a float? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1843 Ibyte *data = XSTRING_DATA (name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844 Bytecount confusing = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 if (size == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847 goto not_yet_confused; /* Really confusing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 else if (isdigit (data[0]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849 confusing = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850 else if (size == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 goto not_yet_confused;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852 else if (data[0] == '-' || data[0] == '+')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853 confusing = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 goto not_yet_confused;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 for (; confusing < size; confusing++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859 if (!isdigit (data[confusing]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 confusing = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1864 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 not_yet_confused:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867 if (!confusing)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 /* #### Ugh, this is needlessly complex and slow for what we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 need here. It might be a good idea to copy equivalent code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 from FSF. --hniksic */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871 confusing = isfloat_string ((char *) data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 if (confusing)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1873 write_c_string (printcharfun, "\\");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 Bytecount i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878 Bytecount last = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880 for (i = 0; i < size; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1882 switch (string_byte (name, i))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 case 0: case 1: case 2: case 3:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885 case 4: case 5: case 6: case 7:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 case 8: case 9: case 10: case 11:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 case 12: case 13: case 14: case 15:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 case 16: case 17: case 18: case 19:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 case 20: case 21: case 22: case 23:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890 case 24: case 25: case 26: case 27:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891 case 28: case 29: case 30: case 31:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 case ' ': case '\"': case '\\': case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 case ';': case '#' : case '(' : case ')':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894 case ',': case '.' : case '`' :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895 case '[': case ']' : case '?' :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1896 if (i > last)
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1897 output_string (printcharfun, 0, name, last, i - last);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 802
diff changeset
1898 write_c_string (printcharfun, "\\");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 last = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901 }
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1902 output_string (printcharfun, 0, name, last, size - last);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1908 /* Useful on systems or in places where writing to stdout is unavailable or
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1909 not working. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 static int alternate_do_pointer;
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1912 static int alternate_do_size;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1913 static char *alternate_do_string;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915 DEFUN ("alternate-debugging-output", Falternate_debugging_output, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1916 Append CHARACTER to the array `alternate_do_string'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1917 This can be used in place of `external-debugging-output' as a function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918 to be passed to `print'. Before calling `print', set `alternate_do_pointer'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919 to 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 (character))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1923 Ibyte str[MAX_ICHAR_LEN];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 Bytecount len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926 CHECK_CHAR_COERCE_INT (character);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1927 len = set_itext_ichar (str, XCHAR (character));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1928 write_string_to_alternate_debugging_output (str, len);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1929
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1930 return character;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1931 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1932
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1933 static void
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1934 write_string_to_alternate_debugging_output (const Ibyte *str, Bytecount len)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1935 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1936 int extlen;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1937 const Extbyte *extptr;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1938 #if 0 /* We want to see the internal representation, don't we? */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1939 if (initialized && !inhibit_non_essential_conversion_operations)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1940 TO_EXTERNAL_FORMAT (DATA, (str, len),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1941 ALLOCA, (extptr, extlen),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1942 Qterminal);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1943 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1944 #endif /* 0 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1945 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1946 extlen = len;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1947 extptr = (Extbyte *) str;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1948 }
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1949
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1950 /* If not yet initialized, just skip it. */
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1951 if (alternate_do_string == NULL)
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1952 return;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1953
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1954 if (alternate_do_pointer + extlen >= alternate_do_size)
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1955 {
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1956 alternate_do_size =
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1957 max(alternate_do_size * 2, alternate_do_pointer + extlen + 1);
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1958 XREALLOC_ARRAY (alternate_do_string, char, alternate_do_size);
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
1959 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 memcpy (alternate_do_string + alternate_do_pointer, extptr, extlen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 alternate_do_pointer += extlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 alternate_do_string[alternate_do_pointer] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1965
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1966 DEFUN ("set-device-clear-left-side", Fset_device_clear_left_side, 2, 2, 0, /*
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1967 Set whether to output a newline before the next output to a stream device.
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1968 This will happen only if the most recently-outputted character was not
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1969 a newline -- i.e. it will make sure the left side is "clear" of text.
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1970 */
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1971 (device, value))
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1972 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1973 if (!NILP (device))
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1974 CHECK_LIVE_DEVICE (device);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1975 if (NILP (device) || DEVICE_STREAM_P (XDEVICE (device)))
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1976 /* #### This should be per-device */
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1977 stdout_clear_before_next_output = !NILP (value);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1978 return Qnil;
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1979 }
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1980
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1981 DEFUN ("device-left-side-clear-p", Fdevice_left_side_clear_p, 0, 1, 0, /*
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1982 For stream devices, true if the most recent-outputted character was a newline.
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1983 */
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1984 (device))
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1985 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1986 if (!NILP (device))
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1987 CHECK_LIVE_DEVICE (device);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1988 if (NILP (device) || DEVICE_STREAM_P (XDEVICE (device)))
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1989 /* #### This should be per-device */
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1990 return stdout_needs_newline ? Qt : Qnil;
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1991 return Qnil;
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1992 }
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
1993
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994 DEFUN ("external-debugging-output", Fexternal_debugging_output, 1, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995 Write CHAR-OR-STRING to stderr or stdout.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1996 If optional arg STDOUT-P is non-nil, write to stdout; otherwise, write
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1997 to stderr. You can use this function to write directly to the terminal.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998 This function can be used as the STREAM argument of Fprint() or the like.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1999
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2000 Under MS Windows, this writes output to the console window (which is
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2001 created, if necessary), unless XEmacs is being run noninteractively
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2002 \(i.e. using the `-batch' argument).
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2003
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 If you have opened a termscript file (using `open-termscript'), then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2005 the output also will be logged to this file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2006 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 (char_or_string, stdout_p, device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009 FILE *file = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010 struct console *con = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2011
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012 if (NILP (device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2013 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2014 if (!NILP (stdout_p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2015 file = stdout;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2017 file = stderr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2018 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2019 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2020 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2021 CHECK_LIVE_DEVICE (device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 if (!DEVICE_TTY_P (XDEVICE (device)) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2023 !DEVICE_STREAM_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
2024 wtaerror ("Must be tty or stream device", device);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2025 con = XCONSOLE (DEVICE_CONSOLE (XDEVICE (device)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026 if (DEVICE_TTY_P (XDEVICE (device)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 file = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 else if (!NILP (stdout_p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029 file = CONSOLE_STREAM_DATA (con)->out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031 file = CONSOLE_STREAM_DATA (con)->err;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2033
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034 if (STRINGP (char_or_string))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2035 write_string_to_stdio_stream (file, con,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036 XSTRING_DATA (char_or_string),
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2037 XSTRING_LENGTH (char_or_string),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2038 print_unbuffered);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
2041 Ibyte str[MAX_ICHAR_LEN];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2042 Bytecount len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044 CHECK_CHAR_COERCE_INT (char_or_string);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
2045 len = set_itext_ichar (str, XCHAR (char_or_string));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2046 write_string_to_stdio_stream (file, con, str, len, print_unbuffered);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2048
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2049 return char_or_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052 DEFUN ("open-termscript", Fopen_termscript, 1, 1, "FOpen termscript file: ", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2053 Start writing all terminal output to FILENAME as well as the terminal.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2054 FILENAME = nil means just close any termscript file currently open.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2055 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2056 (filename))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2057 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2058 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2059 if (termscript != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2060 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2061 retry_fclose (termscript);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2062 termscript = 0;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2063 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2064
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2065 if (! NILP (filename))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2066 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2067 filename = Fexpand_file_name (filename, Qnil);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2068 termscript = qxe_fopen (XSTRING_DATA (filename), "w");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2069 if (termscript == NULL)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
2070 report_file_error ("Opening termscript", filename);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2071 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2072 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2074
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2075 static int debug_print_length = 50;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2076 static int debug_print_level = 15;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2077 static int debug_print_readably = -1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2078
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2079 /* Restore values temporarily bound by debug_prin1. We use this approach to
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2080 avoid consing in debug_prin1. That is verboten, since debug_prin1 can be
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2081 called by cons debugging code. */
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2082 static Lisp_Object
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2001
diff changeset
2083 debug_prin1_exit (Lisp_Object UNUSED (ignored))
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2084 {
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2085 struct debug_bindings *bindings =
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2086 (struct debug_bindings *) XOPAQUE (debug_prin1_bindings)->data;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2087 inhibit_non_essential_conversion_operations =
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2088 bindings->inhibit_non_essential_conversion_operations;
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2089 print_depth = bindings->print_depth;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2090 print_readably = bindings->print_readably;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2091 print_unbuffered = bindings->print_unbuffered;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2092 gc_currently_forbidden = bindings->gc_currently_forbidden;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2093 Vprint_length = bindings->Vprint_length;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2094 Vprint_level = bindings->Vprint_level;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2095 Vinhibit_quit = bindings->Vinhibit_quit;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2096 return Qnil;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2097 }
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2098
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2099 /* Print an object, `prin1'-style, to various possible debugging outputs.
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2100 Make sure it's completely unbuffered so that, in the event of a crash
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2101 somewhere, we see as much as possible that happened before it.
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2102 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 static void
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2104 debug_prin1 (Lisp_Object debug_print_obj, int flags)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106 /* This function can GC */
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2107
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2108 /* by doing this, we trick various things that are non-essential
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2109 but might cause crashes into not getting executed. */
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2110 int specdepth;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2111 struct debug_bindings *bindings =
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2112 (struct debug_bindings *) XOPAQUE (debug_prin1_bindings)->data;
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2113
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2114 bindings->inhibit_non_essential_conversion_operations =
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2115 inhibit_non_essential_conversion_operations;
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2116 bindings->print_depth = print_depth;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2117 bindings->print_readably = print_readably;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2118 bindings->print_unbuffered = print_unbuffered;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2119 bindings->gc_currently_forbidden = gc_currently_forbidden;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2120 bindings->Vprint_length = Vprint_length;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2121 bindings->Vprint_level = Vprint_level;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2122 bindings->Vinhibit_quit = Vinhibit_quit;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2123 specdepth = record_unwind_protect (debug_prin1_exit, Qnil);
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2124
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2125 inhibit_non_essential_conversion_operations = 1;
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2126 print_depth = 0;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2127 print_readably = debug_print_readably != -1 ? debug_print_readably : 0;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2128 print_unbuffered++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129 if (debug_print_length > 0)
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2130 Vprint_length = make_int (debug_print_length);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2131 if (debug_print_level > 0)
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2132 Vprint_level = make_int (debug_print_level);
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2133 Vinhibit_quit = Qt;
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2134
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2135 if ((flags & EXT_PRINT_STDOUT) || (flags & EXT_PRINT_STDERR))
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2136 print_internal (debug_print_obj, Qexternal_debugging_output, 1);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2137 if (flags & EXT_PRINT_ALTERNATE)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2138 print_internal (debug_print_obj, Qalternate_debugging_output, 1);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2139 #ifdef WIN32_NATIVE
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2140 if (flags & EXT_PRINT_MSWINDOWS)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2141 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2142 /* Write out to the debugger, as well */
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2143 print_internal (debug_print_obj, Qmswindows_debugging_output, 1);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2144 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2145 #endif
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2146
802
19dfb459d51a [xemacs-hg @ 2002-04-03 10:47:37 by ben]
ben
parents: 800
diff changeset
2147 unbind_to (specdepth);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2148 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2150 void
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2151 debug_p4 (Lisp_Object obj)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2152 {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2153 inhibit_non_essential_conversion_operations = 1;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2154 if (STRINGP (obj))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2155 debug_out ("\"%s\"", XSTRING_DATA (obj));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2156 else if (CONSP (obj))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2157 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2158 int first = 1;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2159 do {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2160 debug_out (first ? "(" : " ");
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2161 first = 0;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2162 debug_p4 (XCAR (obj));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2163 obj = XCDR (obj);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2164 } while (CONSP (obj));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2165 if (NILP (obj))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2166 debug_out (")");
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2167 else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2168 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2169 debug_out (" . ");
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2170 debug_p4 (obj);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2171 debug_out (")");
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2172 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2173 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2174 else if (VECTORP (obj))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2175 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2176 int size = XVECTOR_LENGTH (obj);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2177 int i;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2178 int first = 1;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2179
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2180 for (i = 0; i < size; i++)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2181 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2182 debug_out (first ? "[" : " ");
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2183 first = 0;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2184 debug_p4 (XVECTOR_DATA (obj)[i]);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2185 debug_out ("]");
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2186 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2187 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2188 else if (SYMBOLP (obj))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2189 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2190 Lisp_Object name = XSYMBOL_NAME (obj);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2191 if (!STRINGP (name))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2192 debug_out ("<<bad symbol>>");
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2193 else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2194 debug_out ("%s", XSTRING_DATA (name));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2195 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2196 else if (INTP (obj))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2197 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2198 debug_out ("%ld", XINT (obj));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2199 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2200 else if (FLOATP (obj))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2201 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2202 debug_out ("%g", XFLOAT_DATA (obj));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2203 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2204 else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2205 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2206 struct lrecord_header *header =
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2207 (struct lrecord_header *) XPNTR (obj);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2208
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2209 if (header->type >= lrecord_type_last_built_in_type)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2210 debug_out ("<< bad object type=%d 0x%lx>>", header->type,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2211 (EMACS_INT) header);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2212 else
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
2213 #ifdef MC_ALLOC
3063
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3024
diff changeset
2214 debug_out ("#<%s addr=0x%lx uid=0x%lx>",
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
2215 LHEADER_IMPLEMENTATION (header)->name,
3063
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3024
diff changeset
2216 (EMACS_INT) header,
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
2217 (EMACS_INT) ((struct lrecord_header *) header)->uid);
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
2218 #else /* not MC_ALLOC */
3063
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3024
diff changeset
2219 debug_out ("#<%s addr=0x%lx uid=0x%lx>",
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2220 LHEADER_IMPLEMENTATION (header)->name,
3063
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3024
diff changeset
2221 (EMACS_INT) header,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2222 LHEADER_IMPLEMENTATION (header)->basic_p ?
3063
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3024
diff changeset
2223 ((struct lrecord_header *) header)->uid :
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
2224 ((struct old_lcrecord_header *) header)->uid);
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2500
diff changeset
2225 #endif /* not MC_ALLOC */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2226 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2227
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2228 inhibit_non_essential_conversion_operations = 0;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2229 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2230
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2231 static void
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2232 ext_print_begin (int dest)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2233 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2234 if (dest & EXT_PRINT_ALTERNATE)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2235 alternate_do_pointer = 0;
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2236 if (dest & (EXT_PRINT_STDERR | EXT_PRINT_STDOUT))
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2237 stdout_clear_before_next_output = 1;
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2238 }
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2239
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2240 static void
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2241 ext_print_end (int dest)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2242 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2243 if (dest & (EXT_PRINT_MSWINDOWS | EXT_PRINT_STDERR | EXT_PRINT_STDOUT))
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2244 external_out (dest & (EXT_PRINT_MSWINDOWS | EXT_PRINT_STDERR |
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2245 EXT_PRINT_STDOUT), "\n");
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2246 }
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2247
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2248 static void
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2249 external_debug_print (Lisp_Object object, int dest)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2250 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2251 ext_print_begin (dest);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2252 debug_prin1 (object, dest);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2253 ext_print_end (dest);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2254 }
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2255
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2256 void
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2257 debug_p3 (Lisp_Object obj)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2258 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2259 debug_p4 (obj);
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2260 inhibit_non_essential_conversion_operations = 1;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2261 debug_out ("\n");
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2262 inhibit_non_essential_conversion_operations = 0;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2263 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2264
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2265 void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2266 debug_print (Lisp_Object debug_print_obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2267 {
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2268 external_debug_print (debug_print_obj, EXT_PRINT_ALL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2269 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2270
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2271 /* Getting tired of typing debug_print() ... */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2272 void dp (Lisp_Object debug_print_obj);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2273 void
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2274 dp (Lisp_Object debug_print_obj)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2275 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2276 debug_print (debug_print_obj);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2277 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2278
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2279 /* Alternate debug printer: Return a char * pointer to the output */
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2280 char *dpa (Lisp_Object debug_print_obj);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2281 char *
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2282 dpa (Lisp_Object debug_print_obj)
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2283 {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2284 external_debug_print (debug_print_obj, EXT_PRINT_ALTERNATE);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2285
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2286 return alternate_do_string;
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2287 }
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2288
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2289 /* Debugging kludge -- unbuffered */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2290 /* This function provided for the benefit of the debugger. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2291 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2292 debug_backtrace (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2293 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2294 /* This function can GC */
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2295
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2296 /* by doing this, we trick various things that are non-essential
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2297 but might cause crashes into not getting executed. */
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2298 int specdepth =
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2299 internal_bind_int (&inhibit_non_essential_conversion_operations, 1);
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2300
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
2301 internal_bind_int (&print_depth, 0);
802
19dfb459d51a [xemacs-hg @ 2002-04-03 10:47:37 by ben]
ben
parents: 800
diff changeset
2302 internal_bind_int (&print_readably, 0);
19dfb459d51a [xemacs-hg @ 2002-04-03 10:47:37 by ben]
ben
parents: 800
diff changeset
2303 internal_bind_int (&print_unbuffered, print_unbuffered + 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2304 if (debug_print_length > 0)
802
19dfb459d51a [xemacs-hg @ 2002-04-03 10:47:37 by ben]
ben
parents: 800
diff changeset
2305 internal_bind_lisp_object (&Vprint_length, make_int (debug_print_length));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2306 if (debug_print_level > 0)
802
19dfb459d51a [xemacs-hg @ 2002-04-03 10:47:37 by ben]
ben
parents: 800
diff changeset
2307 internal_bind_lisp_object (&Vprint_level, make_int (debug_print_level));
19dfb459d51a [xemacs-hg @ 2002-04-03 10:47:37 by ben]
ben
parents: 800
diff changeset
2308 /* #### Do we need this? It was in the old code. */
19dfb459d51a [xemacs-hg @ 2002-04-03 10:47:37 by ben]
ben
parents: 800
diff changeset
2309 internal_bind_lisp_object (&Vinhibit_quit, Vinhibit_quit);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2311 Fbacktrace (Qexternal_debugging_output, Qt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2312 stderr_out ("\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2313
802
19dfb459d51a [xemacs-hg @ 2002-04-03 10:47:37 by ben]
ben
parents: 800
diff changeset
2314 unbind_to (specdepth);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2315 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2316
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2317 /* Getting tired of typing debug_backtrace() ... */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2318 void db (void);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2319 void
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2320 db (void)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2321 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2322 debug_backtrace ();
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2323 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1104
diff changeset
2324
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2325 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2326 debug_short_backtrace (int length)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2327 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2328 int first = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2329 struct backtrace *bt = backtrace_list;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2330 debug_out (" [");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2331 while (length > 0 && bt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2332 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2333 if (!first)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2334 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2335 debug_out (", ");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2336 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2337 if (COMPILED_FUNCTIONP (*bt->function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2338 {
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2339 #if defined (COMPILED_FUNCTION_ANNOTATION_HACK)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2340 Lisp_Object ann =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2341 compiled_function_annotation (XCOMPILED_FUNCTION (*bt->function));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2342 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2343 Lisp_Object ann = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2344 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2345 if (!NILP (ann))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2346 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2347 debug_out ("<compiled-function from ");
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2348 debug_prin1 (ann, EXT_PRINT_ALL);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2349 debug_out (">");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2350 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2351 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2352 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2353 debug_out ("<compiled-function of unknown origin>");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2354 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2355 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2356 else
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2357 debug_prin1 (*bt->function, EXT_PRINT_ALL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2358 first = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2359 length--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2360 bt = bt->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2361 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
2362 debug_out ("]\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2363 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2366 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2367 syms_of_print (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2368 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
2369 DEFSYMBOL (Qstandard_output);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2370
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
2371 DEFSYMBOL (Qprint_length);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2372
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
2373 DEFSYMBOL (Qprint_string_length);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2374
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
2375 DEFSYMBOL (Qdisplay_error);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
2376 DEFSYMBOL (Qprint_message_label);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2377
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2378 DEFSUBR (Fprin1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2379 DEFSUBR (Fprin1_to_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2380 DEFSUBR (Fprinc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2381 DEFSUBR (Fprint);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2382 DEFSUBR (Ferror_message_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2383 DEFSUBR (Fdisplay_error);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2384 DEFSUBR (Fterpri);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2385 DEFSUBR (Fwrite_char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2386 DEFSUBR (Falternate_debugging_output);
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2387 DEFSUBR (Fset_device_clear_left_side);
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1261
diff changeset
2388 DEFSUBR (Fdevice_left_side_clear_p);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2389 DEFSUBR (Fexternal_debugging_output);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2390 DEFSUBR (Fopen_termscript);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
2391 DEFSYMBOL (Qexternal_debugging_output);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
2392 DEFSYMBOL (Qalternate_debugging_output);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2393 #ifdef HAVE_MS_WINDOWS
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
2394 DEFSYMBOL (Qmswindows_debugging_output);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2395 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2396 DEFSUBR (Fwith_output_to_temp_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2397 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2399 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2400 reinit_vars_of_print (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2401 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2402 alternate_do_pointer = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2403 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2405 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2406 vars_of_print (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2407 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2408 DEFVAR_LISP ("standard-output", &Vstandard_output /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2409 Output stream `print' uses by default for outputting a character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2410 This may be any function of one argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2411 It may also be a buffer (output is inserted before point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2412 or a marker (output is inserted and the marker is advanced)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2413 or the symbol t (output appears in the minibuffer line).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2414 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2415 Vstandard_output = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2417 DEFVAR_LISP ("float-output-format", &Vfloat_output_format /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2418 The format descriptor string that lisp uses to print floats.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2419 This is a %-spec like those accepted by `printf' in C,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2420 but with some restrictions. It must start with the two characters `%.'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2421 After that comes an integer precision specification,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2422 and then a letter which controls the format.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2423 The letters allowed are `e', `f' and `g'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2424 Use `e' for exponential notation "DIG.DIGITSeEXPT"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2425 Use `f' for decimal point notation "DIGITS.DIGITS".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2426 Use `g' to choose the shorter of those two formats for the number at hand.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2427 The precision in any of these cases is the number of digits following
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2428 the decimal point. With `f', a precision of 0 means to omit the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2429 decimal point. 0 is not allowed with `f' or `g'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2431 A value of nil means to use `%.16g'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2432
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2433 Regardless of the value of `float-output-format', a floating point number
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2434 will never be printed in such a way that it is ambiguous with an integer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2435 that is, a floating-point number will always be printed with a decimal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2436 point and/or an exponent, even if the digits following the decimal point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2437 are all zero. This is to preserve read-equivalence.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2438 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2439 Vfloat_output_format = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2440
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2441 DEFVAR_LISP ("print-length", &Vprint_length /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2442 Maximum length of list or vector to print before abbreviating.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2443 A value of nil means no limit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2444 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2445 Vprint_length = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2446
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2447 DEFVAR_LISP ("print-string-length", &Vprint_string_length /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2448 Maximum length of string to print before abbreviating.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2449 A value of nil means no limit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2450 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2451 Vprint_string_length = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2452
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2453 DEFVAR_LISP ("print-level", &Vprint_level /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2454 Maximum depth of list nesting to print before abbreviating.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2455 A value of nil means no limit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2456 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2457 Vprint_level = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2458
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2459 DEFVAR_BOOL ("print-escape-newlines", &print_escape_newlines /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2460 Non-nil means print newlines in strings as backslash-n.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2461 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2462 print_escape_newlines = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2464 DEFVAR_BOOL ("print-readably", &print_readably /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465 If non-nil, then all objects will be printed in a readable form.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2466 If an object has no readable representation, then an error is signalled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2467 When print-readably is true, compiled-function objects will be written in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2468 #[...] form instead of in #<compiled-function [...]> form, and two-element
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2469 lists of the form (quote object) will be written as the equivalent 'object.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2470 Do not SET this variable; bind it instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2471 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2472 print_readably = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2473
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2474 /* #### I think this should default to t. But we'd better wait
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2475 until we see that it works out. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2476 DEFVAR_LISP ("print-gensym", &Vprint_gensym /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2477 If non-nil, then uninterned symbols will be printed specially.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2478 Uninterned symbols are those which are not present in `obarray', that is,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2479 those which were made with `make-symbol' or by calling `intern' with a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2480 second argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2482 When print-gensym is true, such symbols will be preceded by "#:",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2483 which causes the reader to create a new symbol instead of interning
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2484 and returning an existing one. Beware: the #: syntax creates a new
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2485 symbol each time it is seen, so if you print an object which contains
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2486 two pointers to the same uninterned symbol, `read' will not duplicate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2487 that structure.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2489 If the value of `print-gensym' is a cons cell, then in addition
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2490 refrain from clearing `print-gensym-alist' on entry to and exit from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2491 printing functions, so that the use of #...# and #...= can carry over
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2492 for several separately printed objects.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2493 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2494 Vprint_gensym = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2496 DEFVAR_LISP ("print-gensym-alist", &Vprint_gensym_alist /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2497 Association list of elements (GENSYM . N) to guide use of #N# and #N=.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2498 In each element, GENSYM is an uninterned symbol that has been associated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2499 with #N= for the specified value of N.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2500 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2501 Vprint_gensym_alist = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2502
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2503 DEFVAR_LISP ("print-message-label", &Vprint_message_label /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2504 Label for minibuffer messages created with `print'. This should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2505 generally be bound with `let' rather than set. (See `display-message'.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2506 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2507 Vprint_message_label = Qprint;
1957
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2508
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2509 debug_prin1_bindings =
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2510 make_opaque (OPAQUE_UNINIT, sizeof (struct debug_bindings));
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2511 staticpro (&debug_prin1_bindings);
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2512
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2513 alternate_do_size = 5000;
59e1bbea04fe [xemacs-hg @ 2004-03-19 02:59:08 by james]
james
parents: 1346
diff changeset
2514 alternate_do_string = xnew_array(char, 5000);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2515 }