about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-07-09 16:20:53 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-07-09 16:20:53 +0000
commit7457bdc19d9db02070092c6657ffdc2a8fd85fae (patch)
tree102e76e27e41336fc54d06849def341849917a0a
parent003ec8c7e8814221b366e95dc4ea24fa4cf1e99c (diff)
downloadzsh-7457bdc19d9db02070092c6657ffdc2a8fd85fae.tar.gz
zsh-7457bdc19d9db02070092c6657ffdc2a8fd85fae.tar.xz
zsh-7457bdc19d9db02070092c6657ffdc2a8fd85fae.zip
Fix function stack unwinding on autoload failures.
-rw-r--r--ChangeLog5
-rw-r--r--Src/exec.c13
2 files changed, 12 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index d146f6abc..3497f979e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,11 @@
 	do this sometimes in order for existing $LINENO to show through.
 	This seems to cause more problems than it solves.
 
+2001-07-09  Bart Schaefer  <schaefer@zsh.org>
+
+	* 15321: Src/exec.c: Fix line numbers in an error message; unwind
+	function context properly on obscure autoloading failures.
+
 2001-07-07  Bart Schaefer  <schaefer@zsh.org>
 
 	* 15308: Src/builtin.c: Fix infinite loop on `r OLD=NEW' when OLD
diff --git a/Src/exec.c b/Src/exec.c
index c3da81b5d..c428fdbba 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3273,7 +3273,10 @@ loadautofn(Shfunc shf, int fksh, int autol)
 	    execode(prog, 1, 0);
 	    shf = (Shfunc) shfunctab->getnode(shfunctab, n);
 	    if (!shf || (shf->flags & PM_UNDEFINED)) {
+		/* We're not actually in the function; decrement locallevel */
+		locallevel--;
 		zwarn("%s: function not defined by file", n, 0);
+		locallevel++;
 		popheap();
 		return NULL;
 	    }
@@ -3359,9 +3362,7 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
     if(++funcdepth > MAX_FUNCTION_DEPTH)
     {
         zerr("maximum nested function level reached", NULL, 0);
-	scriptname = oldscriptname;
-	popheap();
-	return;
+	goto undoshfunc;
     }
 #endif
     fstack.name = dupstring(name);
@@ -3382,15 +3383,15 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
 		errflag = 1;
 	    else
 		lastval = 1;
-	    popheap();
-	    scriptname = oldscriptname;
-	    return;
+	    goto doneshfunc;
 	}
 	prog = shf->funcdef;
     }
     runshfunc(prog, wrappers, fstack.name);
+ doneshfunc:
     funcstack = fstack.prev;
 #ifdef MAX_FUNCTION_DEPTH
+ undoshfunc:
     --funcdepth;
 #endif
     if (retflag) {