From 283ad2ba9fe3fa9dacf9bc8395169a71d0d79ad5 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 7 Mar 2006 00:11:23 +0000 Subject: Improved ProcessParameters (removed strlen) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3498 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/command_parse.cpp | 27 +++++++++++++++------------ src/svn-rev.sh | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src') 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 -- cgit v1.2.3