This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: The behavor of printing out libc message catalog without calling setlocale()
- To: GOTO Masanori <gotom at debian dot or dot jp>
- Subject: Re: The behavor of printing out libc message catalog without calling setlocale()
- From: Markus Kuhn <Markus dot Kuhn at cl dot cam dot ac dot uk>
- Date: Tue, 07 Nov 2000 19:15:00 +0000
- cc: libc-alpha at sourceware dot cygnus dot com
GOTO Masanori wrote on 2000-11-07 18:40 UTC:
> > Second, calling setlocale() is always
> > necessary if any of the locale-related environment variables is to be
> > used (LC_ALL, LC_xxx, LANG).
>
> What standard is it described?
ISO/IEC 9899:1999 (ISO C99) says in §7.11.1.1:
[#3] A value of "C" for locale specifies the minimal
environment for C translation; a value of "" for locale
specifies the locale-specific native environment. Other
implementation-defined strings may be passed as the second
argument to setlocale.
[#4] At program startup, the equivalent of
setlocale(LC_ALL, "C");
is executed.
> If calling setlocale() is needed anytime when we set locale-related
> env variables, we must write setlocale() into hello.c ?!
If you want the locale-dependent functions (such as gettext) used in
hello.c to follow any locale other than "C", then you definitely have to
call setlocale().
> # Why don't you have setlocale(LC_ALL,"") in crt0.o? :-)
Because this would be in violation of the above paragraph of ISO C, and
we like to obey the holly scripture.
Markus
--
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org, WWW: <http://www.cl.cam.ac.uk/~mgk25/>