This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] setlocale changes


Jakub Jelinek <jakub@redhat.com> writes:

> IBM JDK does basically:
> 
> char *p = setlocale(LC_CTYPE, "");
> setlocale(LC_ALL, p);

This is wrong.  The specification explicitly talks about restoring.
This is not restoring.  The value for LC_CTYPE is used for LC_ALL.

> /* use p - as use p you could consider e.g. setlocale(LC_CTYPE, p); */

setlocale(LC_CTYPE, p);

This should work.  Some platforms return strings like

   "LC_CTYPE=foo"

which make it obvious that the value cannot be used for anything but
LC_CTYPE.

> char *p = setlocale(LC_ALL, "");
> setlocale(LC_CTYPE, "C");
> setlocale(LC_ALL, p);
> then I can add that easily too

This is wrong as well.  You have to use strdup().

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]