diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/exec.c | 22 | ||||
-rw-r--r-- | Test/C04funcdef.ztst | 9 |
3 files changed, 34 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index dfd30ca9c..5613c8c72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-12-15 Peter Stephenson <p.stephenson@samsung.com> + + * 42123 (tweaked further): Src/exec.c: need to take account of + Dash when comparing functions names for autoloading. + 2017-12-14 Peter Stephenson <p.stephenson@samsung.com> * dana: 42119: Doc/zsh/params.yo, Src/jobs.c, 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; { diff --git a/Test/C04funcdef.ztst b/Test/C04funcdef.ztst index 0c00a0477..5786018e0 100644 --- a/Test/C04funcdef.ztst +++ b/Test/C04funcdef.ztst @@ -523,6 +523,15 @@ 1: ?fn:4: maximum nested function level reached; increase FUNCNEST? + ( + fpath=(.) + print "foo-bar() { print this should run automatically; }" >foo-bar + autoload -Uz foo-bar + foo-bar + ) +0:autoload containing dash +>this should run automatically + %clean rm -f file.in file.out |