[BusyBox] [patch] hex constants in ash arithmetic

Dick Streefland Dick.Streefland at xs4all.nl
Sun May 5 13:37:03 UTC 2002


The following micro patch adds support for hex constants in ash
arithmetic expressions, just like bash. You can use this to convert
hex values that are used in various /proc files to decimal. Example:

$ hex=100
$ echo $((0x$hex))
256

-- 
Dick Streefland                    ////               De Bilt
dick.streefland at xs4all.nl         (@ @)       The Netherlands
------------------------------oOO--(_)--OOo------------------

--- busybox-0.60.3/libbb/arith.c.orig	Sat Oct 27 01:08:06 2001
+++ busybox-0.60.3/libbb/arith.c	Sat May  4 23:27:08 2002
@@ -157,7 +157,7 @@
 		if (arithval == ' ' || arithval == '\n' || arithval == '\t')
 			goto prologue;
 		if ((unsigned)arithval-'0' <= 9) /* isdigit */ {
-			*numstackptr++ = strtol(expr, (char **) &expr, 10);
+			*numstackptr++ = strtol(expr, (char **) &expr, 0);
 			lasttok = TOK_NUM;
 			continue;
 		} if (arithval == '(') {



More information about the busybox mailing list