This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] Fix libstdc++/38365
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 02 Dec 2008 16:02:06 +0100
- Subject: Re: [v3] Fix libstdc++/38365
- References: <493514C5.7050407@oracle.com>
Hi again,
> tested x86_64-linux, committed to mainline.
>
Upon submitter's suggestion, I fixed the issue in a different way.
Paolo.
/////////////////
2008-12-02 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/38365 (cont)
* src/localename.cc (locale::locale(const locale&, const locale&,
category)): Revert last changes.
* src/localename.cc (locale::_Impl::_M_replace_categories(const
_Impl*, category)): Fix here instead; rework.
Index: src/localename.cc
===================================================================
*** src/localename.cc (revision 142349)
--- src/localename.cc (working copy)
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 157,170 ****
locale::locale(const locale& __base, const locale& __add, category __cat)
: _M_impl(0)
! {
! _M_coalesce(__base, __add, __cat);
! if (!__base._M_impl->_M_names[0] || !__add._M_impl->_M_names[0])
! {
! delete [] _M_impl->_M_names[0];
! _M_impl->_M_names[0] = 0; // Unnamed.
! }
! }
void
locale::_M_coalesce(const locale& __base, const locale& __add,
--- 157,163 ----
locale::locale(const locale& __base, const locale& __add, category __cat)
: _M_impl(0)
! { _M_coalesce(__base, __add, __cat); }
void
locale::_M_coalesce(const locale& __base, const locale& __add,
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 274,302 ****
_M_replace_categories(const _Impl* __imp, category __cat)
{
category __mask = 1;
! const bool __have_names = _M_names[0] && __imp->_M_names[0];
! for (size_t __ix = 0; __ix < _S_categories_size; ++__ix, __mask <<= 1)
{
! if (__mask & __cat)
{
! // Need to replace entry in _M_facets with other locale's info.
! _M_replace_category(__imp, _S_facet_categories[__ix]);
! // If both have names, go ahead and mangle.
! if (__have_names)
{
! if (!_M_names[1])
! {
! // A full set of _M_names must be prepared, all identical
! // to _M_names[0] to begin with. Then, below, a few will
! // be replaced by the corresponding __imp->_M_names. I.e.,
! // not a "simple" locale anymore (see locale::operator==).
! const size_t __len = std::strlen(_M_names[0]) + 1;
! for (size_t __i = 1; __i < _S_categories_size; ++__i)
! {
! _M_names[__i] = new char[__len];
! std::memcpy(_M_names[__i], _M_names[0], __len);
! }
! }
// FIXME: Hack for libstdc++/29217: the numerical encodings
// of the time and collate categories are swapped vs the
--- 267,309 ----
_M_replace_categories(const _Impl* __imp, category __cat)
{
category __mask = 1;
! if (!_M_names[0] || !__imp->_M_names[0])
! {
! if (_M_names[0])
! {
! delete [] _M_names[0];
! _M_names[0] = 0; // Unnamed.
! }
!
! for (size_t __ix = 0; __ix < _S_categories_size; ++__ix, __mask <<= 1)
! {
! if (__mask & __cat)
! // Need to replace entry in _M_facets with other locale's info.
! _M_replace_category(__imp, _S_facet_categories[__ix]);
! }
! }
! else
{
! if (!_M_names[1])
! {
! // A full set of _M_names must be prepared, all identical
! // to _M_names[0] to begin with. Then, below, a few will
! // be replaced by the corresponding __imp->_M_names. I.e.,
! // not a "simple" locale anymore (see locale::operator==).
! const size_t __len = std::strlen(_M_names[0]) + 1;
! for (size_t __i = 1; __i < _S_categories_size; ++__i)
! {
! _M_names[__i] = new char[__len];
! std::memcpy(_M_names[__i], _M_names[0], __len);
! }
! }
!
! for (size_t __ix = 0; __ix < _S_categories_size; ++__ix, __mask <<= 1)
{
! if (__mask & __cat)
{
! // Need to replace entry in _M_facets with other locale's info.
! _M_replace_category(__imp, _S_facet_categories[__ix]);
// FIXME: Hack for libstdc++/29217: the numerical encodings
// of the time and collate categories are swapped vs the