diff options
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/lread.c | 39 |
2 files changed, 46 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 18478bbda9d..c7fc236b495 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2000-09-11 Gerd Moellmann <gerd@gnu.org> | ||
| 2 | |||
| 3 | * lread.c (Vloads_in_progress): New variable. | ||
| 4 | (record_load_unwind): New function. | ||
| 5 | (Fload): Check for recursive loads. | ||
| 6 | (syms_of_lread): Initialize Vloads_in_progress. | ||
| 7 | (read_integer, read1): Avoid some compiler warnings. | ||
| 8 | |||
| 9 | * fns.c (concat, Fsubstring, internal_equal, Fnconc): Avoid some | ||
| 10 | compiler warnings. | ||
| 11 | |||
| 1 | 2000-09-11 Miles Bader <miles@gnu.org> | 12 | 2000-09-11 Miles Bader <miles@gnu.org> |
| 2 | 13 | ||
| 3 | * editfns.c (Fbuffer_string): Doc fix. | 14 | * editfns.c (Fbuffer_string): Doc fix. |
diff --git a/src/lread.c b/src/lread.c index 157ed1d1eec..0788eb85068 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -175,6 +175,12 @@ static file_offset prev_saved_doc_string_position; | |||
| 175 | Fread initializes this to zero, so we need not specbind it | 175 | Fread initializes this to zero, so we need not specbind it |
| 176 | or worry about what happens to it when there is an error. */ | 176 | or worry about what happens to it when there is an error. */ |
| 177 | static int new_backquote_flag; | 177 | static int new_backquote_flag; |
| 178 | |||
| 179 | /* A list of file names for files being loaded in Fload. Used to | ||
| 180 | check for recursive loads. */ | ||
| 181 | |||
| 182 | static Lisp_Object Vloads_in_progress; | ||
| 183 | |||
| 178 | 184 | ||
| 179 | /* Handle unreading and rereading of characters. | 185 | /* Handle unreading and rereading of characters. |
| 180 | Write READCHAR to read a character, | 186 | Write READCHAR to read a character, |
| @@ -584,6 +590,17 @@ safe_to_load_p (fd) | |||
| 584 | } | 590 | } |
| 585 | 591 | ||
| 586 | 592 | ||
| 593 | /* Callback for record_unwind_protect. Restore the old load list OLD, | ||
| 594 | after loading a file successfully. */ | ||
| 595 | |||
| 596 | static Lisp_Object | ||
| 597 | record_load_unwind (old) | ||
| 598 | Lisp_Object old; | ||
| 599 | { | ||
| 600 | return Vloads_in_progress = old; | ||
| 601 | } | ||
| 602 | |||
| 603 | |||
| 587 | DEFUN ("load", Fload, Sload, 1, 5, 0, | 604 | DEFUN ("load", Fload, Sload, 1, 5, 0, |
| 588 | "Execute a file of Lisp code named FILE.\n\ | 605 | "Execute a file of Lisp code named FILE.\n\ |
| 589 | First try FILE with `.elc' appended, then try with `.el',\n\ | 606 | First try FILE with `.elc' appended, then try with `.el',\n\ |
| @@ -691,6 +708,13 @@ Return t if file exists.") | |||
| 691 | return call5 (handler, Qload, found, noerror, nomessage, Qt); | 708 | return call5 (handler, Qload, found, noerror, nomessage, Qt); |
| 692 | } | 709 | } |
| 693 | 710 | ||
| 711 | /* Check if we're loading this file again while another load | ||
| 712 | of the same file is already in progress. */ | ||
| 713 | if (!NILP (Fmember (found, Vloads_in_progress))) | ||
| 714 | error ("Recursive load of file `%s'", XSTRING (file)->data); | ||
| 715 | record_unwind_protect (record_load_unwind, Vloads_in_progress); | ||
| 716 | Vloads_in_progress = Fcons (found, Vloads_in_progress); | ||
| 717 | |||
| 694 | /* Load .elc files directly, but not when they are | 718 | /* Load .elc files directly, but not when they are |
| 695 | remote and have no handler! */ | 719 | remote and have no handler! */ |
| 696 | if (!bcmp (&(XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 4]), | 720 | if (!bcmp (&(XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 4]), |
| @@ -737,11 +761,14 @@ Return t if file exists.") | |||
| 737 | /* We are loading a source file (*.el). */ | 761 | /* We are loading a source file (*.el). */ |
| 738 | if (!NILP (Vload_source_file_function)) | 762 | if (!NILP (Vload_source_file_function)) |
| 739 | { | 763 | { |
| 764 | Lisp_Object val; | ||
| 765 | |||
| 740 | if (fd != 0) | 766 | if (fd != 0) |
| 741 | emacs_close (fd); | 767 | emacs_close (fd); |
| 742 | return call4 (Vload_source_file_function, found, file, | 768 | val = call4 (Vload_source_file_function, found, file, |
| 743 | NILP (noerror) ? Qnil : Qt, | 769 | NILP (noerror) ? Qnil : Qt, |
| 744 | NILP (nomessage) ? Qnil : Qt); | 770 | NILP (nomessage) ? Qnil : Qt); |
| 771 | return unbind_to (count, val); | ||
| 745 | } | 772 | } |
| 746 | } | 773 | } |
| 747 | 774 | ||
| @@ -817,6 +844,7 @@ Return t if file exists.") | |||
| 817 | else /* The typical case; compiled file newer than source file. */ | 844 | else /* The typical case; compiled file newer than source file. */ |
| 818 | message_with_string ("Loading %s...done", file, 1); | 845 | message_with_string ("Loading %s...done", file, 1); |
| 819 | } | 846 | } |
| 847 | |||
| 820 | return Qt; | 848 | return Qt; |
| 821 | } | 849 | } |
| 822 | 850 | ||
| @@ -1647,7 +1675,7 @@ read_integer (readcharfun, radix) | |||
| 1647 | Lisp_Object readcharfun; | 1675 | Lisp_Object readcharfun; |
| 1648 | int radix; | 1676 | int radix; |
| 1649 | { | 1677 | { |
| 1650 | int number, ndigits, invalid_p, c, sign; | 1678 | int number = 0, ndigits = 0, invalid_p, c, sign = 0; |
| 1651 | 1679 | ||
| 1652 | if (radix < 2 || radix > 36) | 1680 | if (radix < 2 || radix > 36) |
| 1653 | invalid_p = 1; | 1681 | invalid_p = 1; |
| @@ -1833,6 +1861,7 @@ read1 (readcharfun, pch, first_in_list) | |||
| 1833 | Lisp_Object beg, end, plist; | 1861 | Lisp_Object beg, end, plist; |
| 1834 | 1862 | ||
| 1835 | beg = read1 (readcharfun, &ch, 0); | 1863 | beg = read1 (readcharfun, &ch, 0); |
| 1864 | end = plist = Qnil; | ||
| 1836 | if (ch == ')') | 1865 | if (ch == ')') |
| 1837 | break; | 1866 | break; |
| 1838 | if (ch == 0) | 1867 | if (ch == 0) |
| @@ -3599,4 +3628,6 @@ to load. See also `load-dangerous-libraries'."); | |||
| 3599 | read_objects = Qnil; | 3628 | read_objects = Qnil; |
| 3600 | staticpro (&seen_list); | 3629 | staticpro (&seen_list); |
| 3601 | 3630 | ||
| 3631 | Vloads_in_progress = Qnil; | ||
| 3632 | staticpro (&Vloads_in_progress); | ||
| 3602 | } | 3633 | } |