This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Fix collate::do_tranform
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Sat, 9 Mar 2002 08:11:42 -0800 (PST)
- Subject: Re: [PATCH] Fix collate::do_tranform
> So, I rewrote it, closely following the detailed glibc2.2.5 docs, which comes
> complete with an example of correct use of strxfrm:
>
> template<typename _CharT>
> typename collate<_CharT>::string_type
> collate<_CharT>::
> do_transform(const _CharT* __lo, const _CharT* __hi) const
> {
> size_t __len = (__hi - __lo) * 2;
> // First try a buffer perhaps big enough.
> _CharT* __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
> size_t __res = _M_transform_helper(__c, __lo, __len);
> // If the buffer was not large enough, try again with the correct size.
> if (__res >= __len)
> {
> _CharT* __c2 =
> static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * (__res + 1)));
> size_t __res2 = _M_transform_helper(__c2, __lo, __res + 1);
> return string_type(__c2);
> }
> return string_type(__c);
> }
>
> On my system (i686-pc-linux-gnu, binutils2.11.2 -> no versioning) this fixes:
>
> XPASS: 22_locale/collate_members_char.cc execution test
>
> down to 2 expected failures (yeah!):
This is good news. Do you know what's up with the collate_members_wchar_t
fail?
> Is the patch OK for mainline and branch?
Yes. Can you wait a bit for the branch check-in though? I need to move my
subdir patch over first.