aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/expr.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-06-15 00:49:06 -0500
committerRob Landley <rob@landley.net>2013-06-15 00:49:06 -0500
commitbc9cfe08cfa2c47b2d106eda7b5d0ecc73f47238 (patch)
tree64dc550d1e9a8ebf9b8afb454d8f61d0a7f571ea /toys/pending/expr.c
parentfdc0a0e74f2ac366399c152196a2498a0e98ad0a (diff)
downloadtoybox-bc9cfe08cfa2c47b2d106eda7b5d0ecc73f47238.tar.gz
Force 64 bit math in expr, from Daniel Verkamp
Diffstat (limited to 'toys/pending/expr.c')
-rw-r--r--toys/pending/expr.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/toys/pending/expr.c b/toys/pending/expr.c
index 949bb664..dd27d58f 100644
--- a/toys/pending/expr.c
+++ b/toys/pending/expr.c
@@ -36,7 +36,7 @@ GLOBALS(
// If s is not NULL, the value is a string (s).
struct value {
char *s;
- long i;
+ long long i;
};
static void parse_expr(struct value *ret, struct value *v);
@@ -57,7 +57,7 @@ static void get_value(struct value *v)
arg = toys.optargs[TT.argidx++];
- v->i = strtol(arg, &endp, 10);
+ v->i = strtoll(arg, &endp, 10);
v->s = *endp ? arg : NULL;
}
@@ -79,10 +79,10 @@ static int is_zero(const struct value *v)
return ((v->s && *v->s == '\0') || v->i == 0);
}
-static char *num_to_str(long num)
+static char *num_to_str(long long num)
{
static char num_buf[21];
- snprintf(num_buf, sizeof(num_buf), "%ld", num);
+ snprintf(num_buf, sizeof(num_buf), "%lld", num);
return num_buf;
}
@@ -266,7 +266,7 @@ void expr_main(void)
if (!tok.s || *tok.s) error_exit("syntax error"); // final token should be end of expression
if (ret.s) printf("%s\n", ret.s);
- else printf("%ld\n", ret.i);
+ else printf("%lld\n", ret.i);
exit(is_zero(&ret));
}