This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFC] collate_members_wchar_t.cc
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Ulrich Drepper <drepper at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Sat, 09 Mar 2002 21:47:05 +0100
- Subject: Re: [RFC] collate_members_wchar_t.cc
- References: <1015703700.16743.628.camel@myware.mynet>
Ulrich Drepper wrote:
> This is definitely needed. The C++ standard indeed requires
> normalization of the return value for do_compare. ISO C does not (with
> good reasons) for strcoll and wcscoll. But the conditionals are kind of
> bad. I'd suggest
>
> template<>
> int
> collate<wchar_t>::_M_compare_helper(const wchar_t* __one,
> const wchar_t* __two) const
> {
> int __cmp = wcscoll(__one, __two);
> return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
> }
>
> Compiled for the right platform it won't require any jumps. Modern gcc
> versions will optimize your code pretty well but it's not as good as
> this code.
>
> You have to use the same sequence for the strcoll call.
Thanks. I will implement this.
> > would fix only the assert at line 129, /not/ that at 107, where i1 ==
> 20 (vs i1
> > == -1 for the corresponding char test).
>
> On what system do you run this? I get -1 for the C equivalent
>
> wcscoll (L"Äuglein", L"Augment")
>
> It might well be the case that you're stumbling accross a problem with
> the libc code.
Well, I'm running on i686-pc-linux-gnu, linux2.4.16, and a stock glibc2.2.5
built with gcc2.95.3+patches.
Are there known bugs in this setup for the stock glibc2.2.5 (and the full set of
locales installed with the usual `make localedata/install-locales') ??
Ciao, Paolo.