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