[PATCH] setlocale changes
Ulrich Drepper
drepper@redhat.com
Tue Jan 2 09:55:00 GMT 2001
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 `------------------------
More information about the Libc-hacker
mailing list