Commit 5837a639 authored by Max Kellermann's avatar Max Kellermann

AllCommands: simplify the tokenizer loop

parent 3a28f456
......@@ -384,23 +384,25 @@ command_process(Client &client, unsigned num, char *line)
/* now parse the arguments (quoted or unquoted) */
while (argc < COMMAND_ARGV_MAX &&
(argv[argc] =
tokenizer.NextParam(error)) != nullptr)
++argc;
/* some error checks */
if (argc >= COMMAND_ARGV_MAX) {
command_error(client, ACK_ERROR_ARG, "Too many arguments");
current_command = nullptr;
return CommandResult::ERROR;
}
if (!tokenizer.IsEnd()) {
command_error(client, ACK_ERROR_ARG, "%s", error.GetMessage());
current_command = nullptr;
return CommandResult::ERROR;
while (true) {
if (argc == COMMAND_ARGV_MAX) {
command_error(client, ACK_ERROR_ARG,
"Too many arguments");
current_command = nullptr;
return CommandResult::ERROR;
}
char *a = tokenizer.NextParam(error);
if (a == nullptr) {
if (tokenizer.IsEnd())
break;
command_error(client, ACK_ERROR_ARG, "%s", error.GetMessage());
current_command = nullptr;
return CommandResult::ERROR;
}
argv[argc++] = a;
}
/* look up and invoke the command handler */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment