]> ruin.nu Git - popboot.git/commitdiff
changing back, and including locale
authorMichael Andreen <harv@ruin.nu>
Wed, 1 Jun 2005 09:20:33 +0000 (09:20 +0000)
committerMichael Andreen <harv@ruin.nu>
Wed, 1 Jun 2005 09:20:33 +0000 (09:20 +0000)
action.h

index a0a1173e4cc0ce9ff6507f615e8c911ed529bb7c..32fbcb986ad912d43b1c675d878f298ebce5eaf9 100644 (file)
--- a/action.h
+++ b/action.h
@@ -4,6 +4,7 @@
 #include <vector>
 #include <string>
 #include <ext/hash_map>
+#include <locale>
 
 typedef std::vector<std::string> Literals;
 typedef __gnu_cxx::hash_map<std::string,bool> Preconditions;
@@ -15,10 +16,9 @@ namespace __gnu_cxx {
                struct hash< std::basic_string<CharT, Traits, Alloc> > {
                        size_t operator()(const std::basic_string<CharT, Traits, Alloc>& s) const {
 
-                               size_t hash = 0;
-                               for (unsigned int i = 0; i < s.size(); ++i)
-                                       hash += static_cast<size_t>(s[i]);
-                               return hash + s.size();
+                               const std::collate<CharT>& c = std::use_facet< std::collate<CharT> >(std::locale());
+
+                               return c.hash(s.c_str(), s.c_str() + s.size());
 
                        }
 
@@ -29,10 +29,9 @@ namespace __gnu_cxx {
 
                        size_t operator()(const std::basic_string<CharT, Traits, Alloc>& s) const {
 
-                               size_t hash = 0;
-                               for (unsigned int i = 0; i < s.size(); ++i)
-                                       hash += static_cast<size_t>(s[i]);
-                               return hash + s.size();
+                               const std::collate<CharT>& c = std::use_facet< std::collate<CharT> >(std::locale());
+
+                               return c.hash(s.c_str(), s.c_str() + s.size());
                        }
 
                };