Bug 24855

Summary: Localization should not be done by fprintf()
Product: [Retired] Red Hat Raw Hide Reporter: Enrico Scholz <rh-bugzilla>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.0CC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-01-24 16:01:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Enrico Scholz 2001-01-24 16:01:17 UTC
The follwing program gives different output in different languages:

------ fp.c --------
#include <stdio.h>
#include <locale.h>

int main()
{
        setlocale (LC_ALL, "");
        printf("%f\n", 42.0);
}
-----------------

$ gcc -std=c99 ~/tmp/fp.c
$ LANG=C ./a.out 
42.000000
$ LANG=de_DE ./a.out 
42,000000


The C99-draft says at 7.19.6.1/#8:

-------------------
f,F     A  double argument representing a (finite) floating-
               point number is converted to decimal notation in the
               style  [-]ddd.ddd,
-------------------

so the latter output (with a comma instead of a period)  is wrong.

This behavior breaks a lot of programs (e.g. doxygen generates TeX with
measure-units like 1,6666cm)

Comment 1 Enrico Scholz 2001-01-24 16:24:55 UTC
Sorry, behavior if glibc is correct (I have missed 7.1.1/#); the other programs
are wrong so I have to write a lot of other bugreports.