From 318552487d077bb20c8f320c564a7b1e652cf885 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 10 Aug 2006 18:54:29 +0000 Subject: [PATCH] Move strlower into nspace namespace where hash lives git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4850 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/hashcomp.h | 2 ++ include/helperfuncs.h | 1 - src/hashcomp.cpp | 18 ++++++++++++++++++ src/helperfuncs.cpp | 18 ------------------ src/modules/m_helpop.cpp | 3 ++- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/include/hashcomp.h b/include/hashcomp.h index 6c90ee919..0ca8a6fac 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -43,6 +43,8 @@ using irc::sockets::insp_inaddr; namespace nspace { + void strlower(char *n); + template<> struct hash { size_t operator()(const insp_inaddr &a) const; diff --git a/include/helperfuncs.h b/include/helperfuncs.h index 21cb6caf3..7a55e5d23 100644 --- a/include/helperfuncs.h +++ b/include/helperfuncs.h @@ -48,7 +48,6 @@ enum DebugLevel #define STRINGIFY(x) STRINGIFY2(x) #define log(l, x, args...) InspIRCd::Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args) -void strlower(char *n); void Error(int status); void ShowMOTD(userrec *user); void ShowRULES(userrec *user); diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 278ea0044..6606884c9 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -60,6 +60,24 @@ extern const char lowermap[255]; using namespace std; using namespace irc::sockets; +/* convert a string to lowercase. Note following special circumstances + * taken from RFC 1459. Many "official" server branches still hold to this + * rule so i will too; + * + * Because of IRC's scandanavian origin, the characters {}| are + * considered to be the lower case equivalents of the characters []\, + * respectively. This is a critical issue when determining the + * equivalence of two nicknames. + */ +void nspace::strlower(char *n) +{ + if (n) + { + for (char* t = n; *t; t++) + *t = lowermap[(unsigned char)*t]; + } +} + size_t nspace::hash::operator()(const insp_inaddr &a) const { size_t q; diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index d048b75df..71a8d24a0 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -248,24 +248,6 @@ void InspIRCd::WriteMode(const char* modes, int flags, const char* text, ...) } } -/* convert a string to lowercase. Note following special circumstances - * taken from RFC 1459. Many "official" server branches still hold to this - * rule so i will too; - * - * Because of IRC's scandanavian origin, the characters {}| are - * considered to be the lower case equivalents of the characters []\, - * respectively. This is a critical issue when determining the - * equivalence of two nicknames. - */ -void strlower(char *n) -{ - if (n) - { - for (char* t = n; *t; t++) - *t = lowermap[(unsigned char)*t]; - } -} - /* Find a user record by nickname and return a pointer to it */ userrec* InspIRCd::FindNick(const std::string &nick) diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index 28e826276..00ba05c24 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -149,7 +149,8 @@ bool do_helpop(const char** parameters, int pcnt, userrec *src) strlcpy(search,parameters[0],MAXBUF); } - strlower(search); + for (char* n = search; *n; n++) + *n = tolower(*n); for (int i = 1; output != ""; i++) { -- 2.39.5