[BusyBox-cvs] Config.in
Erik Andersen,,,
andersen at busybox.net
Tue Jun 22 08:29:48 UTC 2004
Update of /var/cvs/busybox/shell
In directory nail:/tmp/cvs-serv32036/shell
Modified Files:
Config.in ash.c
Log Message:
Patch from Bastian Blank:
The updated patch adds a config option to explicitely enable 64 bit
arithmetic.
Also it removes the arith prototype from libbb.h as it is not used
outside of ash.
Bastian
this patch has been slightly modified by Erik for cleanliness.
Index: Config.in
===================================================================
RCS file: /var/cvs/busybox/shell/Config.in,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- Config.in 7 Apr 2004 09:34:26 -0000 1.15
+++ Config.in 22 Jun 2004 08:29:45 -0000 1.16
@@ -67,6 +67,15 @@
help
Enable math support in the ash shell.
+config CONFIG_ASH_MATH_SUPPORT_64
+ bool " Extend Posix math support to 64 bit"
+ default n
+ depends on CONFIG_ASH_MATH_SUPPORT
+ help
+ Enable 64-bit math support in the ash shell. This will make
+ the shell slightly larger, but will allow computation with very
+ large numbers.
+
config CONFIG_ASH_GETOPTS
bool " Enable getopt builtin to parse positional parameters"
default n
Index: ash.c
===================================================================
RCS file: /var/cvs/busybox/shell/ash.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- ash.c 14 Apr 2004 17:51:31 -0000 1.97
+++ ash.c 22 Jun 2004 08:29:45 -0000 1.98
@@ -1446,7 +1446,13 @@
static void unsetfunc(const char *);
#ifdef CONFIG_ASH_MATH_SUPPORT
-static long dash_arith(const char *);
+#ifdef CONFIG_ASH_MATH_SUPPORT_64
+typedef int64_t arith_t;
+#else
+typedef long arith_t;
+#endif
+static arith_t dash_arith(const char *);
+static arith_t arith(const char *expr, int *perrcode);
#endif
#ifdef CONFIG_ASH_RANDOM_SUPPORT
@@ -4531,7 +4537,7 @@
static void expandmeta(struct strlist *, int);
static int patmatch(char *, const char *);
-static int cvtnum(long);
+static int cvtnum(arith_t);
static size_t esclen(const char *, const char *);
static char *scanleft(char *, char *, char *, char *, int, int);
static char *scanright(char *, char *, char *, char *, int, int);
@@ -5902,12 +5908,16 @@
*/
static int
-cvtnum(long num)
+cvtnum(arith_t num)
{
int len;
expdest = makestrspace(32, expdest);
+#ifdef CONFIG_ASH_MATH_SUPPORT_64
+ len = fmtstr(expdest, 32, "%lld", (long long) num);
+#else
len = fmtstr(expdest, 32, "%ld", num);
+#endif
STADJUST(len, expdest);
return len;
}
@@ -12488,10 +12498,10 @@
}
#ifdef CONFIG_ASH_MATH_SUPPORT
-static long
+static arith_t
dash_arith(const char *s)
{
- long result;
+ arith_t result;
int errcode = 0;
INTOFF;
@@ -12523,7 +12533,7 @@
letcmd(int argc, char **argv)
{
char **ap;
- long i;
+ arith_t i;
ap = argv + 1;
if(!*ap)
@@ -13094,8 +13104,8 @@
typedef struct ARITCH_VAR_NUM {
- long val;
- long contidional_second_val;
+ arith_t val;
+ arith_t contidional_second_val;
char contidional_second_val_initialized;
char *var; /* if NULL then is regular number,
else is variable name */
@@ -13152,9 +13162,9 @@
static inline int
arith_apply(operator op, v_n_t *numstack, v_n_t **numstackptr)
{
- long numptr_val;
+ int64_t numptr_val;
v_n_t *numptr_m1;
- long rez;
+ int64_t rez;
int ret_arith_lookup_val;
if (NUMPTR == numstack) goto err; /* There is no operator that can work
@@ -13280,7 +13290,7 @@
goto err;
}
/* save to shell variable */
- sprintf(buf, "%ld", rez);
+ sprintf(buf, "%lld", (long long) rez);
setvar(numptr_m1->var, buf, 0);
/* after saving, make previous value for v++ or v-- */
if(op == TOK_POST_INC)
@@ -13343,7 +13353,7 @@
#define endexpression &op_tokens[sizeof(op_tokens)-7]
-extern long arith (const char *expr, int *perrcode)
+static arith_t arith (const char *expr, int *perrcode)
{
register char arithval; /* Current character under analysis */
operator lasttok, op;
More information about the busybox-cvs
mailing list