aboutsummaryrefslogtreecommitdiffstats
path: root/src/print.c
diff options
context:
space:
mode:
authorStefan Monnier2010-07-23 17:23:09 +0200
committerStefan Monnier2010-07-23 17:23:09 +0200
commit0ee81a0ce066375eac701c06cdfbdebefe594fdc (patch)
treef0dccd24163316cfe688f927681a3032a9b1fe2f /src/print.c
parent894e369ddf48e191638b8e66ce732f24ff9abe2a (diff)
parent94da839793affa2a270bc26cee9c4d95d4dc4708 (diff)
downloademacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.tar.gz
emacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.zip
Merge from trunk
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c138
1 files changed, 45 insertions, 93 deletions
diff --git a/src/print.c b/src/print.c
index fb298233666..614ad6f2632 100644
--- a/src/print.c
+++ b/src/print.c
@@ -168,7 +168,7 @@ extern int noninteractive_need_newline;
168 168
169extern int minibuffer_auto_raise; 169extern int minibuffer_auto_raise;
170 170
171void print_interval (); 171void print_interval (INTERVAL interval, Lisp_Object printcharfun);
172 172
173/* GDB resets this to zero on W32 to disable OutputDebugString calls. */ 173/* GDB resets this to zero on W32 to disable OutputDebugString calls. */
174int print_output_debug_flag = 1; 174int print_output_debug_flag = 1;
@@ -287,10 +287,9 @@ int print_output_debug_flag = 1;
287 when there is a recursive call to print. */ 287 when there is a recursive call to print. */
288 288
289static Lisp_Object 289static Lisp_Object
290print_unwind (saved_text) 290print_unwind (Lisp_Object saved_text)
291 Lisp_Object saved_text;
292{ 291{
293 bcopy (SDATA (saved_text), print_buffer, SCHARS (saved_text)); 292 memcpy (print_buffer, SDATA (saved_text), SCHARS (saved_text));
294 return Qnil; 293 return Qnil;
295} 294}
296 295
@@ -301,9 +300,7 @@ print_unwind (saved_text)
301 argument. */ 300 argument. */
302 301
303static void 302static void
304printchar (ch, fun) 303printchar (unsigned int ch, Lisp_Object fun)
305 unsigned int ch;
306 Lisp_Object fun;
307{ 304{
308 if (!NILP (fun) && !EQ (fun, Qt)) 305 if (!NILP (fun) && !EQ (fun, Qt))
309 call1 (fun, make_number (ch)); 306 call1 (fun, make_number (ch));
@@ -319,7 +316,7 @@ printchar (ch, fun)
319 if (print_buffer_pos_byte + len >= print_buffer_size) 316 if (print_buffer_pos_byte + len >= print_buffer_size)
320 print_buffer = (char *) xrealloc (print_buffer, 317 print_buffer = (char *) xrealloc (print_buffer,
321 print_buffer_size *= 2); 318 print_buffer_size *= 2);
322 bcopy (str, print_buffer + print_buffer_pos_byte, len); 319 memcpy (print_buffer + print_buffer_pos_byte, str, len);
323 print_buffer_pos += 1; 320 print_buffer_pos += 1;
324 print_buffer_pos_byte += len; 321 print_buffer_pos_byte += len;
325 } 322 }
@@ -353,11 +350,8 @@ printchar (ch, fun)
353 to data in a Lisp string. Otherwise that is not safe. */ 350 to data in a Lisp string. Otherwise that is not safe. */
354 351
355static void 352static void
356strout (ptr, size, size_byte, printcharfun, multibyte) 353strout (const char *ptr, int size, int size_byte, Lisp_Object printcharfun,
357 char *ptr; 354 int multibyte)
358 int size, size_byte;
359 Lisp_Object printcharfun;
360 int multibyte;
361{ 355{
362 if (size < 0) 356 if (size < 0)
363 size_byte = size = strlen (ptr); 357 size_byte = size = strlen (ptr);
@@ -370,7 +364,7 @@ strout (ptr, size, size_byte, printcharfun, multibyte)
370 print_buffer = (char *) xrealloc (print_buffer, 364 print_buffer = (char *) xrealloc (print_buffer,
371 print_buffer_size); 365 print_buffer_size);
372 } 366 }
373 bcopy (ptr, print_buffer + print_buffer_pos_byte, size_byte); 367 memcpy (print_buffer + print_buffer_pos_byte, ptr, size_byte);
374 print_buffer_pos += size; 368 print_buffer_pos += size;
375 print_buffer_pos_byte += size_byte; 369 print_buffer_pos_byte += size_byte;
376 } 370 }
@@ -440,9 +434,7 @@ strout (ptr, size, size_byte, printcharfun, multibyte)
440 because printing one char can relocate. */ 434 because printing one char can relocate. */
441 435
442static void 436static void
443print_string (string, printcharfun) 437print_string (Lisp_Object string, Lisp_Object printcharfun)
444 Lisp_Object string;
445 Lisp_Object printcharfun;
446{ 438{
447 if (EQ (printcharfun, Qt) || NILP (printcharfun)) 439 if (EQ (printcharfun, Qt) || NILP (printcharfun))
448 { 440 {
@@ -469,7 +461,7 @@ print_string (string, printcharfun)
469 if (chars < bytes) 461 if (chars < bytes)
470 { 462 {
471 newstr = make_uninit_multibyte_string (chars, bytes); 463 newstr = make_uninit_multibyte_string (chars, bytes);
472 bcopy (SDATA (string), SDATA (newstr), chars); 464 memcpy (SDATA (newstr), SDATA (string), chars);
473 str_to_multibyte (SDATA (newstr), bytes, chars); 465 str_to_multibyte (SDATA (newstr), bytes, chars);
474 string = newstr; 466 string = newstr;
475 } 467 }
@@ -488,7 +480,7 @@ print_string (string, printcharfun)
488 USE_SAFE_ALLOCA; 480 USE_SAFE_ALLOCA;
489 481
490 SAFE_ALLOCA (buffer, char *, nbytes); 482 SAFE_ALLOCA (buffer, char *, nbytes);
491 bcopy (SDATA (string), buffer, nbytes); 483 memcpy (buffer, SDATA (string), nbytes);
492 484
493 strout (buffer, chars, SBYTES (string), 485 strout (buffer, chars, SBYTES (string),
494 printcharfun, STRING_MULTIBYTE (string)); 486 printcharfun, STRING_MULTIBYTE (string));
@@ -530,8 +522,7 @@ print_string (string, printcharfun)
530DEFUN ("write-char", Fwrite_char, Swrite_char, 1, 2, 0, 522DEFUN ("write-char", Fwrite_char, Swrite_char, 1, 2, 0,
531 doc: /* Output character CHARACTER to stream PRINTCHARFUN. 523 doc: /* Output character CHARACTER to stream PRINTCHARFUN.
532PRINTCHARFUN defaults to the value of `standard-output' (which see). */) 524PRINTCHARFUN defaults to the value of `standard-output' (which see). */)
533 (character, printcharfun) 525 (Lisp_Object character, Lisp_Object printcharfun)
534 Lisp_Object character, printcharfun;
535{ 526{
536 PRINTDECLARE; 527 PRINTDECLARE;
537 528
@@ -549,9 +540,7 @@ PRINTCHARFUN defaults to the value of `standard-output' (which see). */)
549 Do not use this on the contents of a Lisp string. */ 540 Do not use this on the contents of a Lisp string. */
550 541
551void 542void
552write_string (data, size) 543write_string (const char *data, int size)
553 char *data;
554 int size;
555{ 544{
556 PRINTDECLARE; 545 PRINTDECLARE;
557 Lisp_Object printcharfun; 546 Lisp_Object printcharfun;
@@ -568,10 +557,7 @@ write_string (data, size)
568 Do not use this on the contents of a Lisp string. */ 557 Do not use this on the contents of a Lisp string. */
569 558
570void 559void
571write_string_1 (data, size, printcharfun) 560write_string_1 (const char *data, int size, Lisp_Object printcharfun)
572 char *data;
573 int size;
574 Lisp_Object printcharfun;
575{ 561{
576 PRINTDECLARE; 562 PRINTDECLARE;
577 563
@@ -582,8 +568,7 @@ write_string_1 (data, size, printcharfun)
582 568
583 569
584void 570void
585temp_output_buffer_setup (bufname) 571temp_output_buffer_setup (const char *bufname)
586 const char *bufname;
587{ 572{
588 int count = SPECPDL_INDEX (); 573 int count = SPECPDL_INDEX ();
589 register struct buffer *old = current_buffer; 574 register struct buffer *old = current_buffer;
@@ -616,10 +601,7 @@ temp_output_buffer_setup (bufname)
616} 601}
617 602
618Lisp_Object 603Lisp_Object
619internal_with_output_to_temp_buffer (bufname, function, args) 604internal_with_output_to_temp_buffer (const char *bufname, Lisp_Object (*function) (Lisp_Object), Lisp_Object args)
620 const char *bufname;
621 Lisp_Object (*function) P_ ((Lisp_Object));
622 Lisp_Object args;
623{ 605{
624 int count = SPECPDL_INDEX (); 606 int count = SPECPDL_INDEX ();
625 Lisp_Object buf, val; 607 Lisp_Object buf, val;
@@ -670,8 +652,7 @@ temporarily selected. But it doesn't run `temp-buffer-show-hook'
670if it uses `temp-buffer-show-function'. 652if it uses `temp-buffer-show-function'.
671 653
672usage: (with-output-to-temp-buffer BUFNAME BODY...) */) 654usage: (with-output-to-temp-buffer BUFNAME BODY...) */)
673 (args) 655 (Lisp_Object args)
674 Lisp_Object args;
675{ 656{
676 struct gcpro gcpro1; 657 struct gcpro gcpro1;
677 Lisp_Object name; 658 Lisp_Object name;
@@ -695,16 +676,15 @@ usage: (with-output-to-temp-buffer BUFNAME BODY...) */)
695} 676}
696 677
697 678
698static void print (); 679static void print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag);
699static void print_preprocess (); 680static void print_preprocess (Lisp_Object obj);
700static void print_preprocess_string (); 681static void print_preprocess_string (INTERVAL interval, Lisp_Object arg);
701static void print_object (); 682static void print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag);
702 683
703DEFUN ("terpri", Fterpri, Sterpri, 0, 1, 0, 684DEFUN ("terpri", Fterpri, Sterpri, 0, 1, 0,
704 doc: /* Output a newline to stream PRINTCHARFUN. 685 doc: /* Output a newline to stream PRINTCHARFUN.
705If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used. */) 686If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used. */)
706 (printcharfun) 687 (Lisp_Object printcharfun)
707 Lisp_Object printcharfun;
708{ 688{
709 PRINTDECLARE; 689 PRINTDECLARE;
710 690
@@ -739,8 +719,7 @@ of these:
739 719
740If PRINTCHARFUN is omitted, the value of `standard-output' (which see) 720If PRINTCHARFUN is omitted, the value of `standard-output' (which see)
741is used instead. */) 721is used instead. */)
742 (object, printcharfun) 722 (Lisp_Object object, Lisp_Object printcharfun)
743 Lisp_Object object, printcharfun;
744{ 723{
745 PRINTDECLARE; 724 PRINTDECLARE;
746 725
@@ -766,8 +745,7 @@ OBJECT is any of the Lisp data types: a number, a string, a symbol,
766a list, a buffer, a window, a frame, etc. 745a list, a buffer, a window, a frame, etc.
767 746
768A printed representation of an object is text which describes that object. */) 747A printed representation of an object is text which describes that object. */)
769 (object, noescape) 748 (Lisp_Object object, Lisp_Object noescape)
770 Lisp_Object object, noescape;
771{ 749{
772 Lisp_Object printcharfun; 750 Lisp_Object printcharfun;
773 /* struct gcpro gcpro1, gcpro2; */ 751 /* struct gcpro gcpro1, gcpro2; */
@@ -835,8 +813,7 @@ of these:
835 813
836If PRINTCHARFUN is omitted, the value of `standard-output' (which see) 814If PRINTCHARFUN is omitted, the value of `standard-output' (which see)
837is used instead. */) 815is used instead. */)
838 (object, printcharfun) 816 (Lisp_Object object, Lisp_Object printcharfun)
839 Lisp_Object object, printcharfun;
840{ 817{
841 PRINTDECLARE; 818 PRINTDECLARE;
842 819
@@ -871,8 +848,7 @@ of these:
871 848
872If PRINTCHARFUN is omitted, the value of `standard-output' (which see) 849If PRINTCHARFUN is omitted, the value of `standard-output' (which see)
873is used instead. */) 850is used instead. */)
874 (object, printcharfun) 851 (Lisp_Object object, Lisp_Object printcharfun)
875 Lisp_Object object, printcharfun;
876{ 852{
877 PRINTDECLARE; 853 PRINTDECLARE;
878 struct gcpro gcpro1; 854 struct gcpro gcpro1;
@@ -897,8 +873,7 @@ DEFUN ("external-debugging-output", Fexternal_debugging_output, Sexternal_debugg
897 doc: /* Write CHARACTER to stderr. 873 doc: /* Write CHARACTER to stderr.
898You can call print while debugging emacs, and pass it this function 874You can call print while debugging emacs, and pass it this function
899to make it write to the debugging output. */) 875to make it write to the debugging output. */)
900 (character) 876 (Lisp_Object character)
901 Lisp_Object character;
902{ 877{
903 CHECK_NUMBER (character); 878 CHECK_NUMBER (character);
904 putc (XINT (character), stderr); 879 putc (XINT (character), stderr);
@@ -919,8 +894,7 @@ to make it write to the debugging output. */)
919 print_output_debug_flag from being optimized away. */ 894 print_output_debug_flag from being optimized away. */
920 895
921void 896void
922debug_output_compilation_hack (x) 897debug_output_compilation_hack (int x)
923 int x;
924{ 898{
925 print_output_debug_flag = x; 899 print_output_debug_flag = x;
926} 900}
@@ -941,8 +915,7 @@ DEFUN ("redirect-debugging-output", Fredirect_debugging_output, Sredirect_debugg
941If FILE is nil, reset target to the initial stderr stream. 915If FILE is nil, reset target to the initial stderr stream.
942Optional arg APPEND non-nil (interactively, with prefix arg) means 916Optional arg APPEND non-nil (interactively, with prefix arg) means
943append to existing target file. */) 917append to existing target file. */)
944 (file, append) 918 (Lisp_Object file, Lisp_Object append)
945 Lisp_Object file, append;
946{ 919{
947 if (initial_stderr_stream != NULL) 920 if (initial_stderr_stream != NULL)
948 { 921 {
@@ -974,16 +947,14 @@ append to existing target file. */)
974/* This is the interface for debugging printing. */ 947/* This is the interface for debugging printing. */
975 948
976void 949void
977debug_print (arg) 950debug_print (Lisp_Object arg)
978 Lisp_Object arg;
979{ 951{
980 Fprin1 (arg, Qexternal_debugging_output); 952 Fprin1 (arg, Qexternal_debugging_output);
981 fprintf (stderr, "\r\n"); 953 fprintf (stderr, "\r\n");
982} 954}
983 955
984void 956void
985safe_debug_print (arg) 957safe_debug_print (Lisp_Object arg)
986 Lisp_Object arg;
987{ 958{
988 int valid = valid_lisp_object_p (arg); 959 int valid = valid_lisp_object_p (arg);
989 960
@@ -1002,8 +973,7 @@ DEFUN ("error-message-string", Ferror_message_string, Serror_message_string,
1002 doc: /* Convert an error value (ERROR-SYMBOL . DATA) to an error message. 973 doc: /* Convert an error value (ERROR-SYMBOL . DATA) to an error message.
1003See Info anchor `(elisp)Definition of signal' for some details on how this 974See Info anchor `(elisp)Definition of signal' for some details on how this
1004error message is constructed. */) 975error message is constructed. */)
1005 (obj) 976 (Lisp_Object obj)
1006 Lisp_Object obj;
1007{ 977{
1008 struct buffer *old = current_buffer; 978 struct buffer *old = current_buffer;
1009 Lisp_Object value; 979 Lisp_Object value;
@@ -1037,10 +1007,8 @@ error message is constructed. */)
1037 CALLER is the Lisp function inside which the error was signaled. */ 1007 CALLER is the Lisp function inside which the error was signaled. */
1038 1008
1039void 1009void
1040print_error_message (data, stream, context, caller) 1010print_error_message (Lisp_Object data, Lisp_Object stream, const char *context,
1041 Lisp_Object data, stream; 1011 Lisp_Object caller)
1042 char *context;
1043 Lisp_Object caller;
1044{ 1012{
1045 Lisp_Object errname, errmsg, file_error, tail; 1013 Lisp_Object errname, errmsg, file_error, tail;
1046 struct gcpro gcpro1; 1014 struct gcpro gcpro1;
@@ -1055,7 +1023,7 @@ print_error_message (data, stream, context, caller)
1055 { 1023 {
1056 Lisp_Object cname = SYMBOL_NAME (caller); 1024 Lisp_Object cname = SYMBOL_NAME (caller);
1057 char *name = alloca (SBYTES (cname)); 1025 char *name = alloca (SBYTES (cname));
1058 bcopy (SDATA (cname), name, SBYTES (cname)); 1026 memcpy (name, SDATA (cname), SBYTES (cname));
1059 message_dolog (name, SBYTES (cname), 0, 0); 1027 message_dolog (name, SBYTES (cname), 0, 0);
1060 message_dolog (": ", 2, 0, 0); 1028 message_dolog (": ", 2, 0, 0);
1061 } 1029 }
@@ -1125,9 +1093,7 @@ print_error_message (data, stream, context, caller)
1125 */ 1093 */
1126 1094
1127void 1095void
1128float_to_string (buf, data) 1096float_to_string (unsigned char *buf, double data)
1129 unsigned char *buf;
1130 double data;
1131{ 1097{
1132 unsigned char *cp; 1098 unsigned char *cp;
1133 int width; 1099 int width;
@@ -1250,10 +1216,7 @@ float_to_string (buf, data)
1250 1216
1251 1217
1252static void 1218static void
1253print (obj, printcharfun, escapeflag) 1219print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag)
1254 Lisp_Object obj;
1255 register Lisp_Object printcharfun;
1256 int escapeflag;
1257{ 1220{
1258 new_backquote_output = 0; 1221 new_backquote_output = 0;
1259 1222
@@ -1312,8 +1275,7 @@ print (obj, printcharfun, escapeflag)
1312 The status fields of Vprint_number_table mean whether each object appears 1275 The status fields of Vprint_number_table mean whether each object appears
1313 more than once in OBJ: Qnil at the first time, and Qt after that . */ 1276 more than once in OBJ: Qnil at the first time, and Qt after that . */
1314static void 1277static void
1315print_preprocess (obj) 1278print_preprocess (Lisp_Object obj)
1316 Lisp_Object obj;
1317{ 1279{
1318 int i; 1280 int i;
1319 EMACS_INT size; 1281 EMACS_INT size;
@@ -1433,9 +1395,7 @@ print_preprocess (obj)
1433} 1395}
1434 1396
1435static void 1397static void
1436print_preprocess_string (interval, arg) 1398print_preprocess_string (INTERVAL interval, Lisp_Object arg)
1437 INTERVAL interval;
1438 Lisp_Object arg;
1439{ 1399{
1440 print_preprocess (interval->plist); 1400 print_preprocess (interval->plist);
1441} 1401}
@@ -1445,7 +1405,7 @@ print_preprocess_string (interval, arg)
1445Lisp_Object Vprint_charset_text_property; 1405Lisp_Object Vprint_charset_text_property;
1446extern Lisp_Object Qdefault; 1406extern Lisp_Object Qdefault;
1447 1407
1448static void print_check_string_charset_prop (); 1408static void print_check_string_charset_prop (INTERVAL interval, Lisp_Object string);
1449 1409
1450#define PRINT_STRING_NON_CHARSET_FOUND 1 1410#define PRINT_STRING_NON_CHARSET_FOUND 1
1451#define PRINT_STRING_UNSAFE_CHARSET_FOUND 2 1411#define PRINT_STRING_UNSAFE_CHARSET_FOUND 2
@@ -1454,9 +1414,7 @@ static void print_check_string_charset_prop ();
1454static int print_check_string_result; 1414static int print_check_string_result;
1455 1415
1456static void 1416static void
1457print_check_string_charset_prop (interval, string) 1417print_check_string_charset_prop (INTERVAL interval, Lisp_Object string)
1458 INTERVAL interval;
1459 Lisp_Object string;
1460{ 1418{
1461 Lisp_Object val; 1419 Lisp_Object val;
1462 1420
@@ -1503,8 +1461,7 @@ print_check_string_charset_prop (interval, string)
1503static Lisp_Object print_prune_charset_plist; 1461static Lisp_Object print_prune_charset_plist;
1504 1462
1505static Lisp_Object 1463static Lisp_Object
1506print_prune_string_charset (string) 1464print_prune_string_charset (Lisp_Object string)
1507 Lisp_Object string;
1508{ 1465{
1509 print_check_string_result = 0; 1466 print_check_string_result = 0;
1510 traverse_intervals (STRING_INTERVALS (string), 0, 1467 traverse_intervals (STRING_INTERVALS (string), 0,
@@ -1528,10 +1485,7 @@ print_prune_string_charset (string)
1528} 1485}
1529 1486
1530static void 1487static void
1531print_object (obj, printcharfun, escapeflag) 1488print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag)
1532 Lisp_Object obj;
1533 register Lisp_Object printcharfun;
1534 int escapeflag;
1535{ 1489{
1536 char buf[40]; 1490 char buf[40];
1537 1491
@@ -2307,9 +2261,7 @@ print_object (obj, printcharfun, escapeflag)
2307 This is part of printing a string that has text properties. */ 2261 This is part of printing a string that has text properties. */
2308 2262
2309void 2263void
2310print_interval (interval, printcharfun) 2264print_interval (INTERVAL interval, Lisp_Object printcharfun)
2311 INTERVAL interval;
2312 Lisp_Object printcharfun;
2313{ 2265{
2314 if (NILP (interval->plist)) 2266 if (NILP (interval->plist))
2315 return; 2267 return;
@@ -2324,7 +2276,7 @@ print_interval (interval, printcharfun)
2324 2276
2325 2277
2326void 2278void
2327syms_of_print () 2279syms_of_print (void)
2328{ 2280{
2329 Qtemp_buffer_setup_hook = intern_c_string ("temp-buffer-setup-hook"); 2281 Qtemp_buffer_setup_hook = intern_c_string ("temp-buffer-setup-hook");
2330 staticpro (&Qtemp_buffer_setup_hook); 2282 staticpro (&Qtemp_buffer_setup_hook);