comparison src/print.c @ 109126:aec1143e8d85

Convert (most) functions in src to standard C. * src/alloc.c: Convert function definitions to standard C. * src/atimer.c: * src/bidi.c: * src/bytecode.c: * src/callint.c: * src/callproc.c: * src/casefiddle.c: * src/casetab.c: * src/category.c: * src/ccl.c: * src/character.c: * src/charset.c: * src/chartab.c: * src/cmds.c: * src/coding.c: * src/composite.c: * src/data.c: * src/dbusbind.c: * src/dired.c: * src/dispnew.c: * src/doc.c: * src/doprnt.c: * src/ecrt0.c: * src/editfns.c: * src/fileio.c: * src/filelock.c: * src/filemode.c: * src/fns.c: * src/font.c: * src/fontset.c: * src/frame.c: * src/fringe.c: * src/ftfont.c: * src/ftxfont.c: * src/gtkutil.c: * src/indent.c: * src/insdel.c: * src/intervals.c: * src/keymap.c: * src/lread.c: * src/macros.c: * src/marker.c: * src/md5.c: * src/menu.c: * src/minibuf.c: * src/prefix-args.c: * src/print.c: * src/ralloc.c: * src/regex.c: * src/region-cache.c: * src/scroll.c: * src/search.c: * src/sound.c: * src/strftime.c: * src/syntax.c: * src/sysdep.c: * src/termcap.c: * src/terminal.c: * src/terminfo.c: * src/textprop.c: * src/tparam.c: * src/undo.c: * src/unexelf.c: * src/window.c: * src/xfaces.c: * src/xfns.c: * src/xfont.c: * src/xftfont.c: * src/xgselect.c: * src/xmenu.c: * src/xrdb.c: * src/xselect.c: * src/xsettings.c: * src/xsmfns.c: * src/xterm.c: Likewise.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 04 Jul 2010 00:50:25 -0700
parents 2bc9a0c04c87
children efd2c7ec61fe
comparison
equal deleted inserted replaced
109125:12b02558bf51 109126:aec1143e8d85
166 166
167 extern int noninteractive_need_newline; 167 extern int noninteractive_need_newline;
168 168
169 extern int minibuffer_auto_raise; 169 extern int minibuffer_auto_raise;
170 170
171 void print_interval (); 171 void 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. */
174 int print_output_debug_flag = 1; 174 int print_output_debug_flag = 1;
175 175
176 176
285 285
286 /* This is used to restore the saved contents of print_buffer 286 /* This is used to restore the saved contents of print_buffer
287 when there is a recursive call to print. */ 287 when there is a recursive call to print. */
288 288
289 static Lisp_Object 289 static Lisp_Object
290 print_unwind (saved_text) 290 print_unwind (Lisp_Object saved_text)
291 Lisp_Object saved_text;
292 { 291 {
293 bcopy (SDATA (saved_text), print_buffer, SCHARS (saved_text)); 292 bcopy (SDATA (saved_text), print_buffer, SCHARS (saved_text));
294 return Qnil; 293 return Qnil;
295 } 294 }
296 295
299 print_buffer. FUN t means print to echo area or stdout if 298 print_buffer. FUN t means print to echo area or stdout if
300 non-interactive. If FUN is neither nil nor t, call FUN with CH as 299 non-interactive. If FUN is neither nil nor t, call FUN with CH as
301 argument. */ 300 argument. */
302 301
303 static void 302 static void
304 printchar (ch, fun) 303 printchar (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));
310 else 307 else
311 { 308 {
351 348
352 In the case where PRINTCHARFUN is nil, it is safe for PTR to point 349 In the case where PRINTCHARFUN is nil, it is safe for PTR to point
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
355 static void 352 static void
356 strout (ptr, size, size_byte, printcharfun, multibyte) 353 strout (char *ptr, int size, int size_byte, Lisp_Object printcharfun, int multibyte)
357 char *ptr;
358 int size, size_byte;
359 Lisp_Object printcharfun;
360 int multibyte;
361 { 354 {
362 if (size < 0) 355 if (size < 0)
363 size_byte = size = strlen (ptr); 356 size_byte = size = strlen (ptr);
364 357
365 if (NILP (printcharfun)) 358 if (NILP (printcharfun))
438 /* Print the contents of a string STRING using PRINTCHARFUN. 431 /* Print the contents of a string STRING using PRINTCHARFUN.
439 It isn't safe to use strout in many cases, 432 It isn't safe to use strout in many cases,
440 because printing one char can relocate. */ 433 because printing one char can relocate. */
441 434
442 static void 435 static void
443 print_string (string, printcharfun) 436 print_string (Lisp_Object string, Lisp_Object printcharfun)
444 Lisp_Object string;
445 Lisp_Object printcharfun;
446 { 437 {
447 if (EQ (printcharfun, Qt) || NILP (printcharfun)) 438 if (EQ (printcharfun, Qt) || NILP (printcharfun))
448 { 439 {
449 int chars; 440 int chars;
450 441
547 /* Used from outside of print.c to print a block of SIZE 538 /* Used from outside of print.c to print a block of SIZE
548 single-byte chars at DATA on the default output stream. 539 single-byte chars at DATA on the default output stream.
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
551 void 542 void
552 write_string (data, size) 543 write_string (char *data, int size)
553 char *data;
554 int size;
555 { 544 {
556 PRINTDECLARE; 545 PRINTDECLARE;
557 Lisp_Object printcharfun; 546 Lisp_Object printcharfun;
558 547
559 printcharfun = Vstandard_output; 548 printcharfun = Vstandard_output;
566 /* Used from outside of print.c to print a block of SIZE 555 /* Used from outside of print.c to print a block of SIZE
567 single-byte chars at DATA on a specified stream PRINTCHARFUN. 556 single-byte chars at DATA on a specified stream PRINTCHARFUN.
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
570 void 559 void
571 write_string_1 (data, size, printcharfun) 560 write_string_1 (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
578 PRINTPREPARE; 564 PRINTPREPARE;
579 strout (data, size, size, printcharfun, 0); 565 strout (data, size, size, printcharfun, 0);
580 PRINTFINISH; 566 PRINTFINISH;
581 } 567 }
582 568
583 569
584 void 570 void
585 temp_output_buffer_setup (bufname) 571 temp_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;
590 register Lisp_Object buf; 575 register Lisp_Object buf;
591 576
614 599
615 specbind (Qstandard_output, buf); 600 specbind (Qstandard_output, buf);
616 } 601 }
617 602
618 Lisp_Object 603 Lisp_Object
619 internal_with_output_to_temp_buffer (bufname, function, args) 604 internal_with_output_to_temp_buffer (const char *bufname, Lisp_Object (*function) (Lisp_Object), Lisp_Object args)
620 const char *bufname;
621 Lisp_Object (*function) (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;
626 struct gcpro gcpro1; 608 struct gcpro gcpro1;
627 609
693 675
694 return unbind_to (count, val); 676 return unbind_to (count, val);
695 } 677 }
696 678
697 679
698 static void print (); 680 static void print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag);
699 static void print_preprocess (); 681 static void print_preprocess (Lisp_Object obj);
700 static void print_preprocess_string (); 682 static void print_preprocess_string (INTERVAL interval, Lisp_Object arg);
701 static void print_object (); 683 static void print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag);
702 684
703 DEFUN ("terpri", Fterpri, Sterpri, 0, 1, 0, 685 DEFUN ("terpri", Fterpri, Sterpri, 0, 1, 0,
704 doc: /* Output a newline to stream PRINTCHARFUN. 686 doc: /* Output a newline to stream PRINTCHARFUN.
705 If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used. */) 687 If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used. */)
706 (printcharfun) 688 (printcharfun)
917 899
918 /* This function is never called. Its purpose is to prevent 900 /* This function is never called. Its purpose is to prevent
919 print_output_debug_flag from being optimized away. */ 901 print_output_debug_flag from being optimized away. */
920 902
921 void 903 void
922 debug_output_compilation_hack (x) 904 debug_output_compilation_hack (int x)
923 int x;
924 { 905 {
925 print_output_debug_flag = x; 906 print_output_debug_flag = x;
926 } 907 }
927 908
928 #if defined (GNU_LINUX) 909 #if defined (GNU_LINUX)
972 953
973 954
974 /* This is the interface for debugging printing. */ 955 /* This is the interface for debugging printing. */
975 956
976 void 957 void
977 debug_print (arg) 958 debug_print (Lisp_Object arg)
978 Lisp_Object arg;
979 { 959 {
980 Fprin1 (arg, Qexternal_debugging_output); 960 Fprin1 (arg, Qexternal_debugging_output);
981 fprintf (stderr, "\r\n"); 961 fprintf (stderr, "\r\n");
982 } 962 }
983 963
984 void 964 void
985 safe_debug_print (arg) 965 safe_debug_print (Lisp_Object arg)
986 Lisp_Object arg;
987 { 966 {
988 int valid = valid_lisp_object_p (arg); 967 int valid = valid_lisp_object_p (arg);
989 968
990 if (valid > 0) 969 if (valid > 0)
991 debug_print (arg); 970 debug_print (arg);
1035 STREAM (suitable for the print functions). 1014 STREAM (suitable for the print functions).
1036 CONTEXT is a C string describing the context of the error. 1015 CONTEXT is a C string describing the context of the error.
1037 CALLER is the Lisp function inside which the error was signaled. */ 1016 CALLER is the Lisp function inside which the error was signaled. */
1038 1017
1039 void 1018 void
1040 print_error_message (data, stream, context, caller) 1019 print_error_message (Lisp_Object data, Lisp_Object stream, char *context, Lisp_Object caller)
1041 Lisp_Object data, stream;
1042 char *context;
1043 Lisp_Object caller;
1044 { 1020 {
1045 Lisp_Object errname, errmsg, file_error, tail; 1021 Lisp_Object errname, errmsg, file_error, tail;
1046 struct gcpro gcpro1; 1022 struct gcpro gcpro1;
1047 int i; 1023 int i;
1048 1024
1123 * re-writing _doprnt to be more sane)? 1099 * re-writing _doprnt to be more sane)?
1124 * -wsr 1100 * -wsr
1125 */ 1101 */
1126 1102
1127 void 1103 void
1128 float_to_string (buf, data) 1104 float_to_string (unsigned char *buf, double data)
1129 unsigned char *buf;
1130 double data;
1131 { 1105 {
1132 unsigned char *cp; 1106 unsigned char *cp;
1133 int width; 1107 int width;
1134 1108
1135 /* Check for plus infinity in a way that won't lose 1109 /* Check for plus infinity in a way that won't lose
1248 } 1222 }
1249 } 1223 }
1250 1224
1251 1225
1252 static void 1226 static void
1253 print (obj, printcharfun, escapeflag) 1227 print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag)
1254 Lisp_Object obj;
1255 register Lisp_Object printcharfun;
1256 int escapeflag;
1257 { 1228 {
1258 new_backquote_output = 0; 1229 new_backquote_output = 0;
1259 1230
1260 /* Reset print_number_index and Vprint_number_table only when 1231 /* Reset print_number_index and Vprint_number_table only when
1261 the variable Vprint_continuous_numbering is nil. Otherwise, 1232 the variable Vprint_continuous_numbering is nil. Otherwise,
1310 string (its text properties will be traced), or a symbol that has 1281 string (its text properties will be traced), or a symbol that has
1311 no obarray (this is for the print-gensym feature). 1282 no obarray (this is for the print-gensym feature).
1312 The status fields of Vprint_number_table mean whether each object appears 1283 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 . */ 1284 more than once in OBJ: Qnil at the first time, and Qt after that . */
1314 static void 1285 static void
1315 print_preprocess (obj) 1286 print_preprocess (Lisp_Object obj)
1316 Lisp_Object obj;
1317 { 1287 {
1318 int i; 1288 int i;
1319 EMACS_INT size; 1289 EMACS_INT size;
1320 int loop_count = 0; 1290 int loop_count = 0;
1321 Lisp_Object halftail; 1291 Lisp_Object halftail;
1431 } 1401 }
1432 print_depth--; 1402 print_depth--;
1433 } 1403 }
1434 1404
1435 static void 1405 static void
1436 print_preprocess_string (interval, arg) 1406 print_preprocess_string (INTERVAL interval, Lisp_Object arg)
1437 INTERVAL interval;
1438 Lisp_Object arg;
1439 { 1407 {
1440 print_preprocess (interval->plist); 1408 print_preprocess (interval->plist);
1441 } 1409 }
1442 1410
1443 /* A flag to control printing of `charset' text property. 1411 /* A flag to control printing of `charset' text property.
1444 The default value is Qdefault. */ 1412 The default value is Qdefault. */
1445 Lisp_Object Vprint_charset_text_property; 1413 Lisp_Object Vprint_charset_text_property;
1446 extern Lisp_Object Qdefault; 1414 extern Lisp_Object Qdefault;
1447 1415
1448 static void print_check_string_charset_prop (); 1416 static void print_check_string_charset_prop (INTERVAL interval, Lisp_Object string);
1449 1417
1450 #define PRINT_STRING_NON_CHARSET_FOUND 1 1418 #define PRINT_STRING_NON_CHARSET_FOUND 1
1451 #define PRINT_STRING_UNSAFE_CHARSET_FOUND 2 1419 #define PRINT_STRING_UNSAFE_CHARSET_FOUND 2
1452 1420
1453 /* Bitwize or of the abobe macros. */ 1421 /* Bitwize or of the abobe macros. */
1454 static int print_check_string_result; 1422 static int print_check_string_result;
1455 1423
1456 static void 1424 static void
1457 print_check_string_charset_prop (interval, string) 1425 print_check_string_charset_prop (INTERVAL interval, Lisp_Object string)
1458 INTERVAL interval;
1459 Lisp_Object string;
1460 { 1426 {
1461 Lisp_Object val; 1427 Lisp_Object val;
1462 1428
1463 if (NILP (interval->plist) 1429 if (NILP (interval->plist)
1464 || (print_check_string_result == (PRINT_STRING_NON_CHARSET_FOUND 1430 || (print_check_string_result == (PRINT_STRING_NON_CHARSET_FOUND
1501 1467
1502 /* The value is (charset . nil). */ 1468 /* The value is (charset . nil). */
1503 static Lisp_Object print_prune_charset_plist; 1469 static Lisp_Object print_prune_charset_plist;
1504 1470
1505 static Lisp_Object 1471 static Lisp_Object
1506 print_prune_string_charset (string) 1472 print_prune_string_charset (Lisp_Object string)
1507 Lisp_Object string;
1508 { 1473 {
1509 print_check_string_result = 0; 1474 print_check_string_result = 0;
1510 traverse_intervals (STRING_INTERVALS (string), 0, 1475 traverse_intervals (STRING_INTERVALS (string), 0,
1511 print_check_string_charset_prop, string); 1476 print_check_string_charset_prop, string);
1512 if (! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND)) 1477 if (! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND))
1526 } 1491 }
1527 return string; 1492 return string;
1528 } 1493 }
1529 1494
1530 static void 1495 static void
1531 print_object (obj, printcharfun, escapeflag) 1496 print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag)
1532 Lisp_Object obj;
1533 register Lisp_Object printcharfun;
1534 int escapeflag;
1535 { 1497 {
1536 char buf[40]; 1498 char buf[40];
1537 1499
1538 QUIT; 1500 QUIT;
1539 1501
2305 2267
2306 /* Print a description of INTERVAL using PRINTCHARFUN. 2268 /* Print a description of INTERVAL using PRINTCHARFUN.
2307 This is part of printing a string that has text properties. */ 2269 This is part of printing a string that has text properties. */
2308 2270
2309 void 2271 void
2310 print_interval (interval, printcharfun) 2272 print_interval (INTERVAL interval, Lisp_Object printcharfun)
2311 INTERVAL interval;
2312 Lisp_Object printcharfun;
2313 { 2273 {
2314 if (NILP (interval->plist)) 2274 if (NILP (interval->plist))
2315 return; 2275 return;
2316 PRINTCHAR (' '); 2276 PRINTCHAR (' ');
2317 print_object (make_number (interval->position), printcharfun, 1); 2277 print_object (make_number (interval->position), printcharfun, 1);
2322 print_object (interval->plist, printcharfun, 1); 2282 print_object (interval->plist, printcharfun, 1);
2323 } 2283 }
2324 2284
2325 2285
2326 void 2286 void
2327 syms_of_print () 2287 syms_of_print (void)
2328 { 2288 {
2329 Qtemp_buffer_setup_hook = intern_c_string ("temp-buffer-setup-hook"); 2289 Qtemp_buffer_setup_hook = intern_c_string ("temp-buffer-setup-hook");
2330 staticpro (&Qtemp_buffer_setup_hook); 2290 staticpro (&Qtemp_buffer_setup_hook);
2331 2291
2332 DEFVAR_LISP ("standard-output", &Vstandard_output, 2292 DEFVAR_LISP ("standard-output", &Vstandard_output,