From 417802cbdfaa06bb3071fd648ad0536b64fcda21 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 26 Nov 2011 17:20:02 +0000 Subject: [PATCH] CommandManager: argument splitting supports "multi word" works with " and ' --- src/command_manager.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index b1722f3f..cbe2a1cb 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -27,17 +27,26 @@ static TokenList split(const std::string& line) TokenList result; size_t pos = 0; - while (pos != line.length()) + while (pos < line.length()) { while(line[pos] == ' ' and pos != line.length()) ++pos; + char delimiter = ' '; + if (line[pos] == '"' or line[pos] == '\'') + { + delimiter = line[pos]; + ++pos; + } + size_t token_start = pos; - while((line[pos] != ' ' or line[pos-1] == '\\') and pos != line.length()) + while((line[pos] != delimiter or line[pos-1] == '\\') and pos != line.length()) ++pos; result.push_back(std::make_pair(token_start, pos)); + + ++pos; } return result; }