Bug #1232
closedsetlocale switch to C is broken
90%
Description
Result is https://www.illumos.org/issues/1203 since perl uses setlocale(LC_NUMERIC, "C"); to check the version number.
Testcase:
$ cat test.c
#include <locale.h>
#include <stdio.h>
int main(void)
{
setlocale(LC_NUMERIC, "de_DE.UTF-8");
printf("%f\n",2.5);
setlocale(LC_NUMERIC, "C");
printf("%f\n",2.5);
setlocale(LC_NUMERIC, "en_US.UTF-8");
printf("%f\n",2.5);
}
$ CC -o test test.c
$ LC_NUMERIC=de_DE.UTF-8 ./test
2,500000
2,500000
2.500000
richlowe confirmed the bug: http://pastie.org/private/5e4e8xyzbh9jcjyremqlq
I set it to urgent, since it's a showstopper for OIs first Illumos based /dev Release
Files
Related issues
Updated by Jason King almost 12 years ago
- File locale.diff locale.diff added
- Assignee set to Jason King
- % Done changed from 0 to 90
Ugly historical mess...
SYSV defines _numeric (which appears to be exposed from libc) which has some locale data. *printf uses this for the decimal point when formatting floating point types (but amusingly enough, not for integer types).
It appears source:usr/src/lib/libc/port/locale/lnumeric.c@13407#52 is not updating numeric when it switches _to C/POSIX (as it is cached).
Attached is a diff that fixes that, as well as updates *printf to no longer depending on the legacy _numeric bits.
Updated by Jason King almost 12 years ago
- File locale.patch locale.patch added
- File test.c test.c added
Corrected patch attached.
Test case also attached.
Ran full nightly, resulting be w/ patch applied does not have issue.
Running test case with "LD_PRELOAD=./libc.so ./test" (where libc.so is the current Illumos libc) recreates the issue.
Updated by Garrett D'Amore almost 12 years ago
- Status changed from New to Resolved
Fixed in:
changeset: 13409:a4e1558c0599
tag: tip
user: Jason King <jason.brian.king+illumoshg@gmail.com>
date: Fri Jul 22 09:27:57 2011 -0700
description:
1232 setlocale switch to C is broken
Reviewed by: Gordon Ross <gwr@nexenta.com>
Reviewed by: Garret D'Amore <garrett@nexenta.com>
Reviewed by: Rich Lowe <richlowe@richlowe.net>
Approved by: Eric Schrock <Eric.Schrock@delphix.com>