summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2013-07-20 21:23:01 +0200
committerDenys Vlasenko2013-07-20 21:23:01 +0200
commit1390a010b60cbb5adad4e4c56a3613122b4298c6 (patch)
tree96affea1bd133da45e4654bb6743a588e1043ec1
parent5e87e8aebb60bc87d3dd6e07814c7c3b0e8dbbb2 (diff)
downloadbusybox-1390a010b60cbb5adad4e4c56a3613122b4298c6.zip
busybox-1390a010b60cbb5adad4e4c56a3613122b4298c6.tar.gz
awk: use "long long" as integer type, not "int"
Testcase: awk "BEGIN{n=(2^31)-1; print n, int(n), n%1, ++n, int(n), n%1}" 2147483647 2147483647 0 2147483648 2147483648 0 (last three values weren't showing right) function old new delta evaluate 3444 3458 +14 fmt_num 221 230 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/awk.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 0b573a0..a2e2021 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -190,7 +190,7 @@ typedef struct tsplitter_s {
/* combined token classes */
#define TC_BINOP (TC_BINOPX | TC_COMMA | TC_PIPE | TC_IN)
-#define TC_UNARYOP (TC_UOPPRE | TC_UOPPOST)
+//#define TC_UNARYOP (TC_UOPPRE | TC_UOPPOST)
#define TC_OPERAND (TC_VARIABLE | TC_ARRAY | TC_FUNCTION \
| TC_BUILTIN | TC_GETLINE | TC_SEQSTART | TC_STRING | TC_NUMBER)
@@ -2015,8 +2015,8 @@ static int fmt_num(char *b, int size, const char *format, double n, int int_as_i
char c;
const char *s = format;
- if (int_as_int && n == (int)n) {
- r = snprintf(b, size, "%d", (int)n);
+ if (int_as_int && n == (long long)n) {
+ r = snprintf(b, size, "%lld", (long long)n);
} else {
do { c = *s; } while (c && *++s);
if (strchr("diouxX", c)) {
@@ -2733,7 +2733,7 @@ static var *evaluate(node *op, var *res)
switch (opn) {
case F_in:
- R_d = (int)L_d;
+ R_d = (long long)L_d;
break;
case F_rn:
@@ -2931,7 +2931,7 @@ static var *evaluate(node *op, var *res)
case '%':
if (R_d == 0)
syntax_error(EMSG_DIV_BY_ZERO);
- L_d -= (int)(L_d / R_d) * R_d;
+ L_d -= (long long)(L_d / R_d) * R_d;
break;
}
debug_printf_eval("BINARY/REPLACE result:%f\n", L_d);