diff options
author | Max Kellermann <max@duempel.org> | 2014-12-08 13:25:41 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-12-08 13:25:41 +0100 |
commit | 5837a6394256f10b16d9a1fbc19be686ef2da2b6 (patch) | |
tree | ea2d942f94a9047dc9e8d9e90d665bd4ae8dd309 /src | |
parent | 3a28f456b1dbc6e7cb225378375a598735f35338 (diff) | |
download | mpd-5837a6394256f10b16d9a1fbc19be686ef2da2b6.tar.gz mpd-5837a6394256f10b16d9a1fbc19be686ef2da2b6.tar.xz mpd-5837a6394256f10b16d9a1fbc19be686ef2da2b6.zip |
AllCommands: simplify the tokenizer loop
Diffstat (limited to '')
-rw-r--r-- | src/command/AllCommands.cxx | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx index f740373de..b2d9f52d3 100644 --- a/src/command/AllCommands.cxx +++ b/src/command/AllCommands.cxx @@ -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 */ |