summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-06-12 19:29:42 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-06-12 19:29:42 +0000
commitb3e3b1f14e12b4b0a395ef8e2a4848f132e2c22b (patch)
tree18a4627fa652e12055acf88bfac758df0ad85d89
parent06a25cab68a58a4c9e985a394590b3288de33723 (diff)
Now builds ok on gcc 4.3, not tested fully. Also UGLY, oh we hate you GCC, why couldnt you just use TR1 from the start???
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9894 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/hashcomp.h12
-rw-r--r--include/inspircd.h2
-rw-r--r--include/typedefs.h23
-rw-r--r--src/configreader.cpp2
-rw-r--r--src/dns.cpp4
-rw-r--r--src/hashcomp.cpp18
-rw-r--r--src/modules/m_messageflood.cpp4
-rw-r--r--src/modules/m_spanningtree/utils.h8
-rw-r--r--src/modules/m_stripcolor.cpp2
9 files changed, 41 insertions, 34 deletions
diff --git a/include/hashcomp.h b/include/hashcomp.h
index e93875e3e..777c4fe0e 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -688,6 +688,7 @@ BEGIN_HASHMAP_NAMESPACE
size_t operator()(const std::string & s) const;
};
#else
+
template<> struct hash<irc::string>
{
/** Hash an irc::string using RFC1459 case sensitivity rules
@@ -697,14 +698,17 @@ BEGIN_HASHMAP_NAMESPACE
size_t operator()(const irc::string &s) const;
};
+ /* XXX FIXME: Implement a hash function overriding std::string's that works with TR1! */
+
+#ifdef HASHMAP_DEPRECATED
+ struct insensitive
+#else
template<> struct hash<std::string>
+#endif
{
- /** Hash a std::string using RFC1459 case sensitivity rules
- * @param s A string to hash
- * @return The hash value
- */
size_t operator()(const std::string &s) const;
};
+
#endif
/** Convert a string to lower case respecting RFC1459
diff --git a/include/inspircd.h b/include/inspircd.h
index 9d7c8e6e1..e1048f114 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -34,6 +34,8 @@
// Required system headers.
#include <time.h>
#include <stdarg.h>
+#include <algorithm>
+#include <cmath>
#include "inspircd_config.h"
#include "uid.h"
diff --git a/include/typedefs.h b/include/typedefs.h
index d80e578de..5caebf0f1 100644
--- a/include/typedefs.h
+++ b/include/typedefs.h
@@ -15,19 +15,18 @@
#define __TYPEDEF_H__
#ifndef WIN32
-/** User hash (POSIX systems with GCC)
- */
-typedef nspace::hash_map<std::string, User*, nspace::hash<std::string>, irc::StrHashComp> user_hash;
-/** Channel hash (POSIX systems with GCC)
- */
-typedef nspace::hash_map<std::string, Channel*, nspace::hash<std::string>, irc::StrHashComp> chan_hash;
+
+ #ifdef HASHMAP_DEPRECATED
+ typedef nspace::hash_map<std::string, User*, nspace::insensitive, irc::StrHashComp> user_hash;
+ typedef nspace::hash_map<std::string, Channel*, nspace::insensitive, irc::StrHashComp> chan_hash;
+ #else
+ typedef nspace::hash_map<std::string, User*, nspace::hash<std::string>, irc::StrHashComp> user_hash;
+ typedef nspace::hash_map<std::string, Channel*, nspace::hash<std::string>, irc::StrHashComp> chan_hash;
+ #endif
#else
-/** User hash (windows systems with visual studio)
- */
-typedef nspace::hash_map<std::string, User*, nspace::hash_compare<std::string, std::less<std::string> > > user_hash;
-/** Channel hash (windows systems with visual studio)
- */
-typedef nspace::hash_map<std::string, Channel*, nspace::hash_compare<std::string, std::less<std::string> > > chan_hash;
+
+ typedef nspace::hash_map<std::string, User*, nspace::hash_compare<std::string, std::less<std::string> > > user_hash;
+ typedef nspace::hash_map<std::string, Channel*, nspace::hash_compare<std::string, std::less<std::string> > > chan_hash;
#endif
/** Server name cache
diff --git a/src/configreader.cpp b/src/configreader.cpp
index aaff93ef9..34b811600 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -528,7 +528,7 @@ bool DoConnect(ServerConfig* conf, const char*, char**, ValueList &values, int*)
((*name && (cc->GetName() == name)) || // if the name is the same
(*allow && (cc->GetHost() == allow)) || // or the allow is the same
(*deny && (cc->GetHost() == deny))) && // or the deny is the same
- (!port || port && (cc->GetPort() == port)) // and there is no port, or there is a port and the port is the same
+ (!port || (port && (cc->GetPort() == port))) // and there is no port, or there is a port and the port is the same
)
{
/* reenable class so users can be shoved into it :P */
diff --git a/src/dns.cpp b/src/dns.cpp
index ad59a98e4..a6599bf0a 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -1169,8 +1169,8 @@ unsigned long DNS::PRNG()
timeval n;
serverstats* s = ServerInstance->stats;
gettimeofday(&n,NULL);
- val = (n.tv_usec ^ getpid() ^ geteuid() ^ (this->currid++)) ^ s->statsAccept + n.tv_sec;
- val = val + s->statsCollisions ^ s->statsDnsGood - s->statsDnsBad;
+ val = (n.tv_usec ^ (getpid() ^ geteuid()) ^ ((this->currid++)) ^ s->statsAccept) + n.tv_sec;
+ val = val + (s->statsCollisions ^ s->statsDnsGood) - s->statsDnsBad;
val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv) - ServerInstance->Config->ports.size();
return val;
}
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 19f2d601c..1bcb538f6 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -15,14 +15,7 @@
#include "inspircd.h"
#include "hashcomp.h"
-#ifndef WIN32
-#include <ext/hash_map>
-#define nspace __gnu_cxx
-#else
-#include <hash_map>
-#define nspace stdext
-using stdext::hash_map;
-#endif
+#include "hash_map.h"
/******************************************************
*
@@ -68,9 +61,13 @@ void nspace::strlower(char *n)
}
#ifndef WIN32
-size_t nspace::hash<std::string>::operator()(const std::string &s) const
+ #ifdef HASHMAP_DEPRECATED
+ size_t nspace::insensitive::operator()(const std::string &s) const
+ #else
+ size_t nspace::hash<std::string>::operator()(const std::string &s) const
+ #endif
#else
-size_t nspace::hash_compare<std::string, std::less<std::string> >::operator()(const std::string &s) const
+ size_t nspace::hash_compare<std::string, std::less<std::string> >::operator()(const std::string &s) const
#endif
{
/* XXX: NO DATA COPIES! :)
@@ -85,6 +82,7 @@ size_t nspace::hash_compare<std::string, std::less<std::string> >::operator()(co
return t;
}
+
#ifndef WIN32
size_t nspace::hash<irc::string>::operator()(const irc::string &s) const
#else
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index 166e252d6..83079c7f2 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -157,7 +157,7 @@ class MsgFlood : public ModeHandler
}
else
{
- if (((nlines != f->lines) || (nsecs != f->secs)) && ((nsecs > 0) && (nlines > 0)) || (ban != f->ban))
+ if ((((nlines != f->lines) || (nsecs != f->secs) || (ban != f->ban))) && (((nsecs > 0) && (nlines > 0))))
{
delete f;
floodsettings *fs = new floodsettings(ban,nsecs,nlines);
@@ -217,7 +217,7 @@ class ModuleMsgFlood : public Module
int ProcessMessages(User* user,Channel* dest, const std::string &text)
{
- if (!IS_LOCAL(user) || CHANOPS_EXEMPT(ServerInstance, 'f') && dest->GetStatus(user) == STATUS_OP)
+ if (!IS_LOCAL(user) || (CHANOPS_EXEMPT(ServerInstance, 'f') && dest->GetStatus(user) == STATUS_OP))
{
return 0;
}
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index db61fd7aa..27df8ddbf 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -26,9 +26,13 @@ class ModuleSpanningTree;
* tree, used for rapid linear lookups.
*/
#ifdef WINDOWS
-typedef nspace::hash_map<std::string, TreeServer*, nspace::hash_compare<std::string, std::less<std::string> > > server_hash;
+ typedef nspace::hash_map<std::string, TreeServer*, nspace::hash_compare<std::string, std::less<std::string> > > server_hash;
#else
-typedef nspace::hash_map<std::string, TreeServer*, nspace::hash<std::string>, irc::StrHashComp> server_hash;
+ #ifdef HASHCOMP_DEPRECATED
+ typedef nspace::hash_map<std::string, TreeServer*, nspace::insensitive, irc::StrHashComp> server_hash;
+ #else
+ typedef nspace::hash_map<std::string, TreeServer*, nspace::hash<std::string>, irc::StrHashComp> server_hash;
+ #endif
#endif
typedef std::map<TreeServer*,TreeServer*> TreeServerList;
diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp
index 9fec3dcad..c3c274dff 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -68,7 +68,7 @@ class ModuleStripColor : public Module
{
if ((*i == 3))
seq = 1;
- else if (seq && ( (*i >= '0') && (*i <= '9') || (*i == ',') ) )
+ else if (seq && (( ((*i >= '0') && (*i <= '9')) || (*i == ',') ) ))
{
seq++;
if ( (seq <= 4) && (*i == ',') )