Fread initializes this to zero, so we need not specbind it
or worry about what happens to it when there is an error. */
static int new_backquote_flag;
+
+/* A list of file names for files being loaded in Fload. Used to
+ check for recursive loads. */
+
+static Lisp_Object Vloads_in_progress;
+
\f
/* Handle unreading and rereading of characters.
Write READCHAR to read a character,
}
+/* Callback for record_unwind_protect. Restore the old load list OLD,
+ after loading a file successfully. */
+
+static Lisp_Object
+record_load_unwind (old)
+ Lisp_Object old;
+{
+ return Vloads_in_progress = old;
+}
+
+
DEFUN ("load", Fload, Sload, 1, 5, 0,
"Execute a file of Lisp code named FILE.\n\
First try FILE with `.elc' appended, then try with `.el',\n\
return call5 (handler, Qload, found, noerror, nomessage, Qt);
}
+ /* Check if we're loading this file again while another load
+ of the same file is already in progress. */
+ if (!NILP (Fmember (found, Vloads_in_progress)))
+ error ("Recursive load of file `%s'", XSTRING (file)->data);
+ record_unwind_protect (record_load_unwind, Vloads_in_progress);
+ Vloads_in_progress = Fcons (found, Vloads_in_progress);
+
/* Load .elc files directly, but not when they are
remote and have no handler! */
if (!bcmp (&(XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 4]),
/* We are loading a source file (*.el). */
if (!NILP (Vload_source_file_function))
{
+ Lisp_Object val;
+
if (fd != 0)
emacs_close (fd);
- return call4 (Vload_source_file_function, found, file,
- NILP (noerror) ? Qnil : Qt,
- NILP (nomessage) ? Qnil : Qt);
+ val = call4 (Vload_source_file_function, found, file,
+ NILP (noerror) ? Qnil : Qt,
+ NILP (nomessage) ? Qnil : Qt);
+ return unbind_to (count, val);
}
}
else /* The typical case; compiled file newer than source file. */
message_with_string ("Loading %s...done", file, 1);
}
+
return Qt;
}
Lisp_Object readcharfun;
int radix;
{
- int number, ndigits, invalid_p, c, sign;
+ int number = 0, ndigits = 0, invalid_p, c, sign = 0;
if (radix < 2 || radix > 36)
invalid_p = 1;
Lisp_Object beg, end, plist;
beg = read1 (readcharfun, &ch, 0);
+ end = plist = Qnil;
if (ch == ')')
break;
if (ch == 0)
read_objects = Qnil;
staticpro (&seen_list);
+ Vloads_in_progress = Qnil;
+ staticpro (&Vloads_in_progress);
}