diff options
| author | Richard M. Stallman | 1991-08-10 20:14:03 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1991-08-10 20:14:03 +0000 |
| commit | ec838c39240761f3f283e89195ae39c402f3e89d (patch) | |
| tree | 41961c0b17768966f062c2d4ba69847a60c6e863 /src | |
| parent | a91990b8e912380e46e8dd6ba768294a0f6d4e2d (diff) | |
| download | emacs-ec838c39240761f3f283e89195ae39c402f3e89d.tar.gz emacs-ec838c39240761f3f283e89195ae39c402f3e89d.zip | |
*** empty log message ***
Diffstat (limited to 'src')
| -rw-r--r-- | src/print.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/print.c b/src/print.c index 3ef76747a91..7a2beb0beda 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -41,6 +41,10 @@ Lisp_Object Vfloat_output_format, Qfloat_output_format; | |||
| 41 | /* Avoid actual stack overflow in print. */ | 41 | /* Avoid actual stack overflow in print. */ |
| 42 | int print_depth; | 42 | int print_depth; |
| 43 | 43 | ||
| 44 | /* Detect most circularities to print finite output. */ | ||
| 45 | #define PRINT_CIRCLE 200 | ||
| 46 | Lisp_Object being_printed[PRINT_CIRCLE]; | ||
| 47 | |||
| 44 | /* Maximum length of list to print in full; noninteger means | 48 | /* Maximum length of list to print in full; noninteger means |
| 45 | effectively infinity */ | 49 | effectively infinity */ |
| 46 | 50 | ||
| @@ -651,9 +655,27 @@ print (obj, printcharfun, escapeflag) | |||
| 651 | 655 | ||
| 652 | QUIT; | 656 | QUIT; |
| 653 | 657 | ||
| 658 | #if 1 /* I'm not sure this is really worth doing. */ | ||
| 659 | /* Detect circularities and truncate them. | ||
| 660 | No need to offer any alternative--this is better than an error. */ | ||
| 661 | if (XTYPE (obj) == Lisp_Cons || XTYPE (obj) == Lisp_Vector | ||
| 662 | || XTYPE (obj) == Lisp_Compiled) | ||
| 663 | { | ||
| 664 | int i; | ||
| 665 | for (i = 0; i < print_depth; i++) | ||
| 666 | if (EQ (obj, being_printed[i])) | ||
| 667 | { | ||
| 668 | sprintf (buf, "#%d", i); | ||
| 669 | strout (buf, -1, printcharfun); | ||
| 670 | return; | ||
| 671 | } | ||
| 672 | } | ||
| 673 | #endif | ||
| 674 | |||
| 675 | being_printed[print_depth] = obj; | ||
| 654 | print_depth++; | 676 | print_depth++; |
| 655 | 677 | ||
| 656 | if (print_depth > 200) | 678 | if (print_depth > PRINT_CIRCLE) |
| 657 | error ("Apparently circular structure being printed"); | 679 | error ("Apparently circular structure being printed"); |
| 658 | #ifdef MAX_PRINT_CHARS | 680 | #ifdef MAX_PRINT_CHARS |
| 659 | if (max_print && print_chars > max_print) | 681 | if (max_print && print_chars > max_print) |
| @@ -783,6 +805,9 @@ print (obj, printcharfun, escapeflag) | |||
| 783 | 805 | ||
| 784 | if (XTYPE (Vprint_length) == Lisp_Int) | 806 | if (XTYPE (Vprint_length) == Lisp_Int) |
| 785 | max = XINT (Vprint_length); | 807 | max = XINT (Vprint_length); |
| 808 | /* Could recognize circularities in cdrs here, | ||
| 809 | but that would make printing of long lists quadratic. | ||
| 810 | It's not worth doing. */ | ||
| 786 | while (CONSP (obj)) | 811 | while (CONSP (obj)) |
| 787 | { | 812 | { |
| 788 | if (i++) | 813 | if (i++) |