[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gawk: fix for x86-64
From: |
Jean-Marc Saffroy |
Subject: |
gawk: fix for x86-64 |
Date: |
Thu, 29 Apr 2010 01:08:31 +0200 (CEST) |
Hi,
I saw that some tests in the gawk (3.1.7) test suite fail on x86-64:
$ make check -C test/ &> log
$ grep differ: log
./double1.ok _double1 differ: char 1, line 1
./double2.ok _double2 differ: char 247, line 4
./intformat.ok _intformat differ: char 1, line 1
The patch below fixes these problems. On x86-64, LONG_MAX is actually
64-bit wide, and comparing a double seems to lose accuracy in some cases
(eg. when the double contains something close to LONG_MAX but with a
53-bit mantissa).
Cheers,
Jean-Marc
--
address@hidden
diff -r d87a84edf71e node.c
--- a/node.c Wed Apr 28 18:47:29 2010 +0200
+++ b/node.c Thu Apr 29 00:16:24 2010 +0200
@@ -212,7 +212,7 @@
/* not an integral value, or out of range */
if ((val = double_to_int(s->numbr)) != s->numbr
- || val < LONG_MIN || val > LONG_MAX) {
+ || val < INT_MIN || val > INT_MAX) {
/*
* Once upon a time, if GFMT_WORKAROUND wasn't defined,
* we just blindly did this:
@@ -253,13 +253,13 @@
goto no_malloc;
} else {
/* integral value */
- /* force conversion to long only once */
- register long num = (long) val;
+ /* force conversion to int only once */
+ int num = (long) val;
if (num < NVAL && num >= 0) {
sp = (char *) values[num];
s->stlen = 1;
} else {
- (void) sprintf(sp, "%ld", num);
+ (void) sprintf(sp, "%d", num);
s->stlen = strlen(sp);
}
s->stfmt = -1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gawk: fix for x86-64,
Jean-Marc Saffroy <=