summaryrefslogtreecommitdiff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2017-12-15 08:56:19 +0000
committerPeter Stephenson <pws@zsh.org>2017-12-15 09:00:37 +0000
commitaab0f6d763b0eb3eb964c576953c9dd0b90916ae (patch)
treea9904adba1126d1492411a09029c3283e95186e8 /Src/exec.c
parentcb04ae40af123da88bf0209964965d17a9486325 (diff)
downloadzsh-aab0f6d763b0eb3eb964c576953c9dd0b90916ae.tar.gz
zsh-aab0f6d763b0eb3eb964c576953c9dd0b90916ae.zip
42123 (tweaked): take account of Dash in function names.
Needed when comparing word code function name with autoload request. Add test.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/Src/exec.c b/Src/exec.c
index fc6d02dc3..664d79079 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5932,6 +5932,7 @@ stripkshdef(Eprog prog, char *name)
{
Wordcode pc;
wordcode code;
+ char *ptr1, *ptr2;
if (!prog)
return NULL;
@@ -5942,8 +5943,25 @@ 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. The word code shouldn't, as function names should be
+ * untokenised, but reports say it sometimes does.
+ */
+ ptr1 = name;
+ ptr2 = ecrawstr(prog, pc + 1, NULL);
+ while (*ptr1 && *ptr2) {
+ if (*ptr1 != *ptr2 && *ptr1 != Dash && *ptr1 != '-' &&
+ *ptr2 != Dash && *ptr2 != '-')
+ break;
+ ptr1++;
+ ptr2++;
+ }
+ if (*ptr1 || *ptr2)
return prog;
{