[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gawk: Locale-dependant bug with string to floating point conversion
From: |
Jim Meyering |
Subject: |
gawk: Locale-dependant bug with string to floating point conversion |
Date: |
Thu, 29 Apr 2004 10:28:30 +0200 |
Package: gawk
Version: 1:3.1.3-3
Severity: normal
Tags: patch
This bug was originally reported by Michael Mauch here:
http://mail.gnu.org/archive/html/bug-gnu-utils/2004-04/msg00060.html
It also affects string-to-floating-point conversions.
This works fine in the C locale:
$ LC_ALL=c gawk 'BEGIN {print 0+".1"}'
0.1
But not in some other locales (assuming you have them installed):
$ LC_ALL=af_ZA gawk 'BEGIN {print 0+".1", 0+",1"}'
0 0
$ address@hidden gawk 'BEGIN {print 0+".1", 0+",1"}'
0 0
With the fix below, it works:
$ LC_ALL=af_ZA ./gawk 'BEGIN {print 0+".1", 0+",1"}'
0 0,1
First, gawk is mistakenly using a replacement strtod function,
when the libc one would work just fine.
Then, the replacement function hard-codes `.' as the decimal point.
When running configure, I see this:
checking for strtod with C89 semantics... no
Gawk's configure-time test for a working strtod seems to be reversed.
Here's a patch to make gawk use libc's strtod when possible.
Eventually, gawk's replacement strtod should be fixed to honor the
locale-specified decimal point.
2004-04-29 Jim Meyering <address@hidden>
* strtod.m4 (GAWK_FUNC_STRTOD_C89): Fix reversed test.
--- strtod.m4.~1~ 2004-04-29 08:57:29.232172928 +0200
+++ strtod.m4 2004-04-29 08:57:50.402123674 +0200
@@ -45,7 +45,7 @@ main ()
char *str = "0x345a";
d = strtod(str, 0);
- if (d == 0)
+ if (d == 13402)
exit (0);
else
exit (1);
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.5
Locale: LANG=C, LC_CTYPE=C
Versions of packages gawk depends on:
ii libc6 2.3.2.ds1-12 GNU C Library: Shared libraries an
-- no debconf information