Include <config.h> instead of "config.h".
[bpt/emacs.git] / src / lread.c
index 8615288..8703a7e 100644 (file)
@@ -1,6 +1,6 @@
 /* Lisp parsing and input streams.
    Copyright (C) 1985, 1986, 1987, 1988, 1989,
-   1992 Free Software Foundation, Inc.
+   1993 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -24,8 +24,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <sys/stat.h>
 #include <sys/file.h>
 #include <ctype.h>
-#undef NULL
-#include "config.h"
+#include <config.h>
 #include "lisp.h"
 
 #ifndef standalone
@@ -45,12 +44,15 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #endif
 
 #ifdef LISP_FLOAT_TYPE
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
 #include <math.h>
 #endif /* LISP_FLOAT_TYPE */
 
-Lisp_Object Qread_char, Qget_file_char, Qstandard_input;
+Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list;
 Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist;
-Lisp_Object Qascii_character;
+Lisp_Object Qascii_character, Qload;
 
 extern Lisp_Object Qevent_symbol_element_mask;
 
@@ -316,10 +318,16 @@ Return t if file exists.")
   Lisp_Object found;
   /* 1 means inhibit the message at the beginning.  */
   int nomessage1 = 0;
+  Lisp_Object handler;
 
   CHECK_STRING (str, 0);
   str = Fsubstitute_in_file_name (str);
 
+  /* If file name is magic, call the handler.  */
+  handler = Ffind_file_name_handler (str);
+  if (!NILP (handler))
+    return call5 (handler, Qload, str, noerror, nomessage, nosuffix);
+
   /* Avoid weird lossage with null string as arg,
      since it would try to load a directory as a Lisp file */
   if (XSTRING (str)->size > 0)
@@ -532,6 +540,10 @@ build_load_history (stream, source)
   register Lisp_Object tem, tem2;
   register int foundit, loading;
 
+  /* Don't bother recording anything for preloaded files.  */
+  if (!NILP (Vpurify_flag))
+    return;
+
   loading = stream || !NARROWED;
 
   tail = Vload_history;
@@ -579,12 +591,12 @@ build_load_history (stream, source)
       QUIT;
     }
 
-      /* If we're loading, cons the new assoc onto the front of load-history,
-        the most-recently-loaded position.  Also do this if we didn't find
-        an existing member for the current source.  */
-      if (loading || !foundit)
-         Vload_history = Fcons (Fnreverse(Vcurrent_load_list),
-                                Vload_history);
+  /* If we're loading, cons the new assoc onto the front of load-history,
+     the most-recently-loaded position.  Also do this if we didn't find
+     an existing member for the current source.  */
+  if (loading || !foundit)
+    Vload_history = Fcons (Fnreverse (Vcurrent_load_list),
+                          Vload_history);
 }
 
 Lisp_Object
@@ -604,16 +616,14 @@ readevalloop (readcharfun, stream, sourcename, evalfun, printflag)
 {
   register int c;
   register Lisp_Object val;
-  Lisp_Object oldlist;
   int count = specpdl_ptr - specpdl;
-  struct gcpro gcpro1, gcpro2;
+  struct gcpro gcpro1;
 
   specbind (Qstandard_input, readcharfun);
+  specbind (Qcurrent_load_list, Qnil);
 
-  oldlist = Vcurrent_load_list;
-  GCPRO2 (sourcename, oldlist);
+  GCPRO1 (sourcename);
 
-  Vcurrent_load_list = Qnil;
   LOADHIST_ATTACH (sourcename);
 
   while (1)
@@ -652,8 +662,6 @@ readevalloop (readcharfun, stream, sourcename, evalfun, printflag)
     }
 
   build_load_history (stream, sourcename);
-
-  Vcurrent_load_list = oldlist;
   UNGCPRO;
 
   unbind_to (count, Qnil);
@@ -1776,7 +1784,20 @@ init_lread ()
 
       dump_path = decode_env_path (0, PATH_DUMPLOADSEARCH);
       if (! NILP (Fequal (dump_path, Vload_path)))
-       Vload_path = decode_env_path (0, normal);
+       {
+         Vload_path = decode_env_path (0, normal);
+         if (!NILP (Vinvocation_directory))
+           {
+             /* Add to the path the ../lisp dir of the Emacs executable,
+                if that dir exists.  */
+             Lisp_Object tem, tem1;
+             tem = Fexpand_file_name (build_string ("../lisp"),
+                                      Vinvocation_directory);
+             tem1 = Ffile_exists_p (tem);
+             if (!NILP (tem1) && NILP (Fmember (tem, Vload_path)))
+               Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
+           }
+       }
     }
   else
     Vload_path = decode_env_path (0, normal);
@@ -1873,9 +1894,13 @@ The remaining elements of each list are symbols defined as functions\n\
 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.");
   Vload_history = Qnil;
 
-  staticpro (&Vcurrent_load_list);
+  DEFVAR_LISP ("current-load-list", &Vcurrent_load_list,
+    "Used for internal purposes by `load'.");
   Vcurrent_load_list = Qnil;
 
+  Qcurrent_load_list = intern ("current-load-list");
+  staticpro (&Qcurrent_load_list);
+
   Qstandard_input = intern ("standard-input");
   staticpro (&Qstandard_input);
 
@@ -1887,4 +1912,7 @@ or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.");
 
   Qascii_character = intern ("ascii-character");
   staticpro (&Qascii_character);
+
+  Qload = intern ("load");
+  staticpro (&Qload);
 }