comparison src/print.c @ 20:859a2309aef8 r19-15b93

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 0293115a14e9
children 4103f0995bd7
comparison
equal deleted inserted replaced
19:ac1f612d5250 20:859a2309aef8
373 /* This function can GC */ 373 /* This function can GC */
374 write_string_1 ((CONST Bufbyte *) str, strlen (str), stream); 374 write_string_1 ((CONST Bufbyte *) str, strlen (str), stream);
375 } 375 }
376 376
377 377
378 DEFUN ("write-char", Fwrite_char, Swrite_char, 1, 2, 0 /* 378 DEFUN ("write-char", Fwrite_char, 1, 2, 0, /*
379 Output character CH to stream STREAM. 379 Output character CH to stream STREAM.
380 STREAM defaults to the value of `standard-output' (which see). 380 STREAM defaults to the value of `standard-output' (which see).
381 */ ) 381 */
382 (ch, stream) 382 (ch, stream))
383 Lisp_Object ch, stream;
384 { 383 {
385 /* This function can GC */ 384 /* This function can GC */
386 Bufbyte str[MAX_EMCHAR_LEN]; 385 Bufbyte str[MAX_EMCHAR_LEN];
387 Bytecount len; 386 Bytecount len;
388 387
438 UNGCPRO; 437 UNGCPRO;
439 438
440 return unbind_to (speccount, arg); 439 return unbind_to (speccount, arg);
441 } 440 }
442 441
443 DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, Swith_output_to_temp_buffer, 442 DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, 1, UNEVALLED, 0, /*
444 1, UNEVALLED, 0 /*
445 Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer. 443 Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer.
446 The buffer is cleared out initially, and marked as unmodified when done. 444 The buffer is cleared out initially, and marked as unmodified when done.
447 All output done by BODY is inserted in that buffer by default. 445 All output done by BODY is inserted in that buffer by default.
448 The buffer is displayed in another window, but not selected. 446 The buffer is displayed in another window, but not selected.
449 The value of the last form in BODY is returned. 447 The value of the last form in BODY is returned.
450 If BODY does not finish normally, the buffer BUFNAME is not displayed. 448 If BODY does not finish normally, the buffer BUFNAME is not displayed.
451 449
452 If variable `temp-buffer-show-function' is non-nil, call it at the end 450 If variable `temp-buffer-show-function' is non-nil, call it at the end
453 to get the buffer displayed. It gets one argument, the buffer to display. 451 to get the buffer displayed. It gets one argument, the buffer to display.
454 */ ) 452 */
455 (args) 453 (args))
456 Lisp_Object args;
457 { 454 {
458 /* This function can GC */ 455 /* This function can GC */
459 struct gcpro gcpro1; 456 struct gcpro gcpro1;
460 Lisp_Object name; 457 Lisp_Object name;
461 int speccount = specpdl_depth (); 458 int speccount = specpdl_depth ();
479 476
480 return unbind_to (speccount, val); 477 return unbind_to (speccount, val);
481 } 478 }
482 #endif /* not standalone */ 479 #endif /* not standalone */
483 480
484 DEFUN ("terpri", Fterpri, Sterpri, 0, 1, 0 /* 481 DEFUN ("terpri", Fterpri, 0, 1, 0, /*
485 Output a newline to STREAM. 482 Output a newline to STREAM.
486 If STREAM is omitted or nil, the value of `standard-output' is used. 483 If STREAM is omitted or nil, the value of `standard-output' is used.
487 */ ) 484 */
488 (stream) 485 (stream))
489 Lisp_Object stream;
490 { 486 {
491 /* This function can GC */ 487 /* This function can GC */
492 Bufbyte str[1]; 488 Bufbyte str[1];
493 str[0] = '\n'; 489 str[0] = '\n';
494 output_string (canonicalize_printcharfun (stream), str, Qnil, 0, 1); 490 output_string (canonicalize_printcharfun (stream), str, Qnil, 0, 1);
495 return Qt; 491 return Qt;
496 } 492 }
497 493
498 DEFUN ("prin1", Fprin1, Sprin1, 1, 2, 0 /* 494 DEFUN ("prin1", Fprin1, 1, 2, 0, /*
499 Output the printed representation of OBJECT, any Lisp object. 495 Output the printed representation of OBJECT, any Lisp object.
500 Quoting characters are printed when needed to make output that `read' 496 Quoting characters are printed when needed to make output that `read'
501 can handle, whenever this is possible. 497 can handle, whenever this is possible.
502 Output stream is STREAM, or value of `standard-output' (which see). 498 Output stream is STREAM, or value of `standard-output' (which see).
503 */ ) 499 */
504 (object, stream) 500 (object, stream))
505 Lisp_Object object, stream;
506 { 501 {
507 /* This function can GC */ 502 /* This function can GC */
508 Lisp_Object the_stream = Qnil; 503 Lisp_Object the_stream = Qnil;
509 struct gcpro gcpro1, gcpro2, gcpro3; 504 struct gcpro gcpro1, gcpro2, gcpro3;
510 505
518 } 513 }
519 514
520 /* a buffer which is used to hold output being built by prin1-to-string */ 515 /* a buffer which is used to hold output being built by prin1-to-string */
521 Lisp_Object Vprin1_to_string_buffer; 516 Lisp_Object Vprin1_to_string_buffer;
522 517
523 DEFUN ("prin1-to-string", Fprin1_to_string, Sprin1_to_string, 1, 2, 0 /* 518 DEFUN ("prin1-to-string", Fprin1_to_string, 1, 2, 0, /*
524 Return a string containing the printed representation of OBJECT, 519 Return a string containing the printed representation of OBJECT,
525 any Lisp object. Quoting characters are used when needed to make output 520 any Lisp object. Quoting characters are used when needed to make output
526 that `read' can handle, whenever this is possible, unless the optional 521 that `read' can handle, whenever this is possible, unless the optional
527 second argument NOESCAPE is non-nil. 522 second argument NOESCAPE is non-nil.
528 */ ) 523 */
529 (object, noescape) 524 (object, noescape))
530 Lisp_Object object, noescape;
531 { 525 {
532 /* This function can GC */ 526 /* This function can GC */
533 Lisp_Object old = Fcurrent_buffer (); 527 Lisp_Object old = Fcurrent_buffer ();
534 struct buffer *out = XBUFFER (Vprin1_to_string_buffer); 528 struct buffer *out = XBUFFER (Vprin1_to_string_buffer);
535 Lisp_Object stream = Qnil; 529 Lisp_Object stream = Qnil;
550 Fset_buffer (old); 544 Fset_buffer (old);
551 UNGCPRO; 545 UNGCPRO;
552 return (object); 546 return (object);
553 } 547 }
554 548
555 DEFUN ("princ", Fprinc, Sprinc, 1, 2, 0 /* 549 DEFUN ("princ", Fprinc, 1, 2, 0, /*
556 Output the printed representation of OBJECT, any Lisp object. 550 Output the printed representation of OBJECT, any Lisp object.
557 No quoting characters are used; no delimiters are printed around 551 No quoting characters are used; no delimiters are printed around
558 the contents of strings. 552 the contents of strings.
559 Output stream is STREAM, or value of standard-output (which see). 553 Output stream is STREAM, or value of standard-output (which see).
560 */ ) 554 */
561 (obj, stream) 555 (obj, stream))
562 Lisp_Object obj, stream;
563 { 556 {
564 /* This function can GC */ 557 /* This function can GC */
565 Lisp_Object the_stream = Qnil; 558 Lisp_Object the_stream = Qnil;
566 struct gcpro gcpro1, gcpro2, gcpro3; 559 struct gcpro gcpro1, gcpro2, gcpro3;
567 560
572 print_finish (the_stream); 565 print_finish (the_stream);
573 UNGCPRO; 566 UNGCPRO;
574 return (obj); 567 return (obj);
575 } 568 }
576 569
577 DEFUN ("print", Fprint, Sprint, 1, 2, 0 /* 570 DEFUN ("print", Fprint, 1, 2, 0, /*
578 Output the printed representation of OBJECT, with newlines around it. 571 Output the printed representation of OBJECT, with newlines around it.
579 Quoting characters are printed when needed to make output that `read' 572 Quoting characters are printed when needed to make output that `read'
580 can handle, whenever this is possible. 573 can handle, whenever this is possible.
581 Output stream is STREAM, or value of `standard-output' (which see). 574 Output stream is STREAM, or value of `standard-output' (which see).
582 */ ) 575 */
583 (obj, stream) 576 (obj, stream))
584 Lisp_Object obj, stream;
585 { 577 {
586 /* This function can GC */ 578 /* This function can GC */
587 Lisp_Object the_stream = Qnil; 579 Lisp_Object the_stream = Qnil;
588 struct gcpro gcpro1, gcpro2, gcpro3; 580 struct gcpro gcpro1, gcpro2, gcpro3;
589 581
1158 1150
1159 1151
1160 int alternate_do_pointer; 1152 int alternate_do_pointer;
1161 char alternate_do_string[5000]; 1153 char alternate_do_string[5000];
1162 1154
1163 DEFUN ("alternate-debugging-output", Falternate_debugging_output, 1155 DEFUN ("alternate-debugging-output", Falternate_debugging_output, 1, 1, 0, /*
1164 Salternate_debugging_output, 1, 1, 0 /*
1165 Append CHARACTER to the array `alternate_do_string'. 1156 Append CHARACTER to the array `alternate_do_string'.
1166 This can be used in place of `external-debugging-output' as a function 1157 This can be used in place of `external-debugging-output' as a function
1167 to be passed to `print'. Before calling `print', set `alternate_do_pointer' 1158 to be passed to `print'. Before calling `print', set `alternate_do_pointer'
1168 to 0. 1159 to 0.
1169 1160
1170 */ ) 1161 */
1171 (character) 1162 (character))
1172 Lisp_Object character;
1173 { 1163 {
1174 Bufbyte str[MAX_EMCHAR_LEN]; 1164 Bufbyte str[MAX_EMCHAR_LEN];
1175 Bytecount len; 1165 Bytecount len;
1176 int extlen; 1166 int extlen;
1177 CONST Extbyte *extptr; 1167 CONST Extbyte *extptr;
1183 alternate_do_pointer += extlen; 1173 alternate_do_pointer += extlen;
1184 alternate_do_string[alternate_do_pointer] = 0; 1174 alternate_do_string[alternate_do_pointer] = 0;
1185 return character; 1175 return character;
1186 } 1176 }
1187 1177
1188 DEFUN ("external-debugging-output", Fexternal_debugging_output, 1178 DEFUN ("external-debugging-output", Fexternal_debugging_output, 1, 3, 0, /*
1189 Sexternal_debugging_output, 1, 3, 0 /*
1190 Write CHAR-OR-STRING to stderr or stdout. 1179 Write CHAR-OR-STRING to stderr or stdout.
1191 If optional arg STDOUT-P is non-nil, write to stdout; otherwise, write 1180 If optional arg STDOUT-P is non-nil, write to stdout; otherwise, write
1192 to stderr. You can use this function to write directly to the terminal. 1181 to stderr. You can use this function to write directly to the terminal.
1193 This function can be used as the STREAM argument of Fprint() or the like. 1182 This function can be used as the STREAM argument of Fprint() or the like.
1194 1183
1195 If you have opened a termscript file (using `open-termscript'), then 1184 If you have opened a termscript file (using `open-termscript'), then
1196 the output also will be logged to this file. 1185 the output also will be logged to this file.
1197 */ ) 1186 */
1198 (char_or_string, stdout_p, device) 1187 (char_or_string, stdout_p, device))
1199 Lisp_Object char_or_string, stdout_p, device;
1200 { 1188 {
1201 FILE *file = 0; 1189 FILE *file = 0;
1202 struct console *con = 0; 1190 struct console *con = 0;
1203 1191
1204 if (NILP (device)) 1192 if (NILP (device))
1239 } 1227 }
1240 1228
1241 return char_or_string; 1229 return char_or_string;
1242 } 1230 }
1243 1231
1244 DEFUN ("open-termscript", Fopen_termscript, Sopen_termscript, 1232 DEFUN ("open-termscript", Fopen_termscript, 1, 1, "FOpen termscript file: ", /*
1245 1, 1, "FOpen termscript file: " /*
1246 Start writing all terminal output to FILE as well as the terminal. 1233 Start writing all terminal output to FILE as well as the terminal.
1247 FILE = nil means just close any termscript file currently open. 1234 FILE = nil means just close any termscript file currently open.
1248 */ ) 1235 */
1249 (file) 1236 (file))
1250 Lisp_Object file;
1251 { 1237 {
1252 /* This function can GC */ 1238 /* This function can GC */
1253 if (termscript != 0) 1239 if (termscript != 0)
1254 fclose (termscript); 1240 fclose (termscript);
1255 termscript = 0; 1241 termscript = 0;
1405 #endif 1391 #endif
1406 1392
1407 defsymbol (&Qprint_length, "print-length"); 1393 defsymbol (&Qprint_length, "print-length");
1408 1394
1409 defsymbol (&Qprint_string_length, "print-string-length"); 1395 defsymbol (&Qprint_string_length, "print-string-length");
1410 defsubr (&Sprin1); 1396 DEFSUBR (Fprin1);
1411 defsubr (&Sprin1_to_string); 1397 DEFSUBR (Fprin1_to_string);
1412 defsubr (&Sprinc); 1398 DEFSUBR (Fprinc);
1413 defsubr (&Sprint); 1399 DEFSUBR (Fprint);
1414 defsubr (&Sterpri); 1400 DEFSUBR (Fterpri);
1415 defsubr (&Swrite_char); 1401 DEFSUBR (Fwrite_char);
1416 defsubr (&Salternate_debugging_output); 1402 DEFSUBR (Falternate_debugging_output);
1417 defsymbol (&Qalternate_debugging_output, "alternate-debugging-output"); 1403 defsymbol (&Qalternate_debugging_output, "alternate-debugging-output");
1418 defsubr (&Sexternal_debugging_output); 1404 DEFSUBR (Fexternal_debugging_output);
1419 defsubr (&Sopen_termscript); 1405 DEFSUBR (Fopen_termscript);
1420 defsymbol (&Qexternal_debugging_output, "external-debugging-output"); 1406 defsymbol (&Qexternal_debugging_output, "external-debugging-output");
1421 #ifndef standalone 1407 #ifndef standalone
1422 defsubr (&Swith_output_to_temp_buffer); 1408 DEFSUBR (Fwith_output_to_temp_buffer);
1423 #endif /* not standalone */ 1409 #endif /* not standalone */
1424 } 1410 }
1425 1411
1426 void 1412 void
1427 lstream_type_create_print (void) 1413 lstream_type_create_print (void)