This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: using xlocale to implement std::locale class


Jonathan Wakely writes:

On 4 May 2011 07:07, Marc Glisse wrote:
> On Wed, 4 May 2011, Takeshi Kobayakawa wrote:
>
>> Are there any effort to handle std::locale class with xlocale(extended
>> locale support)? (here, xlocale.h has nothing to do with XLib' Xlocale.h)
>
> There has been for a while, in libstdc++-v3/config/locale/gnu/.
>
>> I am a navite linux programmers, but when I tried to port my code to
>> darwin(MacOSX), I found one can not create locale object other than "C"
>> locale. The libstdc++ seems to deal with darwin, so I would like to see
>> std::locale object working better on darwin.
>
> I didn't know things were that bad...

Locales need a lot of work everywhere except GNU/Linux.  There are
thread safety issues, 64-bit issues, and failures to handle some
wchar_t character classes on some platforms.

The messages facet is broken everywhere, including GNU/Linux. do_open() calls textdomain(), which sets the global message catalog domain, and do_get() calls gettext(), which uses the global message catalog domain.


Try to instantiate a second messages facet for a different catalog, then your first messages facet instance (whether it was open in the same thread or a different thread) is now bricked.

This effectively means that shared libraries cannot use the C++ library messages facet to access a message catalog for their own domain, because that would break the main app, if it also uses the messages facet.

The messages facet should not call textdomain(), but save the catalog name in a class member, and do_get() should use the thread-safe dgettext(), without stomping the global message catalog.

Attachment: pgp00000.pgp
Description: PGP signature


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