[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gawk number to string bug
From: |
Andrew J. Schorr |
Subject: |
Re: gawk number to string bug |
Date: |
Fri, 23 Dec 2005 16:48:05 -0500 |
User-agent: |
Mutt/1.4.1i |
On Fri, Dec 23, 2005 at 03:57:38PM -0500, Andrew J. Schorr wrote:
> If we can agree on this approach, then the next step is to use
> snprintf("%.0f") to implement "%d" formatting (using a 2nd dynamically
> growing buffer for the initial snprintf rendering)...
OK, I went ahead and did it. Here's the full patch to fix the
buffer overflow and implement "%.0f" formatting for "%d".
And here's the output of the test case on linux opteron:
$ ./gawk --lint 'BEGIN { x=2^60; for(i=60;i<=65;i++) { printf "2^%d= %s %d
%g\n",i,x,x,x; x*=2}}'
2^60= 1152921504606846976 1152921504606846976 1.15292e+18
2^61= 2305843009213693952 2305843009213693952 2.30584e+18
2^62= 4611686018427387904 4611686018427387904 4.61169e+18
2^63= 9.22337e+18 9223372036854775808 9.22337e+18
2^64= 1.84467e+19 18446744073709551616 1.84467e+19
2^65= 3.68935e+19 36893488147419103232 3.68935e+19
And on a 32-bit x86 linux box:
$ ./gawk --lint 'BEGIN { x=2^60; for(i=60;i<=65;i++) { printf "2^%d= %s %d
%g\n",i,x,x,x; x*=2}}'
2^60= 1.15292e+18 1152921504606846976 1.15292e+18
2^61= 2.30584e+18 2305843009213693952 2.30584e+18
2^62= 4.61169e+18 4611686018427387904 4.61169e+18
2^63= 9.22337e+18 9223372036854775808 9.22337e+18
2^64= 1.84467e+19 18446744073709551616 1.84467e+19
2^65= 3.68935e+19 36893488147419103232 3.68935e+19
It passes 'make check' on both platforms. Comments?
Note that this patch doesn't fix possible problems with "%o" or other
non-base-10 formatting.
Regards,
Andy
format_tree.patch
Description: Text document
- Re: gawk number to string bug, (continued)
- Re: gawk number to string bug, Paul Eggert, 2005/12/21
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/21
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/21
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/21
- Re: gawk number to string bug, Paul Eggert, 2005/12/21
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/22
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/23
- Re: gawk number to string bug,
Andrew J. Schorr <=
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/23
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/23
- Re: gawk number to string bug, Eli Zaretskii, 2005/12/24
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/24
- Re: gawk number to string bug, Eli Zaretskii, 2005/12/24
- Re: gawk number to string bug, Paul Jarc, 2005/12/24
- Re: gawk number to string bug, Paul Eggert, 2005/12/25
- Message not available
- Re: gawk number to string bug, Jürgen Kahrs, 2005/12/24
- Re: gawk number to string bug, Eli Zaretskii, 2005/12/25
- Re: gawk number to string bug, Andrew J. Schorr, 2005/12/25