summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-07 00:11:23 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-07 00:11:23 +0000
commit283ad2ba9fe3fa9dacf9bc8395169a71d0d79ad5 (patch)
tree3fe32be13ee1bf81a6653b9abdcb6e25891a4b4e
parent496f9df539560ded1fa401e4d5334cc1f8c0c37b (diff)
Improved ProcessParameters (removed strlen)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3498 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/command_parse.cpp27
-rwxr-xr-xsrc/svn-rev.sh2
2 files changed, 16 insertions, 13 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index bd2f78e05..4d3012915 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -366,29 +366,30 @@ bool CommandParser::CallHandler(std::string &commandname,char **parameters, int
int CommandParser::ProcessParameters(char **command_p,char *parameters)
{
int j = 0;
- int q = strlen(parameters);
+ //int q = strlen(parameters);
- if (!q)
+ if (!*parameters)
{
/* no parameters, command_p invalid! */
return 0;
}
- if (parameters[0] == ':')
+ if (*parameters == ':')
{
command_p[0] = parameters+1;
return 1;
}
- if (q)
+ if (*parameters)
{
- if ((strchr(parameters,' ')==NULL) || (parameters[0] == ':'))
+ char* n = strchr(parameters,' ');
+ if ((!n) || (*parameters == ':'))
{
/* only one parameter */
command_p[0] = parameters;
- if (parameters[0] == ':')
+ if (*parameters == ':')
{
- if (strchr(parameters,' ') != NULL)
+ if (n)
{
command_p[0]++;
}
@@ -400,14 +401,14 @@ int CommandParser::ProcessParameters(char **command_p,char *parameters)
command_p[j++] = parameters;
- for (int i = 0; i <= q; i++)
+ for (char* i = parameters; *i; i++)
{
- if (parameters[i] == ' ')
+ if (*i == ' ')
{
- command_p[j++] = parameters+i+1;
- parameters[i] = '\0';
+ command_p[j++] = i+1;
+ *i = '\0';
- if (command_p[j-1][0] == ':')
+ if (*command_p[j-1] == ':')
{
*command_p[j-1]++; /* remove dodgy ":" */
break;
@@ -415,6 +416,8 @@ int CommandParser::ProcessParameters(char **command_p,char *parameters)
}
}
}
+ //command_p[j] = parameters+i+1;
+ //*i = '\0';
return j; /* returns total number of items in the list */
}
diff --git a/src/svn-rev.sh b/src/svn-rev.sh
index 95a59dad0..ec6f40a06 100755
--- a/src/svn-rev.sh
+++ b/src/svn-rev.sh
@@ -1 +1 @@
-echo 3495
+echo 3497