| Index: base/command_line.cc
|
| diff --git a/base/command_line.cc b/base/command_line.cc
|
| index 36ac88f12c18c78794768e5e881e45201506c3ef..b502811c914d1b6e86d24d6cd614299c76652d79 100644
|
| --- a/base/command_line.cc
|
| +++ b/base/command_line.cc
|
| @@ -145,24 +145,28 @@ std::wstring QuoteForCommandLineToArgvW(const std::wstring& arg) {
|
|
|
| CommandLine::CommandLine(NoProgram no_program)
|
| : argv_(1),
|
| - begin_args_(1) {
|
| + begin_args_(1),
|
| + switch_lengths_mask_(0) {
|
| }
|
|
|
| CommandLine::CommandLine(const FilePath& program)
|
| : argv_(1),
|
| - begin_args_(1) {
|
| + begin_args_(1),
|
| + switch_lengths_mask_(0) {
|
| SetProgram(program);
|
| }
|
|
|
| CommandLine::CommandLine(int argc, const CommandLine::CharType* const* argv)
|
| : argv_(1),
|
| - begin_args_(1) {
|
| + begin_args_(1),
|
| + switch_lengths_mask_(0) {
|
| InitFromArgv(argc, argv);
|
| }
|
|
|
| CommandLine::CommandLine(const StringVector& argv)
|
| : argv_(1),
|
| - begin_args_(1) {
|
| + begin_args_(1),
|
| + switch_lengths_mask_(0) {
|
| InitFromArgv(argv);
|
| }
|
|
|
| @@ -226,6 +230,7 @@ void CommandLine::InitFromArgv(int argc,
|
| void CommandLine::InitFromArgv(const StringVector& argv) {
|
| argv_ = StringVector(1);
|
| switches_.clear();
|
| + switch_lengths_mask_ = 0;
|
| begin_args_ = 1;
|
| SetProgram(argv.empty() ? FilePath() : FilePath(argv[0]));
|
| AppendSwitchesAndArguments(*this, argv);
|
| @@ -282,10 +287,15 @@ void CommandLine::SetProgram(const FilePath& program) {
|
| TrimWhitespace(program.value(), TRIM_ALL, &argv_[0]);
|
| }
|
|
|
| -bool CommandLine::HasSwitch(const std::string& switch_string) const {
|
| +bool CommandLine::HasStringSwitch(const std::string& switch_string) const {
|
| return switches_.find(LowerASCIIOnWindows(switch_string)) != switches_.end();
|
| }
|
|
|
| +bool CommandLine::HasSwitch(const char* switch_string,
|
| + size_t string_length) const {
|
| + return HasSwitch(std::string(switch_string, string_length));
|
| +}
|
| +
|
| std::string CommandLine::GetSwitchValueASCII(
|
| const std::string& switch_string) const {
|
| StringType value = GetSwitchValueNative(switch_string);
|
| @@ -331,6 +341,7 @@ void CommandLine::AppendSwitchNative(const std::string& switch_string,
|
| #endif
|
| size_t prefix_length = GetSwitchPrefixLength(combined_switch_string);
|
| switches_[switch_key.substr(prefix_length)] = value;
|
| + switch_lengths_mask_ |= 1 << (prefix_length - 1);
|
| // Preserve existing switch prefixes in |argv_|; only append one if necessary.
|
| if (prefix_length == 0)
|
| combined_switch_string = kSwitchPrefixes[0] + combined_switch_string;
|
| @@ -353,8 +364,9 @@ void CommandLine::CopySwitchesFrom(const CommandLine& source,
|
| const char* const switches[],
|
| size_t count) {
|
| for (size_t i = 0; i < count; ++i) {
|
| - if (source.HasSwitch(switches[i]))
|
| - AppendSwitchNative(switches[i], source.GetSwitchValueNative(switches[i]));
|
| + std::string s = switches[i];
|
| + if (source.HasSwitch(s))
|
| + AppendSwitchNative(s, source.GetSwitchValueNative(s));
|
| }
|
| }
|
|
|
|
|