[Lldb-commits] [lldb] r116316 - in /lldb/trunk/source: Commands/CommandObjectCommands.cpp Interpreter/Args.cpp
Caroline Tice
ctice at apple.com
Tue Oct 12 10:45:19 PDT 2010
Author: ctice
Date: Tue Oct 12 12:45:19 2010
New Revision: 116316
URL: http://llvm.org/viewvc/llvm-project?rev=116316&view=rev
Log:
Fix bug where alias command options were being duplicated as command arguments as well.
Modified:
lldb/trunk/source/Commands/CommandObjectCommands.cpp
lldb/trunk/source/Interpreter/Args.cpp
Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=116316&r1=116315&r2=116316&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Oct 12 12:45:19 2010
@@ -346,8 +346,9 @@
argc = args.GetArgumentCount();
for (size_t i = 0; i < argc; ++i)
- option_arg_vector->push_back (OptionArgPair ("<argument>",
- std::string (args.GetArgumentAtIndex (i))));
+ if (strcmp (args.GetArgumentAtIndex (i), "") != 0)
+ option_arg_vector->push_back (OptionArgPair ("<argument>",
+ std::string (args.GetArgumentAtIndex (i))));
}
// Create the alias.
Modified: lldb/trunk/source/Interpreter/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=116316&r1=116315&r2=116316&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Args.cpp (original)
+++ lldb/trunk/source/Interpreter/Args.cpp Tue Oct 12 12:45:19 2010
@@ -802,12 +802,9 @@
}
void
-Args::ParseAliasOptions
-(
- Options &options,
- CommandReturnObject &result,
- OptionArgVector *option_arg_vector
-)
+Args::ParseAliasOptions (Options &options,
+ CommandReturnObject &result,
+ OptionArgVector *option_arg_vector)
{
StreamString sstr;
int i;
@@ -936,6 +933,31 @@
result.AppendErrorWithFormat ("Invalid option with value '%c'.\n", (char) val);
result.SetStatus (eReturnStatusFailed);
}
+
+ 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.
+ StreamString short_opt_str;
+ StreamString long_opt_str;
+ short_opt_str.Printf ("-%c", (char) long_options[long_options_index].val);
+ long_opt_str.Printf ("-%s", long_options[long_options_index].name);
+ bool found = false;
+ size_t end = GetArgumentCount();
+ for (size_t i = 0; i < end && !found; ++i)
+ if ((strcmp (GetArgumentAtIndex (i), short_opt_str.GetData()) == 0)
+ || (strcmp (GetArgumentAtIndex (i), long_opt_str.GetData()) == 0))
+ {
+ found = true;
+ ReplaceArgumentAtIndex (i, "");
+ if ((long_options[long_options_index].has_arg != no_argument)
+ && (optarg != NULL)
+ && (i+1 < end)
+ && (strcmp (optarg, GetArgumentAtIndex(i+1)) == 0))
+ ReplaceArgumentAtIndex (i+1, "");
+ }
+ }
+
if (!result.Succeeded())
break;
}
More information about the lldb-commits
mailing list