bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

locale-related printf bug when using formats with thousands grouping cha


From: Andrew J. Schorr
Subject: locale-related printf bug when using formats with thousands grouping character
Date: Tue, 11 Jan 2011 22:31:26 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Using gawk 3.1.8 on Fedora 13 64-bit linux, I see this:

bash-4.1$ (echo 1000000; echo 999999.9998071828) | gawk -v "sq='" '{printf "%" 
sq ".2f\n", $1}'
1,000,000.00
,000,000.00

Note that the 2nd row is missing the leading 1.  I ran it under valgrind,
and it is clean.

bash-4.1$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE=C
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

bash-4.1$ (echo 1000000; echo 999999.9998071828) | LC_ALL=C gawk -v "sq='" 
'{printf "%" sq ".2f\n", $1}'
1000000.00
1000000.00

I think the problem exists in the current development version as well.
Unfortunately, I haven't had a chance to troubleshoot this.

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]