about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-09-03 09:08:18 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-09-03 09:08:18 +0000
commit0cba5ef62ad8e98924c2bd9367f9c7c7e72e2fd0 (patch)
treeaff6e4b164bdd8dd1ad12c921ee774405a5ea244 /Src/exec.c
parentae79d264a3fd989713f6c7413c5096151413f284 (diff)
downloadzsh-0cba5ef62ad8e98924c2bd9367f9c7c7e72e2fd0.tar.gz
zsh-0cba5ef62ad8e98924c2bd9367f9c7c7e72e2fd0.tar.xz
zsh-0cba5ef62ad8e98924c2bd9367f9c7c7e72e2fd0.zip
25595: fix line numbers with EVAL_LINENO,
try to fix oddities with funcstack and sourced files,
simplify use of caller element of funcstack
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Src/exec.c b/Src/exec.c
index cf0efed19..a46dfd683 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4264,10 +4264,16 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
     }
 #endif
     fstack.name = dupstring(name);
-    fstack.caller = dupstring(oargv0 ? oargv0 : argzero);
+    /*
+     * The caller is whatever is immediately before on the stack,
+     * unless we're at the top, in which case it's the script
+     * or interactive shell name.
+     */
+    fstack.caller = funcstack ? funcstack->name :
+	dupstring(oargv0 ? oargv0 : argzero);
     fstack.lineno = lineno;
     fstack.prev = funcstack;
-    fstack.sourced = 0;
+    fstack.tp = FS_FUNC;
     funcstack = &fstack;
 
     if ((shf = (Shfunc) shfunctab->getnode(shfunctab, name))) {
@@ -4277,8 +4283,7 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
 	fstack.flineno = 0;
 	fstack.filename = dupstring(fstack.caller);
     }
-    
-    
+
     if (prog->flags & EF_RUN) {
 	Shfunc shf;