From badcd21abb770c040dd3a842be5e21723cd82e71 Mon Sep 17 00:00:00 2001 From: rburchell Date: Wed, 11 Feb 2009 11:17:10 +0000 Subject: [PATCH] Make max params work correctly, and fix bs_act to request params correctly. Audited as working ok. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2013 5417fbe8-f217-4b02-8779-1006273d7864 --- TODO | 1 - src/commands.c | 18 +++++++++++++++--- src/core/bs_assign.c | 6 +++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 5ab92c1e5..8d6e0093b 100644 --- a/TODO +++ b/TODO @@ -46,7 +46,6 @@ Legend: [ ] HelpServ must die (1.9.1?) [-] Command parser cleanup: mod_current_buffer needs to go away and be replaced by a proper parser. Commands should then indicate how they want the buffer split. These all need reviewing, remove them from the list _AS YOU GO_. Talk t0 w00t or CBX if you don't know what this is for: - src/core/bs_act.c src/core/bs_assign.c src/core/bs_badwords.c src/core/bs_bot.c diff --git a/src/commands.c b/src/commands.c index fc66334c4..5dd24bb1d 100644 --- a/src/commands.c +++ b/src/commands.c @@ -84,14 +84,26 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char * char *s = NULL; while ((s = strtok(NULL, " "))) { - if (params.size() < c->MaxParams) - params.push_back(s); - else + // - 1 because params[0] corresponds with a maxparam of 1. + if (params.size() >= (c->MaxParams - 1)) + { curparam += s; + curparam += " "; + } + else + { + params.push_back(s); + } } if (!curparam.empty()) + { + // Remove trailing space + curparam.erase(curparam.size() - 1, curparam.size()); + + // Add it params.push_back(curparam); + } if (params.size() < c->MinParams) { diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c index dc9dca37a..73bbd6213 100644 --- a/src/core/bs_assign.c +++ b/src/core/bs_assign.c @@ -20,14 +20,14 @@ void myBotServHelp(User * u); class CommandBSAssign : public Command { public: - CommandBSAssign() : Command("ASSIGN", 1, 1) + CommandBSAssign() : Command("ASSIGN", 2, 2) { } CommandReturn Execute(User *u, std::vector ¶ms) { - char *chan = strtok(NULL, " "); - char *nick = strtok(NULL, " "); + const char *chan = params[0].c_str(); + const char *nick = params[1].c_str(); BotInfo *bi; ChannelInfo *ci;