aboutsummaryrefslogtreecommitdiffstats
path: root/src/lread.c
diff options
context:
space:
mode:
authorRichard M. Stallman2005-10-21 16:54:13 +0000
committerRichard M. Stallman2005-10-21 16:54:13 +0000
commit0fc213e97e73856593019fafdaebdf6c121e6e44 (patch)
tree9c9bc867eff93102e3db8c8c03095c6c4368f16a /src/lread.c
parent2ac050ce59e0a36a0a6796017d39d2e115c1a4ce (diff)
downloademacs-0fc213e97e73856593019fafdaebdf6c121e6e44.tar.gz
emacs-0fc213e97e73856593019fafdaebdf6c121e6e44.zip
(Fload): Simplify gcpro structure.
Gcpro FOUND as well as FILE, but not EFOUND. Unless preloading, record FOUND instead of FILE in Vload_history. Rename repeat local FILE to MSG_FILE. (syms_of_lread) <load-history>: Doc fix.
Diffstat (limited to 'src/lread.c')
-rw-r--r--src/lread.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/lread.c b/src/lread.c
index bbe421c0eb5..86ceb8314a4 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -669,6 +669,11 @@ If optional fourth arg NOSUFFIX is non-nil, don't try adding
669If optional fifth arg MUST-SUFFIX is non-nil, insist on 669If optional fifth arg MUST-SUFFIX is non-nil, insist on
670 the suffix `.elc' or `.el'; don't accept just FILE unless 670 the suffix `.elc' or `.el'; don't accept just FILE unless
671 it ends in one of those suffixes or includes a directory name. 671 it ends in one of those suffixes or includes a directory name.
672
673Loading a file records its definitions, and its `provide' and
674`require' calls, in an element of `load-history' whose
675car is the file name loaded. See `load-history'.
676
672Return t if file exists. */) 677Return t if file exists. */)
673 (file, noerror, nomessage, nosuffix, must_suffix) 678 (file, noerror, nomessage, nosuffix, must_suffix)
674 Lisp_Object file, noerror, nomessage, nosuffix, must_suffix; 679 Lisp_Object file, noerror, nomessage, nosuffix, must_suffix;
@@ -677,7 +682,7 @@ Return t if file exists. */)
677 register int fd = -1; 682 register int fd = -1;
678 int count = SPECPDL_INDEX (); 683 int count = SPECPDL_INDEX ();
679 Lisp_Object temp; 684 Lisp_Object temp;
680 struct gcpro gcpro1; 685 struct gcpro gcpro1, gcpro2;
681 Lisp_Object found, efound; 686 Lisp_Object found, efound;
682 /* 1 means we printed the ".el is newer" message. */ 687 /* 1 means we printed the ".el is newer" message. */
683 int newer = 0; 688 int newer = 0;
@@ -724,7 +729,8 @@ Return t if file exists. */)
724 int size = SBYTES (file); 729 int size = SBYTES (file);
725 Lisp_Object tmp[2]; 730 Lisp_Object tmp[2];
726 731
727 GCPRO1 (file); 732 found = Qnil;
733 GCPRO2 (file, found);
728 734
729 if (! NILP (must_suffix)) 735 if (! NILP (must_suffix))
730 { 736 {
@@ -811,6 +817,8 @@ Return t if file exists. */)
811 struct stat s1, s2; 817 struct stat s1, s2;
812 int result; 818 int result;
813 819
820 GCPRO2 (file, found);
821
814 if (!safe_to_load_p (fd)) 822 if (!safe_to_load_p (fd))
815 { 823 {
816 safe_p = 0; 824 safe_p = 0;
@@ -827,7 +835,6 @@ Return t if file exists. */)
827 835
828 compiled = 1; 836 compiled = 1;
829 837
830 GCPRO1 (efound);
831 efound = ENCODE_FILE (found); 838 efound = ENCODE_FILE (found);
832 839
833#ifdef DOS_NT 840#ifdef DOS_NT
@@ -837,7 +844,6 @@ Return t if file exists. */)
837 SSET (efound, SBYTES (efound) - 1, 0); 844 SSET (efound, SBYTES (efound) - 1, 0);
838 result = stat ((char *)SDATA (efound), &s2); 845 result = stat ((char *)SDATA (efound), &s2);
839 SSET (efound, SBYTES (efound) - 1, 'c'); 846 SSET (efound, SBYTES (efound) - 1, 'c');
840 UNGCPRO;
841 847
842 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) 848 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
843 { 849 {
@@ -847,12 +853,13 @@ Return t if file exists. */)
847 /* If we won't print another message, mention this anyway. */ 853 /* If we won't print another message, mention this anyway. */
848 if (!NILP (nomessage)) 854 if (!NILP (nomessage))
849 { 855 {
850 Lisp_Object file; 856 Lisp_Object msg_file;
851 file = Fsubstring (found, make_number (0), make_number (-1)); 857 msg_file = Fsubstring (found, make_number (0), make_number (-1));
852 message_with_string ("Source file `%s' newer than byte-compiled file", 858 message_with_string ("Source file `%s' newer than byte-compiled file",
853 file, 1); 859 msg_file, 1);
854 } 860 }
855 } 861 }
862 UNGCPRO;
856 } 863 }
857 } 864 }
858 else 865 else
@@ -871,12 +878,12 @@ Return t if file exists. */)
871 } 878 }
872 } 879 }
873 880
881 GCPRO2 (file, found);
882
874#ifdef WINDOWSNT 883#ifdef WINDOWSNT
875 emacs_close (fd); 884 emacs_close (fd);
876 GCPRO1 (efound);
877 efound = ENCODE_FILE (found); 885 efound = ENCODE_FILE (found);
878 stream = fopen ((char *) SDATA (efound), fmode); 886 stream = fopen ((char *) SDATA (efound), fmode);
879 UNGCPRO;
880#else /* not WINDOWSNT */ 887#else /* not WINDOWSNT */
881 stream = fdopen (fd, fmode); 888 stream = fdopen (fd, fmode);
882#endif /* not WINDOWSNT */ 889#endif /* not WINDOWSNT */
@@ -903,7 +910,6 @@ Return t if file exists. */)
903 message_with_string ("Loading %s...", file, 1); 910 message_with_string ("Loading %s...", file, 1);
904 } 911 }
905 912
906 GCPRO1 (file);
907 record_unwind_protect (load_unwind, make_save_value (stream, 0)); 913 record_unwind_protect (load_unwind, make_save_value (stream, 0));
908 record_unwind_protect (load_descriptor_unwind, load_descriptor_list); 914 record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
909 specbind (Qload_file_name, found); 915 specbind (Qload_file_name, found);
@@ -911,8 +917,8 @@ Return t if file exists. */)
911 load_descriptor_list 917 load_descriptor_list
912 = Fcons (make_number (fileno (stream)), load_descriptor_list); 918 = Fcons (make_number (fileno (stream)), load_descriptor_list);
913 load_in_progress++; 919 load_in_progress++;
914 readevalloop (Qget_file_char, stream, file, Feval, 920 readevalloop (Qget_file_char, stream, (! NILP (Vpurify_flag) ? file : found),
915 0, Qnil, Qnil, Qnil, Qnil); 921 Feval, 0, Qnil, Qnil, Qnil, Qnil);
916 unbind_to (count, Qnil); 922 unbind_to (count, Qnil);
917 923
918 /* Run any load-hooks for this file. */ 924 /* Run any load-hooks for this file. */
@@ -3879,7 +3885,7 @@ when the corresponding call to `provide' is made. */);
3879 Vafter_load_alist = Qnil; 3885 Vafter_load_alist = Qnil;
3880 3886
3881 DEFVAR_LISP ("load-history", &Vload_history, 3887 DEFVAR_LISP ("load-history", &Vload_history,
3882 doc: /* Alist mapping source file names to symbols and features. 3888 doc: /* Alist mapping file names to symbols and features.
3883Each alist element is a list that starts with a file name, 3889Each alist element is a list that starts with a file name,
3884except for one element (optional) that starts with nil and describes 3890except for one element (optional) that starts with nil and describes
3885definitions evaluated from buffers not visiting files. 3891definitions evaluated from buffers not visiting files.
@@ -3888,7 +3894,10 @@ and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)',
3888`(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'. 3894`(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'.
3889An element `(t . SYMBOL)' precedes an entry `(defun . FUNCTION)', 3895An element `(t . SYMBOL)' precedes an entry `(defun . FUNCTION)',
3890and means that SYMBOL was an autoload before this file redefined it 3896and means that SYMBOL was an autoload before this file redefined it
3891as a function. */); 3897as a function.
3898
3899For a preloaded file, the file name recorded is relative to the main Lisp
3900directory. These names are converted to absolute by `file-loadhist-lookup'. */);
3892 Vload_history = Qnil; 3901 Vload_history = Qnil;
3893 3902
3894 DEFVAR_LISP ("load-file-name", &Vload_file_name, 3903 DEFVAR_LISP ("load-file-name", &Vload_file_name,