Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: globcomplete bug + bug when compctl.so not loaded + init patch



Peter Stephenson wrote:

> I tried to reproduce this with zsh -f (and succeeded eventually), but got
> another bug --- well two, actually.  First I had to apply the patch at the
> end to get the _* files to match properly; plus I needed to fix up some
> nullglob flags in init and dump else dump miscounted the number of files; I
> also made dump produce an alphabetic order (I never realised `whence' just
> dumped the table out without ordering, but maybe I should have).
> 
> Then the following happened.
> 
> % fpath=(~/bin/comp)
> % . ~/bin/comp/init
> % setopt glob<TAB>
> zsh: 19372 illegal hardware instruction (core dumped)  ./zsh -f

I guess it's the same Andrej just reported. The patch below takes some 
code from `bin_zmodload_load' and puts it into a new function
`require_module'. Then `bin_zle_complete' calls this function to try
to make `compctl' loaded. In an environment without dynamically loaded 
modules it just tests if `makecompparamsptr' is NULL.

Bye
 Sven

diff -u os/module.c Src/module.c
--- os/module.c	Wed Feb 24 13:59:11 1999
+++ Src/module.c	Wed Feb 24 15:47:06 1999
@@ -567,6 +567,37 @@
     return m;
 }
 
+/* This ensures that the module with the name given as the second argument
+ * is loaded.
+ * The third argument should be non-zero if the function should complain
+ * 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. */
+
+/**/
+Module
+require_module(char *nam, char *module, int res, int test)
+{
+    Module m = NULL;
+    LinkNode node;
+
+    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;
+	}
+    } else if (res && isset(RESTRICTED) && strchr(module, '/')) {
+	zwarnnam(nam, "%s: restricted", module, 0);
+	return NULL;
+    } else
+	return load_module(module);
+
+    return m;
+}
+
 /**/
 void
 add_dep(char *name, char *from)
@@ -963,22 +994,10 @@
 	return 0;
     } else {
 	/* load modules */
-	for (; *args; args++) {
-	    Module m;
-
-	    node = find_module(*args);
-	    if (node && (m = ((Module) getdata(node)))->handle &&
-		!(m->flags & MOD_UNLOAD)) {
-		if (!ops['i']) {
-		    zwarnnam(nam, "module %s already loaded.", *args, 0);
-		    ret = 1;
-		}
-	    } else if (isset(RESTRICTED) && strchr(*args, '/')) {
-		zwarnnam(nam, "%s: restricted", *args, 0);
-		ret = 1;
-	    } else if (!load_module(*args))
+	for (; *args; args++)
+	    if (!require_module(nam, *args, 1, (!ops['i'])))
 		ret = 1;
-	}
+
 	return ret;
     }
 }
diff -u os/Zle/comp1.c Src/Zle/comp1.c
--- os/Zle/comp1.c	Tue Feb 23 11:34:27 1999
+++ Src/Zle/comp1.c	Wed Feb 24 15:52:40 1999
@@ -410,6 +410,7 @@
     cc_first.mask2 = CC_CCCONT;
     compcontext = compcommand = compprefix = compsuffix =
 	compiprefix = NULL;
+    makecompparamsptr = NULL;
     return 0;
 }
 
diff -u os/Zle/zle_thingy.c Src/Zle/zle_thingy.c
--- os/Zle/zle_thingy.c	Tue Feb 23 11:34:29 1999
+++ Src/Zle/zle_thingy.c	Wed Feb 24 15:46:17 1999
@@ -478,6 +478,17 @@
     Thingy t;
     Widget w, cw;
 
+#ifdef DYNAMIC
+    if (!require_module(name, "compctl", 0, 0)) {
+	zerrnam(name, "can't load compctl module", NULL, 0);
+	return 1;
+    }
+#else
+    if (!makecompparamsptr) {
+	zerrnam(name, "compctl module not available", NULL, 0);
+	return 1;
+    }
+#endif
     t = rthingy(args[1]);
     cw = t->widget;
     unrefthingy(t);

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author