summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/Args.cpp
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2010-12-09 22:52:49 +0000
committerCaroline Tice <ctice@apple.com>2010-12-09 22:52:49 +0000
commit844d230332856276a07b08a61a957e83fd669332 (patch)
tree4d76d6bd37df46be31d2c2faf7d413423847ab79 /lldb/source/Interpreter/Args.cpp
parent2bac54fe0c1184e1a97039cbcb769a2ff3b4183a (diff)
downloadbcm5719-llvm-844d230332856276a07b08a61a957e83fd669332.tar.gz
bcm5719-llvm-844d230332856276a07b08a61a957e83fd669332.zip
Modify HandleCommand to not do any argument processing until it has determined whether or
not the command should take raw input, then handle & dispatch the arguments appropriately. Also change the 'alias' command to be a command that takes raw input. This is necessary to allow aliases to be created for other commands that take raw input and might want to include raw input in the alias itself. Fix a bug in the aliasing mechanism when creating aliases for commands with 3-or-more words. Raw input should now be properly handled by all the command and alias mechanisms. llvm-svn: 121423
Diffstat (limited to 'lldb/source/Interpreter/Args.cpp')
-rw-r--r--lldb/source/Interpreter/Args.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index 8bc7d97b582..b0e448ee9bd 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -849,7 +849,8 @@ Args::IsPositionalArgument (const char *arg)
void
Args::ParseAliasOptions (Options &options,
CommandReturnObject &result,
- OptionArgVector *option_arg_vector)
+ OptionArgVector *option_arg_vector,
+ std::string &raw_input_string)
{
StreamString sstr;
int i;
@@ -985,16 +986,33 @@ Args::ParseAliasOptions (Options &options,
if (long_options_index >= 0)
{
// Find option in the argument list; also see if it was supposed to take an argument and if one was
- // supplied. Remove option (and argument, if given) from the argument list.
+ // supplied. Remove option (and argument, if given) from the argument list. Also remove them from
+ // the raw_input_string, if one was passed in.
size_t idx = FindArgumentIndexForOption (long_options, long_options_index);
if (idx < GetArgumentCount())
{
+ if (raw_input_string.size() > 0)
+ {
+ const char *tmp_arg = GetArgumentAtIndex (idx);
+ size_t pos = raw_input_string.find (tmp_arg);
+ if (pos != std::string::npos)
+ raw_input_string.erase (pos, strlen (tmp_arg));
+ }
ReplaceArgumentAtIndex (idx, "");
if ((long_options[long_options_index].has_arg != no_argument)
&& (optarg != NULL)
&& (idx+1 < GetArgumentCount())
&& (strcmp (optarg, GetArgumentAtIndex(idx+1)) == 0))
+ {
+ if (raw_input_string.size() > 0)
+ {
+ const char *tmp_arg = GetArgumentAtIndex (idx+1);
+ size_t pos = raw_input_string.find (tmp_arg);
+ if (pos != std::string::npos)
+ raw_input_string.erase (pos, strlen (tmp_arg));
+ }
ReplaceArgumentAtIndex (idx+1, "");
+ }
}
}
OpenPOWER on IntegriCloud