XEmacs 21.2.29 "Hestia".
[chise/xemacs-chise.git.1] / src / emodules.c
index 1a5d896..bcd8f01 100644 (file)
@@ -42,12 +42,14 @@ typedef struct _emodules_list
   dll_handle dlhandle;  /* Dynamic lib handle                           */
 } emodules_list;
 
+static Lisp_Object Vmodule_extensions;
+
 static int emodules_depth;
 static dll_handle dlhandle;
 static emodules_list *modules;
 static int modnum;
 
-static int find_make_module (CONST char *mod, CONST char *name, CONST char *ver, int make_or_find);
+static int find_make_module (const char *mod, const char *name, const char *ver, int make_or_find);
 static Lisp_Object module_load_unwind (Lisp_Object);
 static void attempt_module_delete (int mod);
 
@@ -182,7 +184,7 @@ is a bug, and you are encouraged to report it.
 }
 
 static int
-find_make_module (CONST char *mod, CONST char *name, CONST char *ver, int mof)
+find_make_module (const char *mod, const char *name, const char *ver, int mof)
 {
   int i, fs = -1;
 
@@ -211,9 +213,9 @@ find_make_module (CONST char *mod, CONST char *name, CONST char *ver, int mof)
    * not previously loaded.
    */
   if (modules == (emodules_list *)0)
-    modules = (emodules_list *)xmalloc (sizeof(emodules_list));
+    modules = (emodules_list *) xmalloc (sizeof (emodules_list));
   modnum++;
-  modules = xrealloc (modules, modnum * sizeof(emodules_list));
+  modules = (emodules_list *) xrealloc (modules, modnum * sizeof (emodules_list));
 
   fs = modnum - 1;
   memset (&modules[fs], 0, sizeof(emodules_list));
@@ -302,14 +304,14 @@ module_load_unwind (Lisp_Object upto)
  * the cleaning up.
  */
 void
-emodules_load(CONST char *module, CONST char *modname, CONST char *modver)
+emodules_load(const char *module, const char *modname, const char *modver)
 {
   Lisp_Object filename;
   Lisp_Object foundname;
   int fd, x, mpx;
   char *soname, *tmod;
-  CONST char **f;
-  CONST long *ellcc_rev;
+  const char **f;
+  const long *ellcc_rev;
   char *mver, *mname, *mtitle, *symname;
   void (*modload)(void) = 0;
   void (*modsyms)(void) = 0;
@@ -324,7 +326,7 @@ emodules_load(CONST char *module, CONST char *modname, CONST char *modver)
   emodules_depth++;
   dlhandle = 0;
 
-  if ((module == (CONST char *)0) || (module[0] == '\0'))
+  if ((module == (const char *)0) || (module[0] == '\0'))
     error ("Empty module name");
 
   /* This is to get around the fact that build_string() is not declared
@@ -334,7 +336,8 @@ emodules_load(CONST char *module, CONST char *modname, CONST char *modver)
 
   GCPRO2(filename, foundname);
   filename = build_string (tmod);
-  fd = locate_file(Vmodule_load_path, filename, ":.ell:.so:.dll", &foundname, -1);
+  fd = locate_file(Vmodule_load_path, filename, Vmodule_extensions,
+                  &foundname, -1);
   UNGCPRO;
 
   if (fd < 0)
@@ -347,15 +350,15 @@ emodules_load(CONST char *module, CONST char *modname, CONST char *modver)
   if (dlhandle == (dll_handle)0)
     error ("Opening dynamic module: %s", dll_error (dlhandle));
 
-  ellcc_rev = (CONST long *)dll_variable (dlhandle, "emodule_compiler");
-  if ((ellcc_rev == (CONST long *)0) || (*ellcc_rev <= 0))
+  ellcc_rev = (const long *)dll_variable (dlhandle, "emodule_compiler");
+  if ((ellcc_rev == (const long *)0) || (*ellcc_rev <= 0))
     error ("Missing symbol `emodule_compiler': Invalid dynamic module");
   if (*ellcc_rev > EMODULES_REVISION)
     error ("Unsupported version `%ld(%ld)': Invalid dynamic module",
            *ellcc_rev, EMODULES_REVISION);
 
-  f = (CONST char **)dll_variable (dlhandle, "emodule_name");
-  if ((f == (CONST char **)0) || (*f == (CONST char *)0))
+  f = (const char **)dll_variable (dlhandle, "emodule_name");
+  if ((f == (const char **)0) || (*f == (const char *)0))
     error ("Missing symbol `emodule_name': Invalid dynamic module");
 
   mname = (char *)alloca (strlen (*f) + 1);
@@ -363,15 +366,15 @@ emodules_load(CONST char *module, CONST char *modname, CONST char *modver)
   if (mname[0] == '\0')
     error ("Empty value for `emodule_name': Invalid dynamic module");
 
-  f = (CONST char **)dll_variable (dlhandle, "emodule_version");
-  if ((f == (CONST char **)0) || (*f == (CONST char *)0))
+  f = (const char **)dll_variable (dlhandle, "emodule_version");
+  if ((f == (const char **)0) || (*f == (const char *)0))
     error ("Missing symbol `emodule_version': Invalid dynamic module");
 
   mver = (char *)alloca (strlen (*f) + 1);
   strcpy (mver, *f);
 
-  f = (CONST char **)dll_variable (dlhandle, "emodule_title");
-  if ((f == (CONST char **)0) || (*f == (CONST char *)0))
+  f = (const char **)dll_variable (dlhandle, "emodule_title");
+  if ((f == (const char **)0) || (*f == (const char *)0))
     error ("Missing symbol `emodule_title': Invalid dynamic module");
 
   mtitle = (char *)alloca (strlen (*f) + 1);
@@ -475,11 +478,11 @@ emodules_load(CONST char *module, CONST char *modname, CONST char *modver)
 }
 
 void
-emodules_doc_subr(CONST char *symname, CONST char *doc)
+emodules_doc_subr(const char *symname, const char *doc)
 {
   Bytecount len = strlen (symname);
-  Lisp_Object sym = oblookup (Vobarray, (CONST Bufbyte *)symname, len);
-  struct Lisp_Subr *subr;
+  Lisp_Object sym = oblookup (Vobarray, (const Bufbyte *)symname, len);
+  Lisp_Subr *subr;
 
   if (SYMBOLP(sym))
     {
@@ -495,10 +498,10 @@ emodules_doc_subr(CONST char *symname, CONST char *doc)
 }
 
 void
-emodules_doc_sym (CONST char *symname, CONST char *doc)
+emodules_doc_sym (const char *symname, const char *doc)
 {
   Bytecount len = strlen (symname);
-  Lisp_Object sym = oblookup (Vobarray, (CONST Bufbyte *)symname, len);
+  Lisp_Object sym = oblookup (Vobarray, (const Bufbyte *)symname, len);
   Lisp_Object docstr;
   struct gcpro gcpro1;
 
@@ -523,8 +526,18 @@ syms_of_module (void)
 }
 
 void
+reinit_vars_of_module (void)
+{
+  emodules_depth = 0;
+  modules = (emodules_list *)0;
+  modnum = 0;
+}
+
+void
 vars_of_module (void)
 {
+  reinit_vars_of_module ();
+
   DEFVAR_LISP ("module-version", &Vmodule_version /*
 Emacs dynamic loading mechanism version, as a string.
 
@@ -534,7 +547,7 @@ This variable can be used to distinquish between different versions of
 the dynamic loading technology used in Emacs, if required.  It is not
 a given that this value will be the same as the Emacs version number.
 */ );
-  Vmodule_version = Fpurecopy (build_string (EMODULES_VERSION));
+  Vmodule_version = build_string (EMODULES_VERSION);
 
   DEFVAR_BOOL ("load-modules-quietly", &load_modules_quietly /*
 *Set to t if module loading is to be silent.
@@ -567,10 +580,11 @@ the correctness of a dynamic module, which can have unpredictable results
 when a dynamic module is loaded.
 */);
 
+  /* #### Export this to Lisp */
+  Vmodule_extensions = build_string (":.ell:.so:.dll");
+  staticpro (&Vmodule_extensions);
+
   load_modules_quietly = 0;
-  emodules_depth = 0;
-  modules = (emodules_list *)0;
-  modnum = 0;
   Vmodule_load_path = Qnil;
   Fprovide (intern ("modules"));
 }