summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/exec.c7
-rw-r--r--Src/zsh.h1
3 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 90fd3f891..7456a9b85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-12-22 Peter Stephenson <p.w.stephenson@ntlworld.com>
+
+ * 33395: Src/exec.c, Src/zsh.h: improved line numbering for
+ functions (in particular anonymous functions) defined inside
+ others, also flag for anonymous functions.
+
2017-12-20 Peter Stephenson <p.stephenson@samsung.com>
* dana: 42145: Src/Zle/computil.c, Test/Y03arguments.ztst: fix
diff --git a/Src/exec.c b/Src/exec.c
index 3678ef84a..38cc24a12 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5089,7 +5089,11 @@ execfuncdef(Estate state, Eprog redir_prog)
shf->node.flags = 0;
/* No dircache here, not a directory */
shf->filename = ztrdup(scriptfilename);
- shf->lineno = lineno;
+ shf->lineno =
+ (funcstack && (funcstack->tp == FS_FUNC ||
+ funcstack->tp == FS_EVAL)) ?
+ funcstack->flineno + lineno :
+ lineno;
/*
* redir_prog is permanently allocated --- but if
* this function has multiple names we need an additional
@@ -5109,6 +5113,7 @@ execfuncdef(Estate state, Eprog redir_prog)
LinkList args;
anon_func = 1;
+ shf->node.flags |= PM_ANONYMOUS;
state->pc = end;
end += *state->pc++;
diff --git a/Src/zsh.h b/Src/zsh.h
index 24d06ba06..22ae95480 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1875,6 +1875,7 @@ struct tieddata {
#define PM_DONTIMPORT_SUID (1<<19) /* do not import if running setuid */
#define PM_LOADDIR (1<<19) /* (function) filename gives load directory */
#define PM_SINGLE (1<<20) /* special can only have a single instance */
+#define PM_ANONYMOUS (1<<20) /* (function) anonymous function */
#define PM_LOCAL (1<<21) /* this parameter will be made local */
#define PM_SPECIAL (1<<22) /* special builtin parameter */
#define PM_DONTIMPORT (1<<23) /* do not import this variable */