From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: [BUG] Anonymous functions cause funcfiletrace to produce function-relative line numbers
Date: Wed, 20 Dec 2017 17:39:41 +0000 [thread overview]
Message-ID: <20171220173941.141333d3@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20171218090155.58c65907@pwslap01u.europe.root.pri>
I think this might be going in the right direction.
We don't need PM_ANONYMOUS, and in fact we've tested before by using a
special name pointer, but I quite like it for future use anyway...
I tried it with the following...
#snip
# this is line 1
foo() {
bar() { () { (){ print -rC2 -- $functrace $funcfiletrace; } } }
}
foo
bar
#snip
and got
(anon):0 ./why.txt:5
bar:0 ./why.txt:5
./why.txt:8 ./why.txt:8
zsh:1 zsh:1
which looks an improvement.
Probably not much activity till the New Year now.
pws
diff --git a/Src/exec.c b/Src/exec.c
index 3678ef8..38cc24a 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 24d06ba..22ae954 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 */
next prev parent reply other threads:[~2017-12-20 17:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20171210232854epcas2p2f9d4f0ac2ad31feb5a54d61da49e7140@epcas2p2.samsung.com>
2017-12-10 23:28 ` dana
2017-12-11 9:41 ` Peter Stephenson
2017-12-11 10:12 ` Peter Stephenson
2017-12-11 21:57 ` dana
2017-12-15 10:21 ` Peter Stephenson
2017-12-15 18:45 ` dana
2017-12-16 21:10 ` Bart Schaefer
2017-12-16 22:33 ` dana
2017-12-18 9:01 ` Peter Stephenson
2017-12-20 17:39 ` Peter Stephenson [this message]
2017-12-20 22:26 ` dana
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171220173941.141333d3@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).