comparison src/lread.c @ 41463:078a3890c752

(Fload): Detect recursive load error for more than 3 nestings of the same file. (Vrecursive_load_depth_limit): Variable deleted. (syms_of_lread) <recursive-load-depth-limit>: Variable deleted.
author Richard M. Stallman <rms@gnu.org>
date Sun, 25 Nov 2001 02:13:13 +0000
parents 50b111aed6d5
children 0f4506820432
comparison
equal deleted inserted replaced
41462:e251356bc766 41463:078a3890c752
178 178
179 /* A list of file names for files being loaded in Fload. Used to 179 /* A list of file names for files being loaded in Fload. Used to
180 check for recursive loads. */ 180 check for recursive loads. */
181 181
182 static Lisp_Object Vloads_in_progress; 182 static Lisp_Object Vloads_in_progress;
183
184 /* Limit of the depth of recursive loads. */
185
186 Lisp_Object Vrecursive_load_depth_limit;
187 183
188 /* Non-zero means load dangerous compiled Lisp files. */ 184 /* Non-zero means load dangerous compiled Lisp files. */
189 185
190 int load_dangerous_libraries; 186 int load_dangerous_libraries;
191 187
732 evaluted, see font-lock.el/jit-lock.el as an example. This 728 evaluted, see font-lock.el/jit-lock.el as an example. This
733 leads to a certain amount of ``normal'' recursion. 729 leads to a certain amount of ``normal'' recursion.
734 730
735 Also, just loading a file recursively is not always an error in 731 Also, just loading a file recursively is not always an error in
736 the general case; the second load may do something different. */ 732 the general case; the second load may do something different. */
737 if (INTEGERP (Vrecursive_load_depth_limit) 733 {
738 && XINT (Vrecursive_load_depth_limit) > 0) 734 int count = 0;
739 { 735 Lisp_Object tem;
740 Lisp_Object len = Flength (Vloads_in_progress); 736 for (tem = Vloads_in_progress; CONSP (tem); tem = XCDR (tem))
741 if (XFASTINT (len) > XFASTINT (Vrecursive_load_depth_limit)) 737 if (!NILP (Fequal (found, XCAR (tem))))
742 Fsignal (Qerror, Fcons (build_string ("Recursive load suspected"), 738 count++;
743 Fcons (found, Vloads_in_progress))); 739 if (count > 3)
744 record_unwind_protect (record_load_unwind, Vloads_in_progress); 740 Fsignal (Qerror, Fcons (build_string ("Recursive load"),
745 Vloads_in_progress = Fcons (found, Vloads_in_progress); 741 Fcons (found, Vloads_in_progress)));
746 } 742 record_unwind_protect (record_load_unwind, Vloads_in_progress);
743 Vloads_in_progress = Fcons (found, Vloads_in_progress);
744 }
747 745
748 if (!bcmp (&(XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 4]), 746 if (!bcmp (&(XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 4]),
749 ".elc", 4)) 747 ".elc", 4))
750 /* Load .elc files directly, but not when they are 748 /* Load .elc files directly, but not when they are
751 remote and have no handler! */ 749 remote and have no handler! */
3656 When the regular expression matches, the file is considered to be safe 3654 When the regular expression matches, the file is considered to be safe
3657 to load. See also `load-dangerous-libraries'. */); 3655 to load. See also `load-dangerous-libraries'. */);
3658 Vbytecomp_version_regexp 3656 Vbytecomp_version_regexp
3659 = build_string ("^;;;.\\(in Emacs version\\|bytecomp version FSF\\)"); 3657 = build_string ("^;;;.\\(in Emacs version\\|bytecomp version FSF\\)");
3660 3658
3661 DEFVAR_LISP ("recursive-load-depth-limit", &Vrecursive_load_depth_limit,
3662 doc: /* Limit for depth of recursive loads.
3663 Value should be either an integer > 0 specifying the limit, or nil for
3664 no limit. */);
3665 Vrecursive_load_depth_limit = make_number (50);
3666
3667 /* Vsource_directory was initialized in init_lread. */ 3659 /* Vsource_directory was initialized in init_lread. */
3668 3660
3669 load_descriptor_list = Qnil; 3661 load_descriptor_list = Qnil;
3670 staticpro (&load_descriptor_list); 3662 staticpro (&load_descriptor_list);
3671 3663