I saw that my 1st patch was not applied, so better because I have
another, it correct the bug and remove getn(const char *s) function
Malek.
--- busybox/coreutils/test.c.orig 2007-05-24 23:01:44.000000000 +0200
+++ busybox/coreutils/test.c 2007-05-26 11:48:52.000000000 +0200
@@ -150,8 +150,10 @@ enum { NUM_OPS = sizeof(ops) / sizeof(op
#if ENABLE_FEATURE_TEST_64
typedef int64_t arith_t;
+#define test_xatoi(x) xatoll(x)
#else
typedef int arith_t;
+#define test_xatoi(x) xatol(x)
#endif
/* Cannot eliminate these static data (do the G trick)
@@ -169,7 +171,6 @@ static arith_t nexpr(enum token n);
static int binop(void);
static arith_t primary(enum token n);
static int filstat(char *nm, enum token mode);
-static arith_t getn(const char *s);
/* UNUSED
static int newerf(const char *f1, const char *f2);
static int olderf(const char *f1, const char *f2);
@@ -181,7 +182,7 @@ static void initialize_group_array(void)
int bb_test(int argc, char **argv)
{
- int res;
+ arith_t res;
if (LONE_CHAR(argv[0], '[')) {
--argc;
@@ -303,7 +304,7 @@ static arith_t primary(enum token n)
if (n == STRNZ)
return t_wp[0][0] != '\0';
if (n == FILTT)
- return isatty(getn(*t_wp));
+ return isatty(test_xatoi(*t_wp));
return filstat(*t_wp, n);
}
@@ -319,7 +320,7 @@ static int binop(void)
{
const char *opnd1, *opnd2;
struct t_op const *op;
- smallint val1, val2;
+ arith_t val1, val2;
opnd1 = *t_wp;
(void) t_lex(*++t_wp);
@@ -330,8 +331,8 @@ static int binop(void)
syntax(op->op_text, "argument expected");
if (is_int_op(op->op_num)) {
- val1 = getn(opnd1);
- val2 = getn(opnd2);
+ val1 = test_xatoi(opnd1);
+ val2 = test_xatoi(opnd2);
if (op->op_num == INTEQ)
return val1 == val2;
if (op->op_num == INTNE)
@@ -468,33 +469,6 @@ static enum token t_lex(char *s)
return OPERAND;
}
-/* atoi with error detection */
-//XXX: FIXME: duplicate of existing libbb function?
-static arith_t getn(const char *s)
-{
- char *p;
-#if ENABLE_FEATURE_TEST_64
- long long r;
-#else
- long r;
-#endif
-
- errno = 0;
-#if ENABLE_FEATURE_TEST_64
- r = strtoll(s, &p, 10);
-#else
- r = strtol(s, &p, 10);
-#endif
-
- if (errno != 0)
- syntax(s, "out of range");
-
- if (*(skip_whitespace(p)))
- syntax(s, "bad number");
-
- return r;
-}
-
/* UNUSED
static int newerf(const char *f1, const char *f2)
{
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox