diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2011-11-26 17:20:02 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2011-11-26 17:20:02 +0000 |
| commit | 417802cbdfaa06bb3071fd648ad0536b64fcda21 (patch) | |
| tree | a3b9084bea363a691fe940c48e901283c7b34d36 /src | |
| parent | 9775958012ebeace0af3721fd58727f3e77e2a67 (diff) | |
CommandManager: argument splitting supports "multi word"
works with " and '
Diffstat (limited to 'src')
| -rw-r--r-- | src/command_manager.cc | 13 |
1 files 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; } |
