[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
large integer formatting errors
From: |
Andrew J. Schorr |
Subject: |
large integer formatting errors |
Date: |
Mon, 6 Mar 2006 17:36:32 -0500 |
User-agent: |
Mutt/1.4.1i |
In case people are still following this thread, I am attaching
the latest version of my integer formatting patch that is
being committed to xgawk (http://sourceforge.net/projects/xmlgawk).
This fixes problems that are demonstrated by the attached test
case.
So, for example, unpatched gawk 3.1.5 on 32-bit linux does the following:
bash-2.05b$ ./gawk --version | head -1
GNU Awk 3.1.5
bash-2.05b$ ./gawk -f test/intformat.awk | diff test/intformat.ok -
gawk: /home/users/schorr/src/xgawk/cvs/test/intformat.awk:73: fatal error:
internal error
0a1,3
> (sprintf(0x%x,2^64) = 0x0)-1.84467e+19 = -1.84467e+19
> (sprintf(%d,2^64) = 0)-1.84467e+19 = -1.84467e+19
> (sprintf(0%o,2^64) = 00)-1.84467e+19 = -1.84467e+19
2d4
< 0000000000000000000000000000000000000000000000000000001
whereas with the patched version there should be no output.
Mon Mar 6 22:18:38 UTC 2006 Andrew J. Schorr <address@hidden>
* node.c (format_val): Test whether a numeric value is integral
simply by converting it to long and then back again, and checking
if the value matches. That's more robust than trying to test
whether the floating-point value is representable as a long.
* builtin.c (format_tree): Fix buffer overflow bug, off-by-one errors
in checking snprintf return codes, and use "%.0f" to implement "%d"
formatting. For octal or hex formatting, test whether the value
is integral by trying to convert back to floating point and seeing
if the value matches. This is more robust than trying to test
whether the floating-point value is representable as an integer.
Regards,
Andy
large_integer.patch
Description: Text document
intformat.awk
Description: Text document
intformat.ok
Description: Text document
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- large integer formatting errors,
Andrew J. Schorr <=