zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: more improved error messages
@ 2010-06-14 11:51 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2010-06-14 11:51 UTC (permalink / raw)
  To: Zsh Hackers' List

This improves the error messages for other module autoloads along the
same lines as for parameters.  I'm still puzzling over what to do for
conditions where the interface is more complicated.

? Src/test
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.179
diff -p -u -r1.179 exec.c
--- Src/exec.c	12 May 2010 10:07:01 -0000	1.179
+++ Src/exec.c	14 Jun 2010 11:48:16 -0000
@@ -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;
 	}
     }
Index: Src/math.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/math.c,v
retrieving revision 1.37
diff -p -u -r1.37 math.c
--- Src/math.c	20 Jan 2010 17:18:28 -0000	1.37
+++ Src/math.c	14 Jun 2010 11:48:16 -0000
@@ -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;
Index: Src/module.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/module.c,v
retrieving revision 1.41
diff -p -u -r1.41 module.c
--- Src/module.c	16 May 2009 12:13:06 -0000	1.41
+++ Src/module.c	14 Jun 2010 11:48:16 -0000
@@ -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;
 	}
Index: Test/V01zmodload.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/V01zmodload.ztst,v
retrieving revision 1.15
diff -p -u -r1.15 V01zmodload.ztst
--- Test/V01zmodload.ztst	7 Jun 2010 17:00:05 -0000	1.15
+++ Test/V01zmodload.ztst	14 Jun 2010 11:48:16 -0000
@@ -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

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-06-14 11:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-14 11:51 PATCH: more improved error messages Peter Stephenson

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).