diff options
| author | Gerd Moellmann | 2000-09-21 11:15:01 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-09-21 11:15:01 +0000 |
| commit | 550a625e340938c17c00526b0706ccce19aaeaf8 (patch) | |
| tree | 22ade1d3b888fa56a680ab7333d0d78b1a923a6c /src | |
| parent | c29d77c4b63df2f8a7ebbe3737a1d41eae6883be (diff) | |
| download | emacs-550a625e340938c17c00526b0706ccce19aaeaf8.tar.gz emacs-550a625e340938c17c00526b0706ccce19aaeaf8.zip | |
(Vrecursive_load_depth_limit): New variable.
(Fload): Check recursive loads whose recursion depth exceeds
Vrecursive_load_depth_limit.
(syms_of_lread): DERFAR_LISP recursive-load-depth-limit.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/lread.c | 71 |
2 files changed, 52 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ea4ae01fd34..deb65d088d2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2000-09-21 Gerd Moellmann <gerd@gnu.org> | ||
| 2 | |||
| 3 | * lread.c (Vrecursive_load_depth_limit): New variable. | ||
| 4 | (Fload): Check recursive loads whose recursion depth exceeds | ||
| 5 | Vrecursive_load_depth_limit. | ||
| 6 | (syms_of_lread): DERFAR_LISP recursive-load-depth-limit. | ||
| 7 | |||
| 1 | 2000-09-20 Gerd Moellmann <gerd@gnu.org> | 8 | 2000-09-20 Gerd Moellmann <gerd@gnu.org> |
| 2 | 9 | ||
| 3 | * fileio.c (Fread_file_name): Doc fix. | 10 | * fileio.c (Fread_file_name): Doc fix. |
diff --git a/src/lread.c b/src/lread.c index 29eb06c501e..a7b67523316 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -181,6 +181,24 @@ static int new_backquote_flag; | |||
| 181 | 181 | ||
| 182 | static Lisp_Object Vloads_in_progress; | 182 | static Lisp_Object Vloads_in_progress; |
| 183 | 183 | ||
| 184 | /* Limit of the depth of recursive loads. */ | ||
| 185 | |||
| 186 | Lisp_Object Vrecursive_load_depth_limit; | ||
| 187 | |||
| 188 | /* Non-zero means load dangerous compiled Lisp files. */ | ||
| 189 | |||
| 190 | int load_dangerous_libraries; | ||
| 191 | |||
| 192 | /* A regular expression used to detect files compiled with Emacs. */ | ||
| 193 | |||
| 194 | static Lisp_Object Vbytecomp_version_regexp; | ||
| 195 | |||
| 196 | static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object, | ||
| 197 | Lisp_Object (*) (), int, | ||
| 198 | Lisp_Object, Lisp_Object)); | ||
| 199 | static Lisp_Object load_unwind P_ ((Lisp_Object)); | ||
| 200 | static Lisp_Object load_descriptor_unwind P_ ((Lisp_Object)); | ||
| 201 | |||
| 184 | 202 | ||
| 185 | /* Handle unreading and rereading of characters. | 203 | /* Handle unreading and rereading of characters. |
| 186 | Write READCHAR to read a character, | 204 | Write READCHAR to read a character, |
| @@ -537,22 +555,9 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0, | |||
| 537 | XSETINT (val, getc (instream)); | 555 | XSETINT (val, getc (instream)); |
| 538 | return val; | 556 | return val; |
| 539 | } | 557 | } |
| 540 | |||
| 541 | static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object, | ||
| 542 | Lisp_Object (*) (), int, | ||
| 543 | Lisp_Object, Lisp_Object)); | ||
| 544 | static Lisp_Object load_unwind P_ ((Lisp_Object)); | ||
| 545 | static Lisp_Object load_descriptor_unwind P_ ((Lisp_Object)); | ||
| 546 | |||
| 547 | /* Non-zero means load dangerous compiled Lisp files. */ | ||
| 548 | |||
| 549 | int load_dangerous_libraries; | ||
| 550 | |||
| 551 | /* A regular expression used to detect files compiled with Emacs. */ | ||
| 552 | |||
| 553 | static Lisp_Object Vbytecomp_version_regexp; | ||
| 554 | 558 | ||
| 555 | 559 | ||
| 560 | |||
| 556 | /* Value is non-zero if the file asswociated with file descriptor FD | 561 | /* Value is non-zero if the file asswociated with file descriptor FD |
| 557 | is a compiled Lisp file that's safe to load. Only files compiled | 562 | is a compiled Lisp file that's safe to load. Only files compiled |
| 558 | with Emacs are safe to load. Files compiled with XEmacs can lead | 563 | with Emacs are safe to load. Files compiled with XEmacs can lead |
| @@ -708,18 +713,26 @@ Return t if file exists.") | |||
| 708 | return call5 (handler, Qload, found, noerror, nomessage, Qt); | 713 | return call5 (handler, Qload, found, noerror, nomessage, Qt); |
| 709 | } | 714 | } |
| 710 | 715 | ||
| 711 | #if 0 /* This is a good idea, but it doesn't quite work. | 716 | /* Check if we're stuck in a recursive load cycle. |
| 712 | While compiling files, `provide's seem to not be evaluated. | 717 | |
| 713 | Let's come back to this when there's more time. */ | 718 | 2000-09-21: It's not possible to just check for the file loaded |
| 714 | 719 | being a member of Vloads_in_progress. This fails because of the | |
| 715 | /* Check if we're loading this file again while another load | 720 | way the byte compiler currently works; `provide's are not |
| 716 | of the same file is already in progress. */ | 721 | evaluted, see font-lock.el/jit-lock.el as an example. This |
| 717 | if (!NILP (Fmember (found, Vloads_in_progress))) | 722 | leads to a certain amount of ``normal'' recursion. |
| 718 | Fsignal (Qerror, Fcons (build_string ("Recursive load"), | 723 | |
| 719 | Fcons (found, Vloads_in_progress))); | 724 | Also, just loading a file recursively is not always an error in |
| 720 | record_unwind_protect (record_load_unwind, Vloads_in_progress); | 725 | the general case; the second load may do something different. */ |
| 721 | Vloads_in_progress = Fcons (found, Vloads_in_progress); | 726 | if (INTEGERP (Vrecursive_load_depth_limit) |
| 722 | #endif /* 0 */ | 727 | && XINT (Vrecursive_load_depth_limit) > 0) |
| 728 | { | ||
| 729 | Lisp_Object len = Flength (Vloads_in_progress); | ||
| 730 | if (XFASTINT (len) > XFASTINT (Vrecursive_load_depth_limit)) | ||
| 731 | Fsignal (Qerror, Fcons (build_string ("Recursive load suspected"), | ||
| 732 | Fcons (found, Vloads_in_progress))); | ||
| 733 | record_unwind_protect (record_load_unwind, Vloads_in_progress); | ||
| 734 | Vloads_in_progress = Fcons (found, Vloads_in_progress); | ||
| 735 | } | ||
| 723 | 736 | ||
| 724 | /* Load .elc files directly, but not when they are | 737 | /* Load .elc files directly, but not when they are |
| 725 | remote and have no handler! */ | 738 | remote and have no handler! */ |
| @@ -3588,6 +3601,12 @@ to load. See also `load-dangerous-libraries'."); | |||
| 3588 | Vbytecomp_version_regexp | 3601 | Vbytecomp_version_regexp |
| 3589 | = build_string ("^;;;.\\(in Emacs version\\|bytecomp version FSF\\)"); | 3602 | = build_string ("^;;;.\\(in Emacs version\\|bytecomp version FSF\\)"); |
| 3590 | 3603 | ||
| 3604 | DEFVAR_LISP ("recursive-load-depth-limit", &Vrecursive_load_depth_limit, | ||
| 3605 | "Limit for depth of recursive loads.\n\ | ||
| 3606 | Value should be either an integer > 0 specifying the limit, or nil for\n\ | ||
| 3607 | no limit."); | ||
| 3608 | Vrecursive_load_depth_limit = make_number (10); | ||
| 3609 | |||
| 3591 | /* Vsource_directory was initialized in init_lread. */ | 3610 | /* Vsource_directory was initialized in init_lread. */ |
| 3592 | 3611 | ||
| 3593 | load_descriptor_list = Qnil; | 3612 | load_descriptor_list = Qnil; |