This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: std::collate hash() still broken
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: AWLaFramboise at aol dot com
- Cc: libstdc++ at gcc dot gnu dot org, aaronwl at rm-f dot net
- Date: Mon, 11 Feb 2002 10:29:50 -0800 (PST)
- Subject: Re: std::collate hash() still broken
Thanks! Please confirm this is what you'd like to have applied:
2002-02-11 Aaron W LaFramboise <AWLaFramboise@aol.com>
* include/bits/locale_facets.tcc (collate::do_hash): Fix.
* testsuite/22_locale/collate_members_char.cc (test03): New test.
* testsuite/22_locale/collate_members_wchar_t.cc (test03): Same.
Index: include/bits/locale_facets.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_facets.tcc,v
retrieving revision 1.59
diff -c -p -r1.59 locale_facets.tcc
*** locale_facets.tcc 2002/02/06 12:12:58 1.59
--- locale_facets.tcc 2002/02/11 18:27:24
*************** namespace std
*** 1855,1861 ****
unsigned long __val = 0;
for (; __lo < __hi; ++__lo)
__val = *__lo + ((__val << 7) |
! (__val >> (numeric_limits<unsigned long>::digits - 1)));
return static_cast<long>(__val);
}
--- 1855,1861 ----
unsigned long __val = 0;
for (; __lo < __hi; ++__lo)
__val = *__lo + ((__val << 7) |
! (__val >> (numeric_limits<unsigned long>::digits - 7)));
return static_cast<long>(__val);
}
Index: testsuite/22_locale/collate_members_char.cc
===================================================================
RCS file:
/cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/collate_members_char.cc,v
retrieving revision 1.4
diff -c -p -r1.4 collate_members_char.cc
*** collate_members_char.cc 2002/02/01 00:24:12 1.4
--- collate_members_char.cc 2002/02/11 18:27:26
*************** void test02()
*** 147,158 ****
#endif
}
int main()
{
test01();
test02();
return 0;
}
-
-
-
--- 147,170 ----
#endif
}
+ void test03()
+ {
+ bool test = true;
+ std::string str1("fffff");
+ std::string str2("ffffffffffff");
+
+ const std::locale cloc = std::locale::classic();
+ const std::collate<char> &col = std::use_facet<std::collate<char>
>(cloc);
+
+ long l1 = col.hash(str1.c_str(), str1.c_str() + str1.size());
+ long l2 = col.hash(str2.c_str(), str2.c_str() + str2.size());
+ VERIFY( l1 != l2 );
+ }
+
int main()
{
test01();
test02();
+ test03();
return 0;
}
Index: testsuite/22_locale/collate_members_wchar_t.cc
===================================================================
RCS file:
/cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/collate_members_wchar_t.cc,v
retrieving revision 1.4
diff -c -p -r1.4 collate_members_wchar_t.cc
*** collate_members_wchar_t.cc 2002/02/01 00:24:12 1.4
--- collate_members_wchar_t.cc 2002/02/11 18:27:27
*************** void test02()
*** 146,151 ****
--- 146,165 ----
}
#endif
}
+
+ void test03()
+ {
+ bool test = true;
+ std::wstring str1(L"fffff");
+ std::wstring str2(L"ffffffffffff");
+
+ const std::locale cloc = std::locale::classic();
+ const std::collate<wchar_t> &col =
std::use_facet<std::collate<wchar_t> >(cloc);
+
+ long l1 = col.hash(str1.c_str(), str1.c_str() + str1.size());
+ long l2 = col.hash(str2.c_str(), str2.c_str() + str2.size());
+ VERIFY( l1 != l2 );
+ }
#endif
int main()
*************** int main()
*** 153,162 ****
#if _GLIBCPP_USE_WCHAR_T
test01();
test02();
#endif
return 0;
}
-
-
-
-
--- 167,173 ----
#if _GLIBCPP_USE_WCHAR_T
test01();
test02();
+ test03();
#endif
return 0;
}