Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix for require_module()
- X-seq: zsh-workers 6066
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: fix for require_module()
- Date: Wed, 21 Apr 1999 09:24:38 +0200 (MET DST)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
I stumbled over this last weekend. The zle module uses
`require_module()' to make sure that the `compctl' module is loaded
when `zle -C' is invoked. But if `compctl' is linked in, this won't
work, because linked-in modules don't appear in the `modules' list.
The patch adds another list `bltinmodules' with the names of the
linked-in modules and makes `mkbltnmlst.sh' call the function
`register_module()' for them.
Bye
Sven
diff -u os/init.c Src/init.c
--- os/init.c Thu Mar 25 10:09:04 1999
+++ Src/init.c Wed Apr 21 09:09:42 1999
@@ -559,6 +559,7 @@
module_path = mkarray(ztrdup(MODULE_DIR));
modules = newlinklist();
#endif
+ bltinmodules = newlinklist();
/* Set default prompts */
if(unset(INTERACTIVE)) {
diff -u os/mkbltnmlst.sh Src/mkbltnmlst.sh
--- os/mkbltnmlst.sh Wed Apr 21 09:16:05 1999
+++ Src/mkbltnmlst.sh Wed Apr 21 09:16:47 1999
@@ -61,6 +61,6 @@
exit 1 ;;
esac
done
- echo " mod.nam = \"$bin_mod\"; setup_$bin_mod(&mod); boot_$bin_mod(&mod);"
+ echo " register_module(mod.nam = \"$bin_mod\"); setup_$bin_mod(&mod); boot_$bin_mod(&mod);"
done_mods="$done_mods$bin_mod "
done
diff -u os/module.c Src/module.c
--- os/module.c Thu Feb 25 12:07:06 1999
+++ Src/module.c Wed Apr 21 09:17:52 1999
@@ -30,6 +30,12 @@
#include "zsh.mdh"
#include "module.pro"
+/* List of builtin modules. */
+
+/**/
+LinkList bltinmodules;
+
+
/* The `zsh' module contains all the base code that can't actually be built *
* as a separate module. It is initialised by main(), so there's nothing *
* for the boot function to do. */
@@ -48,6 +54,17 @@
return 0;
}
+/* This registers a builtin module. */
+
+/**/
+void
+register_module(char *n)
+{
+ PERMALLOC {
+ addlinknode(bltinmodules, n);
+ } LASTALLOC;
+}
+
/* addbuiltin() can be used to add a new builtin. It returns zero on *
* success, 1 on failure. The only possible type of failure is that *
* a builtin with the specified name already exists. An autoloaded *
@@ -573,29 +590,34 @@
* about trying to load a module with a full path name in restricted mode.
* The last argument should be non-zero if this function should signal an
* error if the module is already loaded.
- * The return value is the module of NULL if the module couldn't be loaded. */
+ * The return value is non-zero if the module was found or loaded. */
/**/
-Module
+int
require_module(char *nam, char *module, int res, int test)
{
Module m = NULL;
LinkNode node;
+ /* First see if the module is linked in. */
+ for (node = firstnode(bltinmodules); node; incnode(node)) {
+ if (!strcmp((char *) getdata(node), nam))
+ return 1;
+ }
node = find_module(module);
if (node && (m = ((Module) getdata(node)))->handle &&
!(m->flags & MOD_UNLOAD)) {
if (test) {
zwarnnam(nam, "module %s already loaded.", module, 0);
- return NULL;
+ return 0;
}
} else if (res && isset(RESTRICTED) && strchr(module, '/')) {
zwarnnam(nam, "%s: restricted", module, 0);
- return NULL;
+ return 0;
} else
- return load_module(module);
+ return !!load_module(module);
- return m;
+ return 1;
}
/**/
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author