Commit 0fc213e9 authored by Richard M. Stallman's avatar Richard M. Stallman

(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.
parent 2ac050ce
...@@ -669,6 +669,11 @@ If optional fourth arg NOSUFFIX is non-nil, don't try adding ...@@ -669,6 +669,11 @@ If optional fourth arg NOSUFFIX is non-nil, don't try adding
If optional fifth arg MUST-SUFFIX is non-nil, insist on If optional fifth arg MUST-SUFFIX is non-nil, insist on
the suffix `.elc' or `.el'; don't accept just FILE unless the suffix `.elc' or `.el'; don't accept just FILE unless
it ends in one of those suffixes or includes a directory name. it ends in one of those suffixes or includes a directory name.
Loading a file records its definitions, and its `provide' and
`require' calls, in an element of `load-history' whose
car is the file name loaded. See `load-history'.
Return t if file exists. */) Return t if file exists. */)
(file, noerror, nomessage, nosuffix, must_suffix) (file, noerror, nomessage, nosuffix, must_suffix)
Lisp_Object file, noerror, nomessage, nosuffix, must_suffix; Lisp_Object file, noerror, nomessage, nosuffix, must_suffix;
...@@ -677,7 +682,7 @@ Return t if file exists. */) ...@@ -677,7 +682,7 @@ Return t if file exists. */)
register int fd = -1; register int fd = -1;
int count = SPECPDL_INDEX (); int count = SPECPDL_INDEX ();
Lisp_Object temp; Lisp_Object temp;
struct gcpro gcpro1; struct gcpro gcpro1, gcpro2;
Lisp_Object found, efound; Lisp_Object found, efound;
/* 1 means we printed the ".el is newer" message. */ /* 1 means we printed the ".el is newer" message. */
int newer = 0; int newer = 0;
...@@ -724,7 +729,8 @@ Return t if file exists. */) ...@@ -724,7 +729,8 @@ Return t if file exists. */)
int size = SBYTES (file); int size = SBYTES (file);
Lisp_Object tmp[2]; Lisp_Object tmp[2];
GCPRO1 (file); found = Qnil;
GCPRO2 (file, found);
if (! NILP (must_suffix)) if (! NILP (must_suffix))
{ {
...@@ -811,6 +817,8 @@ Return t if file exists. */) ...@@ -811,6 +817,8 @@ Return t if file exists. */)
struct stat s1, s2; struct stat s1, s2;
int result; int result;
GCPRO2 (file, found);
if (!safe_to_load_p (fd)) if (!safe_to_load_p (fd))
{ {
safe_p = 0; safe_p = 0;
...@@ -827,7 +835,6 @@ Return t if file exists. */) ...@@ -827,7 +835,6 @@ Return t if file exists. */)
compiled = 1; compiled = 1;
GCPRO1 (efound);
efound = ENCODE_FILE (found); efound = ENCODE_FILE (found);
#ifdef DOS_NT #ifdef DOS_NT
...@@ -837,7 +844,6 @@ Return t if file exists. */) ...@@ -837,7 +844,6 @@ Return t if file exists. */)
SSET (efound, SBYTES (efound) - 1, 0); SSET (efound, SBYTES (efound) - 1, 0);
result = stat ((char *)SDATA (efound), &s2); result = stat ((char *)SDATA (efound), &s2);
SSET (efound, SBYTES (efound) - 1, 'c'); SSET (efound, SBYTES (efound) - 1, 'c');
UNGCPRO;
if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
{ {
...@@ -847,12 +853,13 @@ Return t if file exists. */) ...@@ -847,12 +853,13 @@ Return t if file exists. */)
/* If we won't print another message, mention this anyway. */ /* If we won't print another message, mention this anyway. */
if (!NILP (nomessage)) if (!NILP (nomessage))
{ {
Lisp_Object file; Lisp_Object msg_file;
file = Fsubstring (found, make_number (0), make_number (-1)); msg_file = Fsubstring (found, make_number (0), make_number (-1));
message_with_string ("Source file `%s' newer than byte-compiled file", message_with_string ("Source file `%s' newer than byte-compiled file",
file, 1); msg_file, 1);
} }
} }
UNGCPRO;
} }
} }
else else
...@@ -871,12 +878,12 @@ Return t if file exists. */) ...@@ -871,12 +878,12 @@ Return t if file exists. */)
} }
} }
GCPRO2 (file, found);
#ifdef WINDOWSNT #ifdef WINDOWSNT
emacs_close (fd); emacs_close (fd);
GCPRO1 (efound);
efound = ENCODE_FILE (found); efound = ENCODE_FILE (found);
stream = fopen ((char *) SDATA (efound), fmode); stream = fopen ((char *) SDATA (efound), fmode);
UNGCPRO;
#else /* not WINDOWSNT */ #else /* not WINDOWSNT */
stream = fdopen (fd, fmode); stream = fdopen (fd, fmode);
#endif /* not WINDOWSNT */ #endif /* not WINDOWSNT */
...@@ -903,7 +910,6 @@ Return t if file exists. */) ...@@ -903,7 +910,6 @@ Return t if file exists. */)
message_with_string ("Loading %s...", file, 1); message_with_string ("Loading %s...", file, 1);
} }
GCPRO1 (file);
record_unwind_protect (load_unwind, make_save_value (stream, 0)); record_unwind_protect (load_unwind, make_save_value (stream, 0));
record_unwind_protect (load_descriptor_unwind, load_descriptor_list); record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
specbind (Qload_file_name, found); specbind (Qload_file_name, found);
...@@ -911,8 +917,8 @@ Return t if file exists. */) ...@@ -911,8 +917,8 @@ Return t if file exists. */)
load_descriptor_list load_descriptor_list
= Fcons (make_number (fileno (stream)), load_descriptor_list); = Fcons (make_number (fileno (stream)), load_descriptor_list);
load_in_progress++; load_in_progress++;
readevalloop (Qget_file_char, stream, file, Feval, readevalloop (Qget_file_char, stream, (! NILP (Vpurify_flag) ? file : found),
0, Qnil, Qnil, Qnil, Qnil); Feval, 0, Qnil, Qnil, Qnil, Qnil);
unbind_to (count, Qnil); unbind_to (count, Qnil);
/* Run any load-hooks for this file. */ /* Run any load-hooks for this file. */
...@@ -3879,7 +3885,7 @@ when the corresponding call to `provide' is made. */); ...@@ -3879,7 +3885,7 @@ when the corresponding call to `provide' is made. */);
Vafter_load_alist = Qnil; Vafter_load_alist = Qnil;
DEFVAR_LISP ("load-history", &Vload_history, DEFVAR_LISP ("load-history", &Vload_history,
doc: /* Alist mapping source file names to symbols and features. doc: /* Alist mapping file names to symbols and features.
Each alist element is a list that starts with a file name, Each alist element is a list that starts with a file name,
except for one element (optional) that starts with nil and describes except for one element (optional) that starts with nil and describes
definitions evaluated from buffers not visiting files. definitions evaluated from buffers not visiting files.
...@@ -3888,7 +3894,10 @@ and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)', ...@@ -3888,7 +3894,10 @@ and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)',
`(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'. `(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'.
An element `(t . SYMBOL)' precedes an entry `(defun . FUNCTION)', An element `(t . SYMBOL)' precedes an entry `(defun . FUNCTION)',
and means that SYMBOL was an autoload before this file redefined it and means that SYMBOL was an autoload before this file redefined it
as a function. */); as a function.
For a preloaded file, the file name recorded is relative to the main Lisp
directory. These names are converted to absolute by `file-loadhist-lookup'. */);
Vload_history = Qnil; Vload_history = Qnil;
DEFVAR_LISP ("load-file-name", &Vload_file_name, DEFVAR_LISP ("load-file-name", &Vload_file_name,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment