summaryrefslogtreecommitdiff
path: root/src/mode.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-26 22:34:15 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-26 22:34:15 +0000
commitf96c0c9ec530da99de00a1f60052d8c0d7b19dea (patch)
tree9979c6f2bc3e0f69d1fb8e020e5a3419c1a85af9 /src/mode.cpp
parentf063862950bfa3c5a30f9e6101bd2d74b359b6c0 (diff)
Valgrind fixes (libstdc++ is broken! :O)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3354 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/mode.cpp')
-rw-r--r--src/mode.cpp57
1 files changed, 35 insertions, 22 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index fc2e04b1e..d07675e5f 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -585,6 +585,8 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
while (modelist[len-1] == ' ')
modelist[--len] = '\0';
+ bool next_cant_be_modifier = false;
+
for (char* modechar = modelist; *modechar; ptr++, modechar++)
{
r = NULL;
@@ -595,40 +597,50 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
if (pc > MAXMODES-1)
break;
+ if ((*modechar != '+') && (*modechar != '-'))
+ next_cant_be_modifier = false;
+
{
switch (*modechar)
{
case '-':
- if (mdir != 0)
+ if (!next_cant_be_modifier)
{
- int t = strlen(outlist)-1;
- if ((outlist[t] == '+') || (outlist[t] == '-'))
- {
- outlist[t] = '-';
- }
- else
+ if (mdir != 0)
{
- strcat(outlist,"-");
+ int t = strlen(outlist)-1;
+ if ((outlist[t] == '+') || (outlist[t] == '-'))
+ {
+ outlist[t] = '-';
+ }
+ else
+ {
+ strcat(outlist,"-");
+ }
}
+ mdir = 0;
+ next_cant_be_modifier = true;
}
- mdir = 0;
-
break;
case '+':
- if (mdir != 1)
+ if (!next_cant_be_modifier)
{
- int t = strlen(outlist)-1;
- if ((outlist[t] == '+') || (outlist[t] == '-'))
+ if (mdir != 1)
{
- outlist[t] = '+';
- }
- else
- {
- strcat(outlist,"+");
+ int t = strlen(outlist)-1;
+ if ((outlist[t] == '+') || (outlist[t] == '-'))
+ {
+ outlist[t] = '+';
+ }
+ else
+ {
+ strcat(outlist,"+");
+ }
}
+ mdir = 1;
+ next_cant_be_modifier = true;
}
- mdir = 1;
break;
case 'o':
@@ -1113,13 +1125,14 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
}
/* this ensures only the *valid* modes are sent out onto the network */
- int xt = strlen(outlist)-1;
+ /*int xt = strlen(outlist)-1;
while ((outlist[xt] == '-') || (outlist[xt] == '+'))
{
outlist[xt] = '\0';
xt = strlen(outlist)-1;
- }
- if (outlist[0])
+ }*/
+ /* The mode change must be at least two characters long (+ or - and at least one mode) */
+ if (((*outlist == '+') || (*outlist == '-')) && *(outlist+1))
{
strlcpy(outstr,outlist,MAXBUF);
for (ptr = 0; ptr < pc; ptr++)