diff options
Diffstat (limited to 'toys')
-rw-r--r-- | toys/pending/expr.c | 10 |
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)); } |