Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: more improved error messages



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@xxxxxxx>            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



Messages sorted by: Reverse Date, Date, Thread, Author