diff options
| author | Caroline Tice <ctice@apple.com> | 2010-10-12 17:45:19 +0000 |
|---|---|---|
| committer | Caroline Tice <ctice@apple.com> | 2010-10-12 17:45:19 +0000 |
| commit | 636d6ed0c168366725bf7069d3e4d6957896acd4 (patch) | |
| tree | f8b3900b8fad2678b91facdda7338368b751ed71 /lldb/source/Interpreter/Args.cpp | |
| parent | 897f96a5d3c68ef299dbf016c159554b5d1f1f34 (diff) | |
| download | bcm5719-llvm-636d6ed0c168366725bf7069d3e4d6957896acd4.tar.gz bcm5719-llvm-636d6ed0c168366725bf7069d3e4d6957896acd4.zip | |
Fix bug where alias command options were being duplicated as command arguments as well.
llvm-svn: 116316
Diffstat (limited to 'lldb/source/Interpreter/Args.cpp')
| -rw-r--r-- | lldb/source/Interpreter/Args.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index 62a4e1c999a..c04c4aa7c8a 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/lldb/source/Interpreter/Args.cpp @@ -802,12 +802,9 @@ Args::LongestCommonPrefix (std::string &common_prefix) } 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 @@ Args::ParseAliasOptions 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; } |

