Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] Strange auto-load behaviour when function name contains hyphen
- X-seq: zsh-workers 42123
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [BUG] Strange auto-load behaviour when function name contains hyphen
- Date: Thu, 14 Dec 2017 10:28:27 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20171214102832euoutp02d26b395fe81ef3c0af9a7c9c115b77d0~AImm0uwk62034320343euoutp02C
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1513247312; bh=k06UN22/ZtT1R60eiBMBjd6vc77VOLpDo32+JWpxRKA=; h=Date:From:To:Subject:In-reply-to:References:From; b=KwrvPUvorxvDOnjjqLb3rlXhtKg52ug6acEDW6SprZVKb2wcYjnFKYxNLDswb5z/5 s/aR2wDfWkFhzvZyKXzrnRejgDMyaAJQbYjd1wX5vy1iaYLoTmof0r9pncLNYbE6/a E+vceJZ7xPdHyRGoWBppkY9O8oksov8Bbh+C9kTA=
- In-reply-to: <20171214100142.27516153@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <CGME20171214064805epcas2p196a185a6c3c5e66640833d8dfa15d593@epcas2p1.samsung.com> <990A7EB2-C4BA-4E3D-99B3-7DA40846CBD1@dana.is> <20171214100142.27516153@pwslap01u.europe.root.pri>
On Thu, 14 Dec 2017 10:01:42 +0000
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> + if (*ptr1 != *ptr2 && *ptr1 != Dash && *ptr1 != '-')
Bart noticed the error here. I stared at for ages without noticing.
pws
diff --git a/Src/exec.c b/Src/exec.c
index fc6d02d..eda1015 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5669,11 +5669,13 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
funcsave->fstack.caller = funcstack ? funcstack->name :
dupstring(funcsave->argv0 ? funcsave->argv0 : argzero);
funcsave->fstack.lineno = lineno;
+ funcsave->fstack.flineno = shfunc->lineno;
+ if (funcstack)
+ funcsave->fstack.flineno += funcstack->flineno;
funcsave->fstack.prev = funcstack;
funcsave->fstack.tp = FS_FUNC;
funcstack = &funcsave->fstack;
- funcsave->fstack.flineno = shfunc->lineno;
funcsave->fstack.filename = getshfuncfile(shfunc);
prog = shfunc->funcdef;
@@ -5932,6 +5934,7 @@ stripkshdef(Eprog prog, char *name)
{
Wordcode pc;
wordcode code;
+ char *ptr1, *ptr2;
if (!prog)
return NULL;
@@ -5942,8 +5945,23 @@ stripkshdef(Eprog prog, char *name)
return prog;
pc++;
code = *pc++;
- if (wc_code(code) != WC_FUNCDEF ||
- *pc != 1 || strcmp(name, ecrawstr(prog, pc + 1, NULL)))
+ if (wc_code(code) != WC_FUNCDEF || *pc != 1)
+ return prog;
+
+ /*
+ * See if name of function requested (name) is same as
+ * name of function in word code. name may still have "-"
+ * tokenised.
+ */
+ ptr1 = name;
+ ptr2 = ecrawstr(prog, pc + 1, NULL);
+ while (*ptr1 && *ptr2) {
+ if (*ptr1 != *ptr2 && *ptr1 != Dash && *ptr2 != '-')
+ break;
+ ptr1++;
+ ptr2++;
+ }
+ if (*ptr1 || *ptr2)
return prog;
{
Messages sorted by:
Reverse Date,
Date,
Thread,
Author