[RFC] First draft of the POSIX locale::name patch

Paolo Carlini pcarlini@unitus.it
Wed Oct 2 08:55:00 GMT 2002


Hi,

you will find attached to this message a first rough draft,
tested without regressions together with my stock glibc2.2.5
on an x86-linux platform.

Among the many issues about which your feedback is needed:

1- _M_c_cats(__cat) contains the names of the various
   C categories present in recent glibc: arguably a
   rough approach.

   1a- I have no idea how to automatically adapt it (at
       configure time?!?) to different libc... Is this needed
       or in fact ;) the named locales machinery presently
       works well only for glibc anyway.

   1b- When the 6 additional categories stabilized? This
       is relevant for the new testcases too (some should be
       conditionalized to glibc >= 2.1 or >= 2.0??)

2- Is there a clean way to avoid strtok() in
   locale::_Impl::_Impl(const char*, size_t) not changing
   to much the infrastructure?

3- Should we consider the possibility of names longer than
   20 chars (see the _M_names array)?

4- Is it ok to use the non ANSI strdup() in
   locale::locale(const char *) and in
   locale::_Impl::_Impl(const char*, size_t)? Otherwise I
   could easily replace it with malloc + strlen calls.

Ciao,
Paolo.

//////////

        * include/bits/localefwd.h (class locale): Add static
        member _S_num_c_categories, encoding the number of
        additional C only categories.
        (class locale::_Impl): Add _M_c_cats.
        (class locale::_Impl::_M_names): Change to array of chars.
        (class locale::_Impl::_M_check_same_name):
        Use _S_num_c_categories, tweak.
        (locale::locale(const locale&, _Facet*)): Ditto.
        * src/locale.cc (locale::locale(const char* )):
        Rewrite to deal with the environment in a POSIX-compliant
        way while being thread safe.
        (locale::name()): Update to output POSIX environment strings.
        * src/localename.cc
        (locale::_Impl::_Impl(const _Impl&, size_t): Use
        _S_num_c_categories, tweak.
        (locale::_Impl::_Impl(facet**, size_t, bool)): Ditto.
        (locale::_Impl::_Impl(const char*, size_t)): Name
        each category individually, both C++ ones and C only.
        (locale::_Impl::_M_replace_categories): Use strcpy.
        * testsuite/22_locale/ctor_copy_dtor.cc: Add test04.
   
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_pnames
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20021002/c168e133/attachment.ksh>


More information about the Libstdc++ mailing list