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.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@121423 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/Args.cpp b/source/Interpreter/Args.cpp
index 8bc7d97..b0e448e 100644
--- a/source/Interpreter/Args.cpp
+++ b/source/Interpreter/Args.cpp
@@ -849,7 +849,8 @@
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 @@
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, "");
+ }
}
}