mirror of
https://github.com/anope/anope.git
synced 2026-06-30 03:56:38 +02:00
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
This commit is contained in:
+1
-1
@@ -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);
|
||||
|
||||
+5
-7
@@ -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
|
||||
|
||||
|
||||
+3
-3
@@ -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;
|
||||
|
||||
@@ -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> ¶ms)
|
||||
{
|
||||
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;
|
||||
|
||||
+2
-3
@@ -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())))
|
||||
{
|
||||
|
||||
+4
-6
@@ -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] : '*');
|
||||
|
||||
+2
-2
@@ -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)) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user