From 0cba5ef62ad8e98924c2bd9367f9c7c7e72e2fd0 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 3 Sep 2008 09:08:18 +0000 Subject: 25595: fix line numbers with EVAL_LINENO, try to fix oddities with funcstack and sourced files, simplify use of caller element of funcstack --- Src/exec.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Src/exec.c') 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; -- cgit v1.2.3