comparison src/print.c @ 177:6075d714658b r20-3b15

Import from CVS: tag r20-3b15
author cvs
date Mon, 13 Aug 2007 09:51:16 +0200
parents 8eaf7971accc
children e121b013d1f0
comparison
equal deleted inserted replaced
176:6866abce6aaf 177:6075d714658b
51 Lisp_Object Qexternal_debugging_output; 51 Lisp_Object Qexternal_debugging_output;
52 Lisp_Object Qalternate_debugging_output; 52 Lisp_Object Qalternate_debugging_output;
53 53
54 /* Avoid actual stack overflow in print. */ 54 /* Avoid actual stack overflow in print. */
55 static int print_depth; 55 static int print_depth;
56
57 /* Detect most circularities to print finite output. */
58 #define PRINT_CIRCLE 200
59 Lisp_Object being_printed[PRINT_CIRCLE];
56 60
57 /* Maximum length of list or vector to print in full; noninteger means 61 /* Maximum length of list or vector to print in full; noninteger means
58 effectively infinity */ 62 effectively infinity */
59 63
60 Lisp_Object Vprint_length; 64 Lisp_Object Vprint_length;
899 it creates. This flag should also be user-settable. Perhaps it 903 it creates. This flag should also be user-settable. Perhaps it
900 should be split up into two flags, one for input and one for 904 should be split up into two flags, one for input and one for
901 output. */ 905 output. */
902 #endif 906 #endif
903 907
908 /* Detect circularities and truncate them.
909 No need to offer any alternative--this is better than an error. */
910 if (CONSP (obj) || VECTORP (obj) || COMPILED_FUNCTIONP (obj))
911 {
912 int i;
913 for (i = 0; i < print_depth; i++)
914 if (EQ (obj, being_printed[i]))
915 {
916 sprintf (buf, "#%d", i);
917 write_c_string (buf, printcharfun);
918 return;
919 }
920 }
921
922
923 being_printed[print_depth] = obj;
904 print_depth++; 924 print_depth++;
905 925
906 if (print_depth > 200) 926 if (print_depth > PRINT_CIRCLE)
907 error ("Apparently circular structure being printed"); 927 error ("Apparently circular structure being printed");
908 928
909 switch (XTYPE (obj)) 929 switch (XTYPE (obj))
910 { 930 {
911 case Lisp_Int: 931 case Lisp_Int: