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

PATCH: another base output problem.



This fixes this problem:

% f=472
% print $(( [#16] f ))
472

which arose because the nested evaluation set outputradix back to zero.
The simplest fix seems to be only to reset it for a top-level math eval.
Anything more sophisticated is hard because of the fact that some inner
math evals (such as this one) are fairly well hidden.

Index: Src/math.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/math.c,v
retrieving revision 1.6
diff -u -r1.6 math.c
--- Src/math.c	2000/09/02 17:09:29	1.6
+++ Src/math.c	2000/09/04 15:01:57
@@ -959,7 +959,9 @@
     char *junk;
     mnumber x;
     int xmtok = mtok;
-    outputradix = 0;
+    /* maintain outputradix across levels of evaluation */
+    if (!mlevel)
+	outputradix = 0;
 
     if (!*s) {
 	x.type = MN_INTEGER;

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070



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