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: [RFC] collate_members_wchar_t.cc


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.



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