Mercurial > hg > xemacs-beta
comparison src/print.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
1 /* Lisp object printing and output streams. | 1 /* Lisp object printing and output streams. |
2 Copyright (C) 1985, 1986, 1988, 1992-1995 Free Software Foundation, Inc. | 2 Copyright (C) 1985, 1986, 1988, 1992-1995 Free Software Foundation, Inc. |
3 Copyright (C) 1995, 1996 Ben Wing. | 3 Copyright (C) 1995, 1996, 2000 Ben Wing. |
4 | 4 |
5 This file is part of XEmacs. | 5 This file is part of XEmacs. |
6 | 6 |
7 XEmacs is free software; you can redistribute it and/or modify it | 7 XEmacs is free software; you can redistribute it and/or modify it |
8 under the terms of the GNU General Public License as published by the | 8 under the terms of the GNU General Public License as published by the |
36 #include "extents.h" | 36 #include "extents.h" |
37 #include "frame.h" | 37 #include "frame.h" |
38 #include "insdel.h" | 38 #include "insdel.h" |
39 #include "lstream.h" | 39 #include "lstream.h" |
40 #include "sysfile.h" | 40 #include "sysfile.h" |
41 | 41 #ifdef WIN32_NATIVE |
42 #include <limits.h> | 42 #include "console-msw.h" |
43 #endif | |
44 | |
43 #include <float.h> | 45 #include <float.h> |
44 /* Define if not in float.h */ | 46 /* Define if not in float.h */ |
45 #ifndef DBL_DIG | 47 #ifndef DBL_DIG |
46 #define DBL_DIG 16 | 48 #define DBL_DIG 16 |
47 #endif | 49 #endif |
48 | 50 |
49 Lisp_Object Vstandard_output, Qstandard_output; | 51 Lisp_Object Vstandard_output, Qstandard_output; |
50 | 52 |
51 /* The subroutine object for external-debugging-output is kept here | 53 /* The subroutine object for external-debugging-output is kept here |
52 for the convenience of the debugger. */ | 54 for the convenience of the debugger. */ |
53 Lisp_Object Qexternal_debugging_output; | 55 Lisp_Object Qexternal_debugging_output, Qalternate_debugging_output; |
56 | |
57 #ifdef HAVE_MS_WINDOWS | |
58 Lisp_Object Qmswindows_debugging_output; | |
59 #endif | |
54 | 60 |
55 /* Avoid actual stack overflow in print. */ | 61 /* Avoid actual stack overflow in print. */ |
56 static int print_depth; | 62 static int print_depth; |
57 | 63 |
58 /* Detect most circularities to print finite output. */ | 64 /* Detect most circularities to print finite output. */ |
101 | 107 |
102 | 108 |
103 | 109 |
104 int stdout_needs_newline; | 110 int stdout_needs_newline; |
105 | 111 |
106 /* Write a string (in internal format) to stdio stream STREAM. */ | 112 static void |
107 | 113 std_handle_out_external (FILE *stream, Lisp_Object lstream, |
108 void | 114 const Extbyte *extptr, Extcount extlen, |
109 write_string_to_stdio_stream (FILE *stream, struct console *con, | 115 /* is this really stdout/stderr? |
110 CONST Bufbyte *str, | 116 (controls termscript writing) */ |
111 Bytecount offset, Bytecount len, | 117 int output_is_std_handle, |
112 Lisp_Object coding_system) | 118 int must_flush) |
113 { | 119 { |
114 Extcount extlen; | |
115 CONST Extbyte *extptr; | |
116 | |
117 TO_EXTERNAL_FORMAT (DATA, (str + offset, len), | |
118 ALLOCA, (extptr, extlen), | |
119 coding_system); | |
120 if (stream) | 120 if (stream) |
121 { | 121 { |
122 fwrite (extptr, 1, extlen, stream); | 122 #ifdef WIN32_NATIVE |
123 #ifdef WINDOWSNT | 123 HANDLE errhand = GetStdHandle (STD_INPUT_HANDLE); |
124 /* Q122442 says that pipes are "treated as files, not as | 124 int no_useful_stderr = errhand == 0 || errhand == INVALID_HANDLE_VALUE; |
125 devices", and that this is a feature. Before I found that | 125 |
126 article, I thought it was a bug. Thanks MS, I feel much | 126 if (!no_useful_stderr) |
127 better now. - kkm */ | 127 no_useful_stderr = !PeekNamedPipe (errhand, 0, 0, 0, 0, 0); |
128 if (stream == stdout || stream == stderr) | 128 /* we typically have no useful stdout/stderr under windows if we're |
129 fflush (stream); | 129 being invoked graphically. */ |
130 if (no_useful_stderr) | |
131 mswindows_output_console_string (extptr, extlen); | |
132 else | |
130 #endif | 133 #endif |
134 { | |
135 fwrite (extptr, 1, extlen, stream); | |
136 #ifdef WIN32_NATIVE | |
137 /* Q122442 says that pipes are "treated as files, not as | |
138 devices", and that this is a feature. Before I found that | |
139 article, I thought it was a bug. Thanks MS, I feel much | |
140 better now. - kkm */ | |
141 must_flush = 1; | |
142 #endif | |
143 if (must_flush) | |
144 fflush (stream); | |
145 } | |
131 } | 146 } |
132 else | 147 else |
133 { | 148 Lstream_write (XLSTREAM (lstream), extptr, extlen); |
134 assert (CONSOLE_TTY_P (con)); | 149 |
135 Lstream_write (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream), | 150 if (output_is_std_handle) |
136 extptr, extlen); | |
137 } | |
138 if (stream == stdout || stream == stderr || | |
139 (!stream && CONSOLE_TTY_DATA (con)->is_stdio)) | |
140 { | 151 { |
141 if (termscript) | 152 if (termscript) |
142 { | 153 { |
143 fwrite (extptr, 1, extlen, termscript); | 154 fwrite (extptr, 1, extlen, termscript); |
144 fflush (termscript); | 155 fflush (termscript); |
145 } | 156 } |
146 stdout_needs_newline = (extptr[extlen - 1] != '\n'); | 157 stdout_needs_newline = (extptr[extlen - 1] != '\n'); |
147 } | 158 } |
148 } | 159 } |
149 | 160 |
161 /* #### The following function should be replaced a call to the | |
162 emacs_doprnt_*() functions. This is the only way to ensure that | |
163 I18N3 works properly (many implementations of the *printf() | |
164 functions, including the ones included in glibc, do not implement | |
165 the %###$ argument-positioning syntax). | |
166 | |
167 Note, however, that to do this, we'd have to | |
168 | |
169 1) pre-allocate all the lstreams and do whatever else was necessary | |
170 to make sure that no allocation occurs, since these functions may be | |
171 called from fatal_error_signal(). | |
172 | |
173 2) (to be really correct) make a new lstream that outputs using | |
174 mswindows_output_console_string(). */ | |
175 | |
176 static int | |
177 std_handle_out_va (FILE *stream, const char *fmt, va_list args) | |
178 { | |
179 Bufbyte kludge[8192]; | |
180 Extbyte *extptr; | |
181 Extcount extlen; | |
182 int retval; | |
183 | |
184 retval = vsprintf ((char *) kludge, fmt, args); | |
185 if (initialized && !fatal_error_in_progress) | |
186 TO_EXTERNAL_FORMAT (DATA, (kludge, strlen ((char *) kludge)), | |
187 ALLOCA, (extptr, extlen), | |
188 Qnative); | |
189 else | |
190 { | |
191 extptr = (Extbyte *) kludge; | |
192 extlen = (Extcount) strlen ((char *) kludge); | |
193 } | |
194 | |
195 std_handle_out_external (stream, Qnil, extptr, extlen, 1, 1); | |
196 return retval; | |
197 } | |
198 | |
199 /* Output portably to stderr or its equivalent; call GETTEXT on the | |
200 format string. Automatically flush when done. */ | |
201 | |
202 int | |
203 stderr_out (const char *fmt, ...) | |
204 { | |
205 int retval; | |
206 va_list args; | |
207 va_start (args, fmt); | |
208 retval = | |
209 std_handle_out_va | |
210 (stderr, initialized && !fatal_error_in_progress ? GETTEXT (fmt) : fmt, | |
211 args); | |
212 va_end (args); | |
213 return retval; | |
214 } | |
215 | |
216 /* Output portably to stdout or its equivalent; call GETTEXT on the | |
217 format string. Automatically flush when done. */ | |
218 | |
219 int | |
220 stdout_out (const char *fmt, ...) | |
221 { | |
222 int retval; | |
223 va_list args; | |
224 va_start (args, fmt); | |
225 retval = | |
226 std_handle_out_va | |
227 (stdout, initialized && !fatal_error_in_progress ? GETTEXT (fmt) : fmt, | |
228 args); | |
229 va_end (args); | |
230 return retval; | |
231 } | |
232 | |
233 DOESNT_RETURN | |
234 fatal (const char *fmt, ...) | |
235 { | |
236 va_list args; | |
237 va_start (args, fmt); | |
238 | |
239 stderr_out ("\nXEmacs: "); | |
240 std_handle_out_va (stderr, GETTEXT (fmt), args); | |
241 stderr_out ("\n"); | |
242 | |
243 va_end (args); | |
244 exit (1); | |
245 } | |
246 | |
247 /* Write a string (in internal format) to stdio stream STREAM. */ | |
248 | |
249 void | |
250 write_string_to_stdio_stream (FILE *stream, struct console *con, | |
251 const Bufbyte *str, | |
252 Bytecount offset, Bytecount len, | |
253 Lisp_Object coding_system, | |
254 int must_flush) | |
255 { | |
256 Extcount extlen; | |
257 const Extbyte *extptr; | |
258 | |
259 /* #### yuck! sometimes this function is called with string data, | |
260 and the following call may gc. */ | |
261 { | |
262 Bufbyte *puta = (Bufbyte *) alloca (len); | |
263 memcpy (puta, str + offset, len); | |
264 TO_EXTERNAL_FORMAT (DATA, (puta, len), | |
265 ALLOCA, (extptr, extlen), | |
266 coding_system); | |
267 } | |
268 | |
269 if (stream) | |
270 std_handle_out_external (stream, Qnil, extptr, extlen, | |
271 stream == stdout || stream == stderr, must_flush); | |
272 else | |
273 { | |
274 assert (CONSOLE_TTY_P (con)); | |
275 std_handle_out_external (0, CONSOLE_TTY_DATA (con)->outstream, | |
276 extptr, extlen, | |
277 CONSOLE_TTY_DATA (con)->is_stdio, must_flush); | |
278 } | |
279 } | |
280 | |
150 /* Write a string to the output location specified in FUNCTION. | 281 /* Write a string to the output location specified in FUNCTION. |
151 Arguments NONRELOC, RELOC, OFFSET, and LEN are as in | 282 Arguments NONRELOC, RELOC, OFFSET, and LEN are as in |
152 buffer_insert_string_1() in insdel.c. */ | 283 buffer_insert_string_1() in insdel.c. */ |
153 | 284 |
154 static void | 285 static void |
155 output_string (Lisp_Object function, CONST Bufbyte *nonreloc, | 286 output_string (Lisp_Object function, const Bufbyte *nonreloc, |
156 Lisp_Object reloc, Bytecount offset, Bytecount len) | 287 Lisp_Object reloc, Bytecount offset, Bytecount len) |
157 { | 288 { |
158 /* This function can GC */ | 289 /* This function can GC */ |
159 Charcount cclen; | 290 Charcount cclen; |
160 /* We change the value of nonreloc (fetching it from reloc as | 291 /* We change the value of nonreloc (fetching it from reloc as |
161 necessary), but we don't want to pass this changed value on to | 292 necessary), but we don't want to pass this changed value on to |
162 other functions that take both a nonreloc and a reloc, or things | 293 other functions that take both a nonreloc and a reloc, or things |
163 may get confused and an assertion failure in | 294 may get confused and an assertion failure in |
164 fixup_internal_substring() may get triggered. */ | 295 fixup_internal_substring() may get triggered. */ |
165 CONST Bufbyte *newnonreloc = nonreloc; | 296 const Bufbyte *newnonreloc = nonreloc; |
166 struct gcpro gcpro1, gcpro2; | 297 struct gcpro gcpro1, gcpro2; |
167 | 298 |
168 /* Emacs won't print while GCing, but an external debugger might */ | 299 /* Emacs won't print while GCing, but an external debugger might */ |
169 if (gc_in_progress) return; | 300 if (gc_in_progress) return; |
170 | 301 |
236 echo_area_append (f, nonreloc, reloc, offset, len, Vprint_message_label); | 367 echo_area_append (f, nonreloc, reloc, offset, len, Vprint_message_label); |
237 } | 368 } |
238 else if (EQ (function, Qt) || EQ (function, Qnil)) | 369 else if (EQ (function, Qt) || EQ (function, Qnil)) |
239 { | 370 { |
240 write_string_to_stdio_stream (stdout, 0, newnonreloc, offset, len, | 371 write_string_to_stdio_stream (stdout, 0, newnonreloc, offset, len, |
241 Qterminal); | 372 Qterminal, print_unbuffered); |
242 } | 373 } |
243 else | 374 else |
244 { | 375 { |
245 Charcount ccoff = bytecount_to_charcount (newnonreloc, offset); | 376 Charcount ccoff = bytecount_to_charcount (newnonreloc, offset); |
246 Charcount iii; | 377 Charcount iii; |
345 } | 476 } |
346 } | 477 } |
347 | 478 |
348 /* Used for printing a single-byte character (*not* any Emchar). */ | 479 /* Used for printing a single-byte character (*not* any Emchar). */ |
349 #define write_char_internal(string_of_length_1, stream) \ | 480 #define write_char_internal(string_of_length_1, stream) \ |
350 output_string (stream, (CONST Bufbyte *) (string_of_length_1), \ | 481 output_string (stream, (const Bufbyte *) (string_of_length_1), \ |
351 Qnil, 0, 1) | 482 Qnil, 0, 1) |
352 | 483 |
353 /* NOTE: Do not call this with the data of a Lisp_String, as | 484 /* NOTE: Do not call this with the data of a Lisp_String, as |
354 printcharfun might cause a GC, which might cause the string's data | 485 printcharfun might cause a GC, which might cause the string's data |
355 to be relocated. To princ a Lisp string, use: | 486 to be relocated. To princ a Lisp string, use: |
358 | 489 |
359 Also note that STREAM should be the result of | 490 Also note that STREAM should be the result of |
360 canonicalize_printcharfun() (i.e. Qnil means stdout, not | 491 canonicalize_printcharfun() (i.e. Qnil means stdout, not |
361 Vstandard_output, etc.) */ | 492 Vstandard_output, etc.) */ |
362 void | 493 void |
363 write_string_1 (CONST Bufbyte *str, Bytecount size, Lisp_Object stream) | 494 write_string_1 (const Bufbyte *str, Bytecount size, Lisp_Object stream) |
364 { | 495 { |
365 /* This function can GC */ | 496 /* This function can GC */ |
366 #ifdef ERROR_CHECK_BUFPOS | 497 #ifdef ERROR_CHECK_BUFPOS |
367 assert (size >= 0); | 498 assert (size >= 0); |
368 #endif | 499 #endif |
369 output_string (stream, str, Qnil, 0, size); | 500 output_string (stream, str, Qnil, 0, size); |
370 } | 501 } |
371 | 502 |
372 void | 503 void |
373 write_c_string (CONST char *str, Lisp_Object stream) | 504 write_c_string (const char *str, Lisp_Object stream) |
374 { | 505 { |
375 /* This function can GC */ | 506 /* This function can GC */ |
376 write_string_1 ((CONST Bufbyte *) str, strlen (str), stream); | 507 write_string_1 ((const Bufbyte *) str, strlen (str), stream); |
377 } | 508 } |
378 | 509 |
379 | 510 |
380 DEFUN ("write-char", Fwrite_char, 1, 2, 0, /* | 511 DEFUN ("write-char", Fwrite_char, 1, 2, 0, /* |
381 Output character CH to stream STREAM. | 512 Output character CH to stream STREAM. |
802 buf [(buf [0] == '-' ? 1 : 0)] = '0'; | 933 buf [(buf [0] == '-' ? 1 : 0)] = '0'; |
803 } | 934 } |
804 } | 935 } |
805 #endif /* LISP_FLOAT_TYPE */ | 936 #endif /* LISP_FLOAT_TYPE */ |
806 | 937 |
807 /* Print NUMBER to BUFFER. The digits are first written in reverse | 938 /* Print NUMBER to BUFFER. This is equivalent to sprintf(buffer, |
808 order (the least significant digit first), and are then reversed. | 939 "%ld", number), only much faster. |
809 This is equivalent to sprintf(buffer, "%ld", number), only much | |
810 faster. | |
811 | 940 |
812 BUFFER should accept 24 bytes. This should suffice for the longest | 941 BUFFER should accept 24 bytes. This should suffice for the longest |
813 numbers on 64-bit machines, including the `-' sign and the trailing | 942 numbers on 64-bit machines, including the `-' sign and the trailing |
814 \0. */ | 943 \0. */ |
815 void | 944 void |
857 *p = '\0'; | 986 *p = '\0'; |
858 #endif /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */ | 987 #endif /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */ |
859 } | 988 } |
860 | 989 |
861 static void | 990 static void |
862 print_vector_internal (CONST char *start, CONST char *end, | 991 print_vector_internal (const char *start, const char *end, |
863 Lisp_Object obj, | 992 Lisp_Object obj, |
864 Lisp_Object printcharfun, int escapeflag) | 993 Lisp_Object printcharfun, int escapeflag) |
865 { | 994 { |
866 /* This function can GC */ | 995 /* This function can GC */ |
867 int i; | 996 int i; |
1275 | 1404 |
1276 /* If we print an uninterned symbol as part of a complex object and | 1405 /* If we print an uninterned symbol as part of a complex object and |
1277 the flag print-gensym is non-nil, prefix it with #n= to read the | 1406 the flag print-gensym is non-nil, prefix it with #n= to read the |
1278 object back with the #n# reader syntax later if needed. */ | 1407 object back with the #n# reader syntax later if needed. */ |
1279 if (!NILP (Vprint_gensym) | 1408 if (!NILP (Vprint_gensym) |
1280 /* #### Test whether this produces a noticable slow-down for | 1409 /* #### Test whether this produces a noticeable slow-down for |
1281 printing when print-gensym is non-nil. */ | 1410 printing when print-gensym is non-nil. */ |
1282 && !EQ (obj, oblookup (Vobarray, | 1411 && !EQ (obj, oblookup (Vobarray, |
1283 string_data (symbol_name (XSYMBOL (obj))), | 1412 string_data (symbol_name (XSYMBOL (obj))), |
1284 string_length (symbol_name (XSYMBOL (obj)))))) | 1413 string_length (symbol_name (XSYMBOL (obj)))))) |
1285 { | 1414 { |
1383 output_string (printcharfun, 0, nameobj, last, size - last); | 1512 output_string (printcharfun, 0, nameobj, last, size - last); |
1384 } | 1513 } |
1385 UNGCPRO; | 1514 UNGCPRO; |
1386 } | 1515 } |
1387 | 1516 |
1388 /* #ifdef DEBUG_XEMACS */ | 1517 |
1389 | 1518 /* Useful on systems or in places where writing to stdout is unavailable or |
1390 /* I don't like seeing `Note: Strange doc (not fboundp) for function | 1519 not working. */ |
1391 alternate-debugging-output @ 429542' -slb */ | |
1392 /* #### Eek! Any clue how to get rid of it? In fact, how about | |
1393 getting rid of this function altogether? Does anything actually | |
1394 *use* it? --hniksic */ | |
1395 | 1520 |
1396 static int alternate_do_pointer; | 1521 static int alternate_do_pointer; |
1397 static char alternate_do_string[5000]; | 1522 static char alternate_do_string[5000]; |
1398 | 1523 |
1399 DEFUN ("alternate-debugging-output", Falternate_debugging_output, 1, 1, 0, /* | 1524 DEFUN ("alternate-debugging-output", Falternate_debugging_output, 1, 1, 0, /* |
1405 (character)) | 1530 (character)) |
1406 { | 1531 { |
1407 Bufbyte str[MAX_EMCHAR_LEN]; | 1532 Bufbyte str[MAX_EMCHAR_LEN]; |
1408 Bytecount len; | 1533 Bytecount len; |
1409 int extlen; | 1534 int extlen; |
1410 CONST Extbyte *extptr; | 1535 const Extbyte *extptr; |
1411 | 1536 |
1412 CHECK_CHAR_COERCE_INT (character); | 1537 CHECK_CHAR_COERCE_INT (character); |
1413 len = set_charptr_emchar (str, XCHAR (character)); | 1538 len = set_charptr_emchar (str, XCHAR (character)); |
1414 TO_EXTERNAL_FORMAT (DATA, (str, len), | 1539 TO_EXTERNAL_FORMAT (DATA, (str, len), |
1415 ALLOCA, (extptr, extlen), | 1540 ALLOCA, (extptr, extlen), |
1417 memcpy (alternate_do_string + alternate_do_pointer, extptr, extlen); | 1542 memcpy (alternate_do_string + alternate_do_pointer, extptr, extlen); |
1418 alternate_do_pointer += extlen; | 1543 alternate_do_pointer += extlen; |
1419 alternate_do_string[alternate_do_pointer] = 0; | 1544 alternate_do_string[alternate_do_pointer] = 0; |
1420 return character; | 1545 return character; |
1421 } | 1546 } |
1422 /* #endif / * DEBUG_XEMACS */ | |
1423 | 1547 |
1424 DEFUN ("external-debugging-output", Fexternal_debugging_output, 1, 3, 0, /* | 1548 DEFUN ("external-debugging-output", Fexternal_debugging_output, 1, 3, 0, /* |
1425 Write CHAR-OR-STRING to stderr or stdout. | 1549 Write CHAR-OR-STRING to stderr or stdout. |
1426 If optional arg STDOUT-P is non-nil, write to stdout; otherwise, write | 1550 If optional arg STDOUT-P is non-nil, write to stdout; otherwise, write |
1427 to stderr. You can use this function to write directly to the terminal. | 1551 to stderr. You can use this function to write directly to the terminal. |
1428 This function can be used as the STREAM argument of Fprint() or the like. | 1552 This function can be used as the STREAM argument of Fprint() or the like. |
1553 | |
1554 Under MS Windows, this writes output to the console window (which is | |
1555 created, if necessary), unless XEmacs is being run noninteractively | |
1556 \(i.e. using the `-batch' argument). | |
1429 | 1557 |
1430 If you have opened a termscript file (using `open-termscript'), then | 1558 If you have opened a termscript file (using `open-termscript'), then |
1431 the output also will be logged to this file. | 1559 the output also will be logged to this file. |
1432 */ | 1560 */ |
1433 (char_or_string, stdout_p, device)) | 1561 (char_or_string, stdout_p, device)) |
1459 | 1587 |
1460 if (STRINGP (char_or_string)) | 1588 if (STRINGP (char_or_string)) |
1461 write_string_to_stdio_stream (file, con, | 1589 write_string_to_stdio_stream (file, con, |
1462 XSTRING_DATA (char_or_string), | 1590 XSTRING_DATA (char_or_string), |
1463 0, XSTRING_LENGTH (char_or_string), | 1591 0, XSTRING_LENGTH (char_or_string), |
1464 Qterminal); | 1592 Qterminal, 1); |
1465 else | 1593 else |
1466 { | 1594 { |
1467 Bufbyte str[MAX_EMCHAR_LEN]; | 1595 Bufbyte str[MAX_EMCHAR_LEN]; |
1468 Bytecount len; | 1596 Bytecount len; |
1469 | 1597 |
1470 CHECK_CHAR_COERCE_INT (char_or_string); | 1598 CHECK_CHAR_COERCE_INT (char_or_string); |
1471 len = set_charptr_emchar (str, XCHAR (char_or_string)); | 1599 len = set_charptr_emchar (str, XCHAR (char_or_string)); |
1472 write_string_to_stdio_stream (file, con, str, 0, len, Qterminal); | 1600 write_string_to_stdio_stream (file, con, str, 0, len, Qterminal, 1); |
1473 } | 1601 } |
1474 | 1602 |
1475 return char_or_string; | 1603 return char_or_string; |
1476 } | 1604 } |
1477 | 1605 |
1525 Vprint_length = make_int (debug_print_length); | 1653 Vprint_length = make_int (debug_print_length); |
1526 if (debug_print_level > 0) | 1654 if (debug_print_level > 0) |
1527 Vprint_level = make_int (debug_print_level); | 1655 Vprint_level = make_int (debug_print_level); |
1528 | 1656 |
1529 print_internal (debug_print_obj, Qexternal_debugging_output, 1); | 1657 print_internal (debug_print_obj, Qexternal_debugging_output, 1); |
1658 alternate_do_pointer = 0; | |
1659 print_internal (debug_print_obj, Qalternate_debugging_output, 1); | |
1660 #ifdef WIN32_NATIVE | |
1661 /* Write out to the debugger, as well */ | |
1662 print_internal (debug_print_obj, Qmswindows_debugging_output, 1); | |
1663 #endif | |
1530 | 1664 |
1531 Vinhibit_quit = save_Vinhibit_quit; | 1665 Vinhibit_quit = save_Vinhibit_quit; |
1532 Vprint_level = save_Vprint_level; | 1666 Vprint_level = save_Vprint_level; |
1533 Vprint_length = save_Vprint_length; | 1667 Vprint_length = save_Vprint_length; |
1534 print_depth = save_print_depth; | 1668 print_depth = save_print_depth; |
1540 void | 1674 void |
1541 debug_print (Lisp_Object debug_print_obj) | 1675 debug_print (Lisp_Object debug_print_obj) |
1542 { | 1676 { |
1543 debug_print_no_newline (debug_print_obj); | 1677 debug_print_no_newline (debug_print_obj); |
1544 stderr_out ("\n"); | 1678 stderr_out ("\n"); |
1545 fflush (stderr); | |
1546 } | 1679 } |
1547 | 1680 |
1548 /* Debugging kludge -- unbuffered */ | 1681 /* Debugging kludge -- unbuffered */ |
1549 /* This function provided for the benefit of the debugger. */ | 1682 /* This function provided for the benefit of the debugger. */ |
1550 void debug_backtrace (void); | 1683 void debug_backtrace (void); |
1573 if (debug_print_level > 0) | 1706 if (debug_print_level > 0) |
1574 Vprint_level = make_int (debug_print_level); | 1707 Vprint_level = make_int (debug_print_level); |
1575 | 1708 |
1576 Fbacktrace (Qexternal_debugging_output, Qt); | 1709 Fbacktrace (Qexternal_debugging_output, Qt); |
1577 stderr_out ("\n"); | 1710 stderr_out ("\n"); |
1578 fflush (stderr); | |
1579 | 1711 |
1580 Vinhibit_quit = old_inhibit_quit; | 1712 Vinhibit_quit = old_inhibit_quit; |
1581 Vprint_level = old_print_level; | 1713 Vprint_level = old_print_level; |
1582 Vprint_length = old_print_length; | 1714 Vprint_length = old_print_length; |
1583 print_depth = old_print_depth; | 1715 print_depth = old_print_depth; |
1591 debug_short_backtrace (int length) | 1723 debug_short_backtrace (int length) |
1592 { | 1724 { |
1593 int first = 1; | 1725 int first = 1; |
1594 struct backtrace *bt = backtrace_list; | 1726 struct backtrace *bt = backtrace_list; |
1595 stderr_out (" ["); | 1727 stderr_out (" ["); |
1596 fflush (stderr); | |
1597 while (length > 0 && bt) | 1728 while (length > 0 && bt) |
1598 { | 1729 { |
1599 if (!first) | 1730 if (!first) |
1600 { | 1731 { |
1601 stderr_out (", "); | 1732 stderr_out (", "); |
1602 fflush (stderr); | |
1603 } | 1733 } |
1604 if (COMPILED_FUNCTIONP (*bt->function)) | 1734 if (COMPILED_FUNCTIONP (*bt->function)) |
1605 { | 1735 { |
1606 #if defined(COMPILED_FUNCTION_ANNOTATION_HACK) | 1736 #if defined(COMPILED_FUNCTION_ANNOTATION_HACK) |
1607 Lisp_Object ann = | 1737 Lisp_Object ann = |
1610 Lisp_Object ann = Qnil; | 1740 Lisp_Object ann = Qnil; |
1611 #endif | 1741 #endif |
1612 if (!NILP (ann)) | 1742 if (!NILP (ann)) |
1613 { | 1743 { |
1614 stderr_out ("<compiled-function from "); | 1744 stderr_out ("<compiled-function from "); |
1615 fflush (stderr); | |
1616 debug_print_no_newline (ann); | 1745 debug_print_no_newline (ann); |
1617 stderr_out (">"); | 1746 stderr_out (">"); |
1618 fflush (stderr); | |
1619 } | 1747 } |
1620 else | 1748 else |
1621 { | 1749 { |
1622 stderr_out ("<compiled-function of unknown origin>"); | 1750 stderr_out ("<compiled-function of unknown origin>"); |
1623 fflush (stderr); | |
1624 } | 1751 } |
1625 } | 1752 } |
1626 else | 1753 else |
1627 debug_print_no_newline (*bt->function); | 1754 debug_print_no_newline (*bt->function); |
1628 first = 0; | 1755 first = 0; |
1629 length--; | 1756 length--; |
1630 bt = bt->next; | 1757 bt = bt->next; |
1631 } | 1758 } |
1632 stderr_out ("]\n"); | 1759 stderr_out ("]\n"); |
1633 fflush (stderr); | |
1634 } | 1760 } |
1635 | 1761 |
1636 #endif /* debugging kludge */ | 1762 #endif /* debugging kludge */ |
1637 | 1763 |
1638 | 1764 |
1658 DEFSUBR (Fwrite_char); | 1784 DEFSUBR (Fwrite_char); |
1659 DEFSUBR (Falternate_debugging_output); | 1785 DEFSUBR (Falternate_debugging_output); |
1660 DEFSUBR (Fexternal_debugging_output); | 1786 DEFSUBR (Fexternal_debugging_output); |
1661 DEFSUBR (Fopen_termscript); | 1787 DEFSUBR (Fopen_termscript); |
1662 defsymbol (&Qexternal_debugging_output, "external-debugging-output"); | 1788 defsymbol (&Qexternal_debugging_output, "external-debugging-output"); |
1789 defsymbol (&Qalternate_debugging_output, "alternate-debugging-output"); | |
1790 #ifdef HAVE_MS_WINDOWS | |
1791 defsymbol (&Qmswindows_debugging_output, "mswindows-debugging-output"); | |
1792 #endif | |
1663 DEFSUBR (Fwith_output_to_temp_buffer); | 1793 DEFSUBR (Fwith_output_to_temp_buffer); |
1664 } | 1794 } |
1665 | 1795 |
1666 void | 1796 void |
1667 reinit_vars_of_print (void) | 1797 reinit_vars_of_print (void) |