From e6f14352d61721db83b46e0e56c4d19b731fed95 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 14 Jun 2010 11:57:08 +0000 Subject: 28037: improved error messages for module autoloads of math functions and builtins --- ChangeLog | 6 +++++- Src/exec.c | 6 ++++-- Src/math.c | 3 ++- Src/module.c | 5 ++++- Test/V01zmodload.ztst | 4 ++-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 300bef279..d053c39d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-06-14 Peter Stephenson + * 28037: Src/exec.c, Src/math.c, Src/module.c, + Test/V01zmodload.ztst: improved error messages for autoloading + math functions and builtins (but not conditions). + * 28010: configure.ac, Src/compat.c: use getcwd() as fallback if zgetcwd() fails. @@ -13285,5 +13289,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5002 $ +* $Revision: 1.5003 $ ***************************************************** diff --git a/Src/exec.c b/Src/exec.c index 8fd52420b..6611e9c79 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -2274,18 +2274,20 @@ static HashNode resolvebuiltin(const char *cmdarg, HashNode hn) { if (!((Builtin) hn)->handlerfunc) { + char *modname = dupstring(((Builtin) hn)->optstr); /* * Ensure the module is loaded and the * feature corresponding to the builtin * is enabled. */ - (void)ensurefeature(((Builtin) hn)->optstr, "b:", + (void)ensurefeature(modname, "b:", (hn->flags & BINF_AUTOALL) ? NULL : hn->nam); hn = builtintab->getnode(builtintab, cmdarg); if (!hn) { lastval = 1; - zerr("unknown builtin: %s", cmdarg); + zerr("autoloading module %s failed to define builtin: %s", + modname, cmdarg); return NULL; } } diff --git a/Src/math.c b/Src/math.c index a19c8c762..caff06de9 100644 --- a/Src/math.c +++ b/Src/math.c @@ -941,8 +941,9 @@ callmathfunc(char *o) zerr("wrong number of arguments: %s", o); } } - } else + } else { zerr("unknown function: %s", n); + } dummy.type = MN_INTEGER; dummy.u.l = 0; diff --git a/Src/module.c b/Src/module.c index 4f71153b7..219bdfa8e 100644 --- a/Src/module.c +++ b/Src/module.c @@ -1273,7 +1273,10 @@ getmathfunc(const char *name, int autol) (void)ensurefeature(n, "f:", (flags & MFF_AUTOALL) ? NULL : name); - return getmathfunc(name, 0); + p = getmathfunc(name, 0); + if (!p) { + zerr("autoloading module %s failed to define math function: %s", n, name); + } } return p; } diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst index 090c637df..d74b0ef18 100644 --- a/Test/V01zmodload.ztst +++ b/Test/V01zmodload.ztst @@ -135,7 +135,7 @@ print "Shouldn't get here.") 1:Failed builtin autoload ?(eval):3: module `zsh/parameter' has no such feature: `b:fail': autoload cancelled -?(eval):3: unknown builtin: fail +?(eval):3: autoloading module zsh/parameter failed to define builtin: fail (zmodload -u zsh/parameter zmodload -aF zsh/parameter p:fail @@ -158,7 +158,7 @@ (( fail() )) ) 2:Failed math function autoload ?(eval):3: module `zsh/parameter' has no such feature: `f:fail': autoload cancelled -?(eval):3: unknown function: fail +?(eval):3: autoloading module zsh/parameter failed to define math function: fail zmodload -aF zsh/parameter f:fail2 1:Immediate autoload failure on non-existent feature when module loaded -- cgit 1.4.1