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

Re: arithmetic base accepted on output but not input



"Richard Hartmann" wrote:
> On Wed, May 14, 2008 at 12:43 PM, Peter Stephenson <pws@xxxxxxx> wrote:
> 
> > +       if (pm->base < 2 || pm->base > 36) {
> > +           zwarnnam(name, "invalid base: %d", pm->base);
> > +           return 1;
> > +       }
> 
> Could you make the error messages state what range, i.e. 2 to 36,
> is allowed, please? Verbose error messages are a great thing :)

OK

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.195
diff -u -r1.195 builtin.c
--- Src/builtin.c	15 May 2008 15:51:01 -0000	1.195
+++ Src/builtin.c	10 Jun 2008 08:41:28 -0000
@@ -1745,7 +1745,8 @@
 	    return 1;
 	}
 	if (pm->base < 2 || pm->base > 36) {
-	    zwarnnam(name, "invalid base: %d", pm->base);
+	    zwarnnam(name, "invalid base (must be 2 to 36 inclusive): %d",
+		     pm->base);
 	    return 1;
 	}
     } else if (always)
Index: Src/math.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/math.c,v
retrieving revision 1.31
diff -u -r1.31 math.c
--- Src/math.c	14 May 2008 10:48:28 -0000	1.31
+++ Src/math.c	10 Jun 2008 08:41:28 -0000
@@ -461,7 +461,8 @@
 		if(*ptr != ']')
 			goto bofs;
 		if (outputradix < 2 || outputradix > 36) {
-		    zerr("invalid base: %d", outputradix);
+		    zerr("invalid base (must be 2 to 36 inclusive): %d",
+			 outputradix);
 		    return EOI;
 		}
 		ptr++;
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.193
diff -u -r1.193 utils.c
--- Src/utils.c	17 May 2008 22:43:27 -0000	1.193
+++ Src/utils.c	10 Jun 2008 08:41:28 -0000
@@ -1844,7 +1844,7 @@
     }
     inp = s;
     if (base < 2 || base > 36) {
-	zerr("invalid base: %d", base);
+	zerr("invalid base (must be 2 to 36 inclusive): %d", base);
 	return (zlong)0;
     } else if (base <= 10)
 	for (; *s >= '0' && *s < ('0' + base); s++) {

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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