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

Re: autoload +X[zk]



Sorrysorrysorry, just found a bug in this patch.


Bye
 Sven

diff -ru ../z.old/Src/builtin.c Src/builtin.c
--- ../z.old/Src/builtin.c	Mon Mar 27 13:05:36 2000
+++ Src/builtin.c	Mon Mar 27 13:21:31 2000
@@ -2016,7 +2016,7 @@
 	return bin_eval(name, fargv, ops, func);
     }
 
-    return loadautofn(shf, (ops['k'] ? 2 : (ops['z'] ? 0 : 1)));
+    return !loadautofn(shf, (ops['k'] ? 2 : (ops['z'] ? 0 : 1)));
 }
 
 /* Display or change the attributes of shell functions.   *
diff -ru ../z.old/Src/exec.c Src/exec.c
--- ../z.old/Src/exec.c	Mon Mar 27 13:05:36 2000
+++ Src/exec.c	Mon Mar 27 13:25:21 2000
@@ -3166,16 +3166,17 @@
 static int
 execautofn(Estate state, int do_exec)
 {
-    if (loadautofn(state->prog->shf, 1))
-	return 1;
+    Shfunc shf;
 
+    if (!(shf = loadautofn(state->prog->shf, 1)))
+	return 1;
 
-    execode(state->prog->shf->funcdef, 1, 0);
+    execode(shf->funcdef, 1, 0);
     return lastval;
 }
 
 /**/
-int
+Shfunc
 loadautofn(Shfunc shf, int fksh)
 {
     int noalias = noaliases, ksh = 1;
@@ -3193,7 +3194,7 @@
     if (prog == &dummy_eprog) {
 	zerr("%s: function definition file not found", shf->nam, 0);
 	popheap();
-	return 1;
+	return NULL;
     }
     if (!prog)
 	prog = &dummy_eprog;
@@ -3202,10 +3203,10 @@
 	strcpy(n, shf->nam);
 	execode(prog, 1, 0);
 	shf = (Shfunc) shfunctab->getnode(shfunctab, n);
-	if(!shf || (shf->flags & PM_UNDEFINED)) {
+	if (!shf || (shf->flags & PM_UNDEFINED)) {
 	    zerr("%s: function not defined by file", n, 0);
 	    popheap();
-	    return 1;
+	    return NULL;
 	}
     } else {
 	freeeprog(shf->funcdef);
@@ -3217,7 +3218,7 @@
     }
     popheap();
 
-    return 0;
+    return shf;
 }
 
 /* execute a shell function */

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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