AllCommands: simplify the tokenizer loop
This commit is contained in:
parent
3a28f456b1
commit
5837a63942
@ -384,23 +384,25 @@ command_process(Client &client, unsigned num, char *line)
|
|||||||
|
|
||||||
/* now parse the arguments (quoted or unquoted) */
|
/* now parse the arguments (quoted or unquoted) */
|
||||||
|
|
||||||
while (argc < COMMAND_ARGV_MAX &&
|
while (true) {
|
||||||
(argv[argc] =
|
if (argc == COMMAND_ARGV_MAX) {
|
||||||
tokenizer.NextParam(error)) != nullptr)
|
command_error(client, ACK_ERROR_ARG,
|
||||||
++argc;
|
"Too many arguments");
|
||||||
|
current_command = nullptr;
|
||||||
|
return CommandResult::ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* some error checks */
|
char *a = tokenizer.NextParam(error);
|
||||||
|
if (a == nullptr) {
|
||||||
|
if (tokenizer.IsEnd())
|
||||||
|
break;
|
||||||
|
|
||||||
if (argc >= COMMAND_ARGV_MAX) {
|
command_error(client, ACK_ERROR_ARG, "%s", error.GetMessage());
|
||||||
command_error(client, ACK_ERROR_ARG, "Too many arguments");
|
current_command = nullptr;
|
||||||
current_command = nullptr;
|
return CommandResult::ERROR;
|
||||||
return CommandResult::ERROR;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!tokenizer.IsEnd()) {
|
argv[argc++] = a;
|
||||||
command_error(client, ACK_ERROR_ARG, "%s", error.GetMessage());
|
|
||||||
current_command = nullptr;
|
|
||||||
return CommandResult::ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* look up and invoke the command handler */
|
/* look up and invoke the command handler */
|
||||||
|
Loading…
Reference in New Issue
Block a user