This is the mail archive of the
mailing list for the libstdc++ project.
Re: [RFC] setlocale(LC_ALL) vs setlocale(LC_NUMERIC)
- From: Martin Sebor <sebor at roguewave dot com>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 28 Jan 2005 09:54:15 -0700
- Subject: Re: [RFC] setlocale(LC_ALL) vs setlocale(LC_NUMERIC)
- References: <41F8FD82.firstname.lastname@example.org>
Paolo Carlini wrote:
in order to fix (in 3_4-branch, at least), PR19642, I'd like to know
can assume the below to succeed in "most" libc implementations: seems the
case for glibc, but don't believe it's C standard mandated behavr:
char* save = setlocale(LC_ALL, "de_DE");
assert( !save || !strcmp(setlocale(LC_NUMERIC, NULL), "de_DE"));
assuming, of course, setlocale(LC_NUMERIC, NULL) returns something
like "de_DE", or "C", and so on, we can test at the outset for that.
I expected to find at least some locales where this wasn't true
(e.g., those that use aliases like "german" or "de" for "de_DE)
but I ended up with none on any of the machines I tried (which
included AIX, HP-UX, Linux, Solaris, and Tru64). So while I
wouldn't want to bet my paycheck on it I think it might be
a pretty safe assumption to make in a test suite.