Mercurial > emacs
comparison src/lread.c @ 31534:0bfeb94864e2
(Vloads_in_progress): New variable.
(record_load_unwind): New function.
(Fload): Check for recursive loads.
(syms_of_lread): Initialize Vloads_in_progress.
(read_integer, read1): Avoid some compiler warnings.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 11 Sep 2000 12:51:42 +0000 |
parents | 2efc0e152012 |
children | 76cf765a7dad |
comparison
equal
deleted
inserted
replaced
31533:3898245f639a | 31534:0bfeb94864e2 |
---|---|
173 /* Nonzero means inside a new-style backquote | 173 /* Nonzero means inside a new-style backquote |
174 with no surrounding parentheses. | 174 with no surrounding parentheses. |
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, |
181 UNREAD(c) to unread c to be read again. | 187 UNREAD(c) to unread c to be read again. |
182 | 188 |
579 safe_p = 0; | 585 safe_p = 0; |
580 } | 586 } |
581 | 587 |
582 lseek (fd, 0, SEEK_SET); | 588 lseek (fd, 0, SEEK_SET); |
583 return safe_p; | 589 return safe_p; |
590 } | |
591 | |
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; | |
584 } | 601 } |
585 | 602 |
586 | 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\ |
689 handler = Ffind_file_name_handler (found, Qload); | 706 handler = Ffind_file_name_handler (found, Qload); |
690 if (! NILP (handler)) | 707 if (! NILP (handler)) |
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]), |
697 ".elc", 4) | 721 ".elc", 4) |
698 && fd != 0) | 722 && fd != 0) |
735 load_source: | 759 load_source: |
736 | 760 |
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 |
748 #ifdef WINDOWSNT | 775 #ifdef WINDOWSNT |
749 emacs_close (fd); | 776 emacs_close (fd); |
815 message_with_string ("Loading %s (compiled; note, source file is newer)...done", | 842 message_with_string ("Loading %s (compiled; note, source file is newer)...done", |
816 file, 1); | 843 file, 1); |
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 |
823 static Lisp_Object | 851 static Lisp_Object |
824 load_unwind (stream) /* used as unwind-protect function in load */ | 852 load_unwind (stream) /* used as unwind-protect function in load */ |
1645 static Lisp_Object | 1673 static Lisp_Object |
1646 read_integer (readcharfun, radix) | 1674 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; |
1654 else | 1682 else |
1655 { | 1683 { |
1831 while (1) | 1859 while (1) |
1832 { | 1860 { |
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) |
1839 end = read1 (readcharfun, &ch, 0); | 1868 end = read1 (readcharfun, &ch, 0); |
1840 if (ch == 0) | 1869 if (ch == 0) |
3597 | 3626 |
3598 staticpro (&read_objects); | 3627 staticpro (&read_objects); |
3599 read_objects = Qnil; | 3628 read_objects = Qnil; |
3600 staticpro (&seen_list); | 3629 staticpro (&seen_list); |
3601 | 3630 |
3602 } | 3631 Vloads_in_progress = Qnil; |
3632 staticpro (&Vloads_in_progress); | |
3633 } |