summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-06-11 20:28:06 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-06-11 20:28:06 +0000
commitfc78e51452a0244ee672fca91752eb7d982e2541 (patch)
tree60f6f06b3e3acf0ad3f29a14ae7aef62fb16b1f7
parent8fa67528583b83a23030d5d358e070586672cc87 (diff)
Make stristr() const-safe, replace post-increment on iterators with pre-increment, remove now unused variables, made my_memo_lang() in hs_request.c const-safe.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2320 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--include/extern.h2
-rw-r--r--src/config.c12
-rw-r--r--src/core/ns_group.c6
-rw-r--r--src/core/ns_register.c11
-rw-r--r--src/core/os_staff.c5
-rw-r--r--src/messages.c10
-rw-r--r--src/misc.c4
-rw-r--r--src/modules/hs_request.c8
8 files changed, 26 insertions, 32 deletions
diff --git a/include/extern.h b/include/extern.h
index 1b28aeaa4..32f8ba1b9 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -613,7 +613,7 @@ E size_t strlcpy(char *, const char *, size_t);
#ifndef HAVE_STRLCAT
E size_t strlcat(char *, const char *, size_t);
#endif
-E char *stristr(char *s1, char *s2);
+E const char *stristr(const char *s1, const char *s2);
E char *strnrepl(char *s, int32 size, const char *old, const char *nstr);
E const char *merge_args(int argc, char **argv);
E const char *merge_args(int argc, const char **argv);
diff --git a/src/config.c b/src/config.c
index cc3dfec17..4766da1e8 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1614,19 +1614,17 @@ int read_config(int reload)
char *s;
int defconCount = 0;
std::list<std::pair<std::string, std::string> >::iterator it;
- NickCore *nc;
- std::string nick;
/* Clear current opers for reload */
- for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); it++)
+ for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); ++it)
{
- nick = it->first;
-
- if ((nc = findcore(nick.c_str())))
+ std::string nick = it->first;
+ NickCore *nc = findcore(nick.c_str());
+ if (nc)
nc->ot = NULL;
}
svsopers_in_config.clear();
-
+
retval = serverConfig.Read(reload ? false : true);
if (!retval) return 0; // Temporary until most of the below is modified to use the new parser -- CyberBotX
diff --git a/src/core/ns_group.c b/src/core/ns_group.c
index e19a12f8e..6439b2a21 100644
--- a/src/core/ns_group.c
+++ b/src/core/ns_group.c
@@ -62,11 +62,11 @@ class CommandNSGroup : public Command
if (RestrictOperNicks)
{
- for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); it++)
+ for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); ++it)
{
- const std::string nick = it->first;
+ std::string nick = it->first;
- if (stristr(u->nick, const_cast<char *>(it->first.c_str())) && !is_oper(u))
+ if (stristr(u->nick, nick.c_str()) && !is_oper(u))
{
notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick);
return MOD_CONT;
diff --git a/src/core/ns_register.c b/src/core/ns_register.c
index 5e7088a93..a9788853c 100644
--- a/src/core/ns_register.c
+++ b/src/core/ns_register.c
@@ -35,7 +35,7 @@ class CommandNSConfirm : public Command
return MOD_CONT;
}
- int i, len;
+ int len;
char tsbuf[16];
char tmp_pass[PASSMAX];
char modes[512];
@@ -202,14 +202,13 @@ class CommandNSRegister : public CommandNSConfirm
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
NickRequest *nr = NULL, *anr = NULL;
- NickCore *nc = NULL;
NickAlias *na;
int prefixlen = strlen(NSGuestNickPrefix);
int nicklen = strlen(u->nick);
const char *pass = params[0].c_str();
const char *email = params.size() > 1 ? params[1].c_str() : NULL;
char passcode[11];
- int idx, min = 1, max = 62, i = 0;
+ int idx, min = 1, max = 62;
int chars[] =
{ ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
@@ -262,11 +261,11 @@ class CommandNSRegister : public CommandNSConfirm
if (RestrictOperNicks)
{
- for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); it++)
+ for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); ++it)
{
- const std::string nick = it->first;
+ std::string nick = it->first;
- if (stristr(u->nick, const_cast<char *>(it->first.c_str())) && !is_oper(u))
+ if (stristr(u->nick, nick.c_str()) && !is_oper(u))
{
notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick);
return MOD_CONT;
diff --git a/src/core/os_staff.c b/src/core/os_staff.c
index 28de7768a..476b072c5 100644
--- a/src/core/os_staff.c
+++ b/src/core/os_staff.c
@@ -36,11 +36,10 @@ class CommandOSStaff : public Command
notice_lang(s_OperServ, u, OPER_STAFF_LIST_HEADER);
- for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); it++)
+ for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); ++it)
{
found = 0;
- const std::string nick = it->first;
- const std::string type = it->second;
+ std::string nick = it->first, type = it->second;
if ((au = finduser(nick.c_str())))
{
diff --git a/src/messages.c b/src/messages.c
index a29841b6a..d77b62809 100644
--- a/src/messages.c
+++ b/src/messages.c
@@ -216,7 +216,6 @@ int m_privmsg(const char *source, const char *receiver, const char *msg)
int m_stats(const char *source, int ac, const char **av)
{
- int i;
User *u;
NickCore *nc;
@@ -245,13 +244,12 @@ int m_stats(const char *source, int ac, const char **av)
} else {
std::list<std::pair<std::string, std::string> >::iterator it;
- for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); it++)
+ for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); ++it)
{
- const std::string nick = it->first;
- const std::string type = it->second;
+ std::string nick = it->first, type = it->second;
- if ((nc = findcore(it->first.c_str())))
- ircdproto->SendNumeric(ServerName, 243, source, "O * * %s %s 0", it->first.c_str(), it->second.c_str());
+ if ((nc = findcore(nick.c_str())))
+ ircdproto->SendNumeric(ServerName, 243, source, "O * * %s %s 0", nick.c_str(), type.c_str());
}
ircdproto->SendNumeric(ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*');
diff --git a/src/misc.c b/src/misc.c
index 02375c96b..976c26ada 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -112,9 +112,9 @@ char *strscpy(char *d, const char *s, size_t len)
* @param s2 String 2
* @return first occurrence of s2
*/
-char *stristr(char *s1, char *s2)
+const char *stristr(const char *s1, const char *s2)
{
- register char *s = s1, *d = s2;
+ register const char *s = s1, *d = s2;
while (*s1) {
if (tolower(*s1) == tolower(*d)) {
diff --git a/src/modules/hs_request.c b/src/modules/hs_request.c
index 71efc4c12..2a047d9b9 100644
--- a/src/modules/hs_request.c
+++ b/src/modules/hs_request.c
@@ -772,7 +772,7 @@ class HSRequest : public Module
}
};
-void my_memo_lang(User *u, char *name, int z, int number, ...)
+void my_memo_lang(User *u, const char *name, int z, int number, ...)
{
va_list va;
char buffer[4096], outbuf[4096];
@@ -832,10 +832,10 @@ void req_send_memos(User *u, char *vIdent, char *vHost)
if (HSRequestMemoOper == 1)
{
- for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); it++)
+ for (it = svsopers_in_config.begin(); it != svsopers_in_config.end(); ++it)
{
- const std::string nick = it->first;
- my_memo_lang(u, const_cast<char *>(nick.c_str()), z, LNG_REQUEST_MEMO, host);
+ std::string nick = it->first;
+ my_memo_lang(u, nick.c_str(), z, LNG_REQUEST_MEMO, host);
}
}
if (HSRequestMemoSetters == 1)