This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Doubts about uselocale semantics (aka, libstdc++/12859)
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libc-alpha at sources dot redhat dot com
- Cc: drepper at redhat dot com, roland at redhat dot com
- Date: Fri, 31 Oct 2003 22:13:33 +0100
- Subject: Doubts about uselocale semantics (aka, libstdc++/12859)
Hi,
we have got this PR which boils down to this pure "C" testcase:
#define _GNU_SOURCE 1
#include <locale.h>
#include <stdio.h>
int main()
{
__locale_t loc_new, loc_old;
printf("%d\n", isalpha(0xE4)); // 0
setlocale( LC_ALL, "de_DE" );
printf("%d\n", isalpha(0xE4)); // 1024
loc_new = newlocale(1 << LC_ALL, "C", 0);
loc_old = uselocale(loc_new);
printf("%d\n", isalpha(0xE4)); // 0
uselocale(loc_old);
printf("%d\n", isalpha(0xE4)); // 0 instead of 1024!
freelocale(loc_new);
return 0;
}
I have read and re-read the relevant sections of "Thread-aware Locale
Model" (par 3.4, in particular) and really need your help: why the
second uselocale doesn't restore the "de_DE" locale for the current
thread?
In my naive understanding setlocale changes the global locale, that is
the locale used by all the threads by default, to "de_DE", then the
first uselocale changes the locale used by the current thread to "C",
which should then be restored to "de_DE" by the final uselocale.
What I'm missing? How should we use uselocale for our purposes?
Thanks in advance!
Paolo.