about summary refs log tree commit diff
path: root/Src/Modules/parameter.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/Modules/parameter.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/Modules/parameter.c')
-rw-r--r--Src/Modules/parameter.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index 4119c4982..b6c8c5608 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -583,7 +583,7 @@ funcfiletracegetfn(UNUSED(Param pm))
     for (f = funcstack, p = ret; f; f = f->prev, p++) {
 	char *colonpair, *fname;
 
-	if (!f->prev || f->prev->sourced) {
+	if (!f->prev || f->prev->tp == FS_SOURCE) {
 	    /*
 	     * Calling context is a file---either the parent
 	     * script or interactive shell, or a sourced
@@ -595,13 +595,20 @@ funcfiletracegetfn(UNUSED(Param pm))
 	    sprintf(colonpair, "%s:%ld", f->caller, (long)f->lineno);
 	} else {
 	    /*
-	     * Calling context is a function; we need to find the line number
-	     * in the file where that function was defined.  For this we need
-	     * the $funcsourcetrace information for the context above,
+	     * Calling context is a function or eval; we need to find
+	     * the line number in the file where that function was
+	     * defined or the eval was called.  For this we need the
+	     * $funcsourcetrace information for the context above,
 	     * together with the $functrace line number for the current
 	     * context.
 	     */
 	    long flineno = (long)(f->prev->flineno + f->lineno);
+	    /*
+	     * Line numbers in eval start from 1, not zero,
+	     * so offset by one to get line in file.
+	     */
+	    if (f->prev->tp == FS_EVAL)
+		flineno--;
 	    fname = f->prev->filename ? f->prev->filename : "";
 
 	    colonpair = zhalloc(strlen(fname) + (flineno > 9999 ? 24 : 6));