diff options
author | om <om@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-01 11:42:09 +0000 |
---|---|---|
committer | om <om@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-01 11:42:09 +0000 |
commit | 3cf1ae04704b4f1706daa1077b90fd14d1e72cef (patch) | |
tree | 05e914b6723cff559175d41389f2c15d52fa4b24 | |
parent | a3a9d3e0f0b9680bdb9e8700dc6a43b9c8278977 (diff) |
Replace rather craq'y loop with a couple of std::string calls
Change GetServerDescription to take const char* rather than char*
Change userrec::server from char* to const char*, this is more 'correct' as it's not safe to modify it (pointer as returned by std::string::c_str())
Change WhoWasGroup::server, see above about userrec::server
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4094 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/helperfuncs.h | 2 | ||||
-rw-r--r-- | include/users.h | 4 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 24 |
4 files changed, 16 insertions, 16 deletions
diff --git a/include/helperfuncs.h b/include/helperfuncs.h index 45c4da6f0..5eb6e22d8 100644 --- a/include/helperfuncs.h +++ b/include/helperfuncs.h @@ -72,7 +72,7 @@ void WriteCommon_NoFormat(userrec *u, const char* text); void WriteCommonExcept_NoFormat(userrec *u, const char* text); void WriteOpers_NoFormat(const char* text); -std::string GetServerDescription(char* servername); +std::string GetServerDescription(const char* servername); void WriteMode(const char* modes, int flags, const char* text, ...); void NoticeAll(userrec *source, bool local_only, char* text, ...); void ServerNoticeAll(char* text, ...); diff --git a/include/users.h b/include/users.h index 25db5eb08..0d812c0a4 100644 --- a/include/users.h +++ b/include/users.h @@ -170,7 +170,7 @@ class userrec : public connection /** The server the user is connected to. */ - char* server; + const char* server; /** The user's away message. * If this string is empty, the user is not marked as away. @@ -375,7 +375,7 @@ class WhoWasGroup char* host; char* dhost; char* ident; - char* server; + const char* server; char* gecos; time_t signon; diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index c51a824a8..a30a669ae 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -670,7 +670,7 @@ void ChanExceptSender_NoFormat(chanrec* Ptr, userrec* user, char status, const c } } -std::string GetServerDescription(char* servername) +std::string GetServerDescription(const char* servername) { std::string description = ""; diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index dc50140b2..efedb2b8c 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -1147,18 +1147,17 @@ class TreeSocket : public InspSocket // NICK age nick host dhost ident +modes ip :gecos // 0 123 4 56 7 time_t age = atoi(params[0].c_str()); - std::string modes = params[5]; - while (*(modes.c_str()) == '+') - { - char* m = (char*)modes.c_str(); - m++; - modes = m; - } - char* tempnick = (char*)params[1].c_str(); + + /* This used to have a pretty craq'y loop doing the same thing, + * now we just let the STL do the hard work (more efficiently) + */ + params[5] = params[5].substr(params[5].find_first_not_of('+')); + + const char* tempnick = params[1].c_str(); log(DEBUG,"Introduce client %s!%s@%s",tempnick,params[4].c_str(),params[2].c_str()); - user_hash::iterator iter; - iter = clientlist.find(tempnick); + user_hash::iterator iter = clientlist.find(tempnick); + if (iter != clientlist.end()) { // nick collision @@ -1172,12 +1171,13 @@ class TreeSocket : public InspSocket strlcpy(clientlist[tempnick]->nick, tempnick,NICKMAX-1); strlcpy(clientlist[tempnick]->host, params[2].c_str(),63); strlcpy(clientlist[tempnick]->dhost, params[3].c_str(),63); - clientlist[tempnick]->server = (char*)FindServerNamePtr(source.c_str()); + clientlist[tempnick]->server = FindServerNamePtr(source.c_str()); strlcpy(clientlist[tempnick]->ident, params[4].c_str(),IDENTMAX); strlcpy(clientlist[tempnick]->fullname, params[7].c_str(),MAXGECOS); clientlist[tempnick]->registered = 7; clientlist[tempnick]->signon = age; - strlcpy(clientlist[tempnick]->modes, modes.c_str(),53); + strlcpy(clientlist[tempnick]->modes, params[5].c_str(),53); + for (char *v = clientlist[tempnick]->modes; *v; v++) { switch (*v) |