This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] Fix _M_compare_helper to normalize values
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 11 Mar 2002 01:00:03 +0100
- Subject: [v3] Fix _M_compare_helper to normalize values
Hi,
the following patch, fixes part of the issue with collate_members_wchar_t.cc.
Tested i686-pc-linux-gnu, approved by Benjamin Kosnik, committed.
Ciao, Paolo.
///////////////
2002-03-10 Ulrich Drepper <drepper@redhat.com>
Paolo Carlini <pcarlini@unitus.it>
* config/locale/generic/collate_members.cc
(collate<char,wchar_t>::_M_compare_helper): normalize
values returned by strcoll and wcscoll.
* config/locale/gnu/collate_members.cc
(collate<char,wchar_t>::_M_compare_helper): ditto
for __strcoll_l and __wcscoll_l.
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/locale/generic/collate_members.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- gcc/libstdc++-v3/config/locale/generic/collate_members.cc 2002/03/09
02:16:32 1.1
+++ gcc/libstdc++-v3/config/locale/generic/collate_members.cc 2002/03/10
23:48:24 1.2
@@ -43,7 +43,10 @@
int
collate<char>::_M_compare_helper(const char* __one,
const char* __two) const
- { return strcoll(__one, __two); }
+ {
+ int __cmp = strcoll(__one, __two);
+ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
+ }
template<>
size_t
@@ -56,7 +59,10 @@
int
collate<wchar_t>::_M_compare_helper(const wchar_t* __one,
const wchar_t* __two) const
- { return wcscoll(__one, __two); }
+ {
+ int __cmp = wcscoll(__one, __two);
+ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
+ }
template<>
size_t
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/locale/gnu/collate_members.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- gcc/libstdc++-v3/config/locale/gnu/collate_members.cc 2002/03/09
02:16:33 1.1
+++ gcc/libstdc++-v3/config/locale/gnu/collate_members.cc 2002/03/10
23:48:25 1.2
@@ -43,7 +43,10 @@
int
collate<char>::_M_compare_helper(const char* __one,
const char* __two) const
- { return __strcoll_l(__one, __two, _M_c_locale_collate); }
+ {
+ int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
+ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
+ }
template<>
size_t
@@ -56,7 +59,10 @@
int
collate<wchar_t>::_M_compare_helper(const wchar_t* __one,
const wchar_t* __two) const
- { return __wcscoll_l(__one, __two, _M_c_locale_collate); }
+ {
+ int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
+ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
+ }
template<>
size_t