comparison src/print.c @ 89909:68c22ea6027c

Sync to HEAD
author Kenichi Handa <handa@m17n.org>
date Fri, 16 Apr 2004 12:51:06 +0000
parents 70daf4dac8c0
children 4c90ffeb71c5
comparison
equal deleted inserted replaced
89908:ee1402f7b568 89909:68c22ea6027c
509 GCPRO1 (string); 509 GCPRO1 (string);
510 if (size == size_byte) 510 if (size == size_byte)
511 for (i = 0; i < size; i++) 511 for (i = 0; i < size; i++)
512 PRINTCHAR (SREF (string, i)); 512 PRINTCHAR (SREF (string, i));
513 else 513 else
514 for (i = 0; i < size_byte; i++) 514 for (i = 0; i < size_byte; )
515 { 515 {
516 /* Here, we must convert each multi-byte form to the 516 /* Here, we must convert each multi-byte form to the
517 corresponding character code before handing it to PRINTCHAR. */ 517 corresponding character code before handing it to PRINTCHAR. */
518 int len; 518 int len;
519 int ch = STRING_CHAR_AND_LENGTH (SDATA (string) + i, 519 int ch = STRING_CHAR_AND_LENGTH (SDATA (string) + i,
756 756
757 A printed representation of an object is text which describes that object. */) 757 A printed representation of an object is text which describes that object. */)
758 (object, noescape) 758 (object, noescape)
759 Lisp_Object object, noescape; 759 Lisp_Object object, noescape;
760 { 760 {
761 PRINTDECLARE;
762 Lisp_Object printcharfun; 761 Lisp_Object printcharfun;
763 /* struct gcpro gcpro1, gcpro2; */ 762 /* struct gcpro gcpro1, gcpro2; */
764 Lisp_Object save_deactivate_mark; 763 Lisp_Object save_deactivate_mark;
765 int count = specpdl_ptr - specpdl; 764 int count = specpdl_ptr - specpdl;
765 struct buffer *previous;
766 766
767 specbind (Qinhibit_modification_hooks, Qt); 767 specbind (Qinhibit_modification_hooks, Qt);
768 768
769 /* Save and restore this--we are altering a buffer 769 {
770 but we don't want to deactivate the mark just for that. 770 PRINTDECLARE;
771 No need for specbind, since errors deactivate the mark. */ 771
772 save_deactivate_mark = Vdeactivate_mark; 772 /* Save and restore this--we are altering a buffer
773 /* GCPRO2 (object, save_deactivate_mark); */ 773 but we don't want to deactivate the mark just for that.
774 abort_on_gc++; 774 No need for specbind, since errors deactivate the mark. */
775 775 save_deactivate_mark = Vdeactivate_mark;
776 printcharfun = Vprin1_to_string_buffer; 776 /* GCPRO2 (object, save_deactivate_mark); */
777 PRINTPREPARE; 777 abort_on_gc++;
778 print (object, printcharfun, NILP (noescape)); 778
779 /* Make Vprin1_to_string_buffer be the default buffer after PRINTFINSH */ 779 printcharfun = Vprin1_to_string_buffer;
780 PRINTFINISH; 780 PRINTPREPARE;
781 print (object, printcharfun, NILP (noescape));
782 /* Make Vprin1_to_string_buffer be the default buffer after PRINTFINSH */
783 PRINTFINISH;
784 }
785
786 previous = current_buffer;
781 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer)); 787 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
782 object = Fbuffer_string (); 788 object = Fbuffer_string ();
783 if (SBYTES (object) == SCHARS (object)) 789 if (SBYTES (object) == SCHARS (object))
784 STRING_SET_UNIBYTE (object); 790 STRING_SET_UNIBYTE (object);
785 791
792 /* Note that this won't make prepare_to_modify_buffer call
793 ask-user-about-supersession-threat because this buffer
794 does not visit a file. */
786 Ferase_buffer (); 795 Ferase_buffer ();
787 set_buffer_internal (old); 796 set_buffer_internal (previous);
788 797
789 Vdeactivate_mark = save_deactivate_mark; 798 Vdeactivate_mark = save_deactivate_mark;
790 /* UNGCPRO; */ 799 /* UNGCPRO; */
791 800
792 abort_on_gc--; 801 abort_on_gc--;
900 #endif 909 #endif
901 910
902 return character; 911 return character;
903 } 912 }
904 913
914
915 #if defined(GNU_LINUX)
916
917 /* This functionality is not vitally important in general, so we rely on
918 non-portable ability to use stderr as lvalue. */
919
920 #define WITH_REDIRECT_DEBUGGING_OUTPUT 1
921
922 FILE *initial_stderr_stream = NULL;
923
924 DEFUN ("redirect-debugging-output", Fredirect_debugging_output, Sredirect_debugging_output,
925 1, 2,
926 "FDebug output file: \nP",
927 doc: /* Redirect debugging output (stderr stream) to file FILE.
928 If FILE is nil, reset target to the initial stderr stream.
929 Optional arg APPEND non-nil (interactively, with prefix arg) means
930 append to existing target file. */)
931 (file, append)
932 Lisp_Object file, append;
933 {
934 if (initial_stderr_stream != NULL)
935 fclose(stderr);
936 stderr = initial_stderr_stream;
937 initial_stderr_stream = NULL;
938
939 if (STRINGP (file))
940 {
941 file = Fexpand_file_name (file, Qnil);
942 initial_stderr_stream = stderr;
943 stderr = fopen(SDATA (file), NILP (append) ? "w" : "a");
944 if (stderr == NULL)
945 {
946 stderr = initial_stderr_stream;
947 initial_stderr_stream = NULL;
948 report_file_error ("Cannot open debugging output stream",
949 Fcons (file, Qnil));
950 }
951 }
952 return Qnil;
953 }
954 #endif /* GNU_LINUX */
955
956
905 /* This is the interface for debugging printing. */ 957 /* This is the interface for debugging printing. */
906 958
907 void 959 void
908 debug_print (arg) 960 debug_print (arg)
909 Lisp_Object arg; 961 Lisp_Object arg;
912 fprintf (stderr, "\r\n"); 964 fprintf (stderr, "\r\n");
913 } 965 }
914 966
915 DEFUN ("error-message-string", Ferror_message_string, Serror_message_string, 967 DEFUN ("error-message-string", Ferror_message_string, Serror_message_string,
916 1, 1, 0, 968 1, 1, 0,
917 doc: /* Convert an error value (ERROR-SYMBOL . DATA) to an error message. */) 969 doc: /* Convert an error value (ERROR-SYMBOL . DATA) to an error message.
970 See Info anchor `(elisp)Definition of signal' for some details on how this
971 error message is constructed. */)
918 (obj) 972 (obj)
919 Lisp_Object obj; 973 Lisp_Object obj;
920 { 974 {
921 struct buffer *old = current_buffer; 975 struct buffer *old = current_buffer;
922 Lisp_Object value; 976 Lisp_Object value;
1220 more than once in OBJ: Qnil at the first time, and Qt after that . */ 1274 more than once in OBJ: Qnil at the first time, and Qt after that . */
1221 static void 1275 static void
1222 print_preprocess (obj) 1276 print_preprocess (obj)
1223 Lisp_Object obj; 1277 Lisp_Object obj;
1224 { 1278 {
1225 int i, size; 1279 int i;
1280 EMACS_INT size;
1226 1281
1227 loop: 1282 loop:
1228 if (STRINGP (obj) || CONSP (obj) || VECTORP (obj) 1283 if (STRINGP (obj) || CONSP (obj) || VECTORP (obj)
1229 || COMPILEDP (obj) || CHAR_TABLE_P (obj) 1284 || COMPILEDP (obj) || CHAR_TABLE_P (obj)
1230 || (! NILP (Vprint_gensym) 1285 || (! NILP (Vprint_gensym)
1286 print_preprocess (XCAR (obj)); 1341 print_preprocess (XCAR (obj));
1287 obj = XCDR (obj); 1342 obj = XCDR (obj);
1288 goto loop; 1343 goto loop;
1289 1344
1290 case Lisp_Vectorlike: 1345 case Lisp_Vectorlike:
1291 size = XVECTOR (obj)->size & PSEUDOVECTOR_SIZE_MASK; 1346 size = XVECTOR (obj)->size;
1347 if (size & PSEUDOVECTOR_FLAG)
1348 size &= PSEUDOVECTOR_SIZE_MASK;
1292 for (i = 0; i < size; i++) 1349 for (i = 0; i < size; i++)
1293 print_preprocess (XVECTOR (obj)->contents[i]); 1350 print_preprocess (XVECTOR (obj)->contents[i]);
1294 break; 1351 break;
1295 1352
1296 default: 1353 default:
1936 strout (buf, -1, -1, printcharfun, 0); 1993 strout (buf, -1, -1, printcharfun, 0);
1937 PRINTCHAR ('>'); 1994 PRINTCHAR ('>');
1938 } 1995 }
1939 else 1996 else
1940 { 1997 {
1941 int size = XVECTOR (obj)->size; 1998 EMACS_INT size = XVECTOR (obj)->size;
1942 if (COMPILEDP (obj)) 1999 if (COMPILEDP (obj))
1943 { 2000 {
1944 PRINTCHAR ('#'); 2001 PRINTCHAR ('#');
1945 size &= PSEUDOVECTOR_SIZE_MASK; 2002 size &= PSEUDOVECTOR_SIZE_MASK;
1946 } 2003 }
2271 defsubr (&Sprinc); 2328 defsubr (&Sprinc);
2272 defsubr (&Sprint); 2329 defsubr (&Sprint);
2273 defsubr (&Sterpri); 2330 defsubr (&Sterpri);
2274 defsubr (&Swrite_char); 2331 defsubr (&Swrite_char);
2275 defsubr (&Sexternal_debugging_output); 2332 defsubr (&Sexternal_debugging_output);
2333 #ifdef WITH_REDIRECT_DEBUGGING_OUTPUT
2334 defsubr (&Sredirect_debugging_output);
2335 #endif
2276 2336
2277 Qexternal_debugging_output = intern ("external-debugging-output"); 2337 Qexternal_debugging_output = intern ("external-debugging-output");
2278 staticpro (&Qexternal_debugging_output); 2338 staticpro (&Qexternal_debugging_output);
2279 2339
2280 Qprint_escape_newlines = intern ("print-escape-newlines"); 2340 Qprint_escape_newlines = intern ("print-escape-newlines");
2289 print_prune_charset_plist = Qnil; 2349 print_prune_charset_plist = Qnil;
2290 staticpro (&print_prune_charset_plist); 2350 staticpro (&print_prune_charset_plist);
2291 2351
2292 defsubr (&Swith_output_to_temp_buffer); 2352 defsubr (&Swith_output_to_temp_buffer);
2293 } 2353 }
2354
2355 /* arch-tag: bc797170-94ae-41de-86e3-75e20f8f7a39
2356 (do not change this comment) */