Index: base/command_line.cc |
=================================================================== |
--- base/command_line.cc (revision 8989) |
+++ base/command_line.cc (working copy) |
@@ -29,6 +29,7 @@ |
#endif |
const wchar_t CommandLine::kSwitchValueSeparator[] = L"="; |
+const wchar_t CommandLine::kSwitchTerminator[] = L"--"; |
// Needed to avoid a typecast on the tolower() function pointer in Lowercase(). |
// MSVC accepts it as-is but GCC requires the typecast. |
@@ -88,10 +89,21 @@ |
// Populate program_ with the trimmed version of the first arg. |
TrimWhitespace(args[0], TRIM_ALL, &program_); |
+ bool parse_switches = true; |
for (int i = 1; i < num_args; ++i) { |
wstring arg; |
TrimWhitespace(args[i], TRIM_ALL, &arg); |
+ if (!parse_switches) { |
+ loose_values_.push_back(arg); |
+ continue; |
+ } |
+ |
+ if (arg == kSwitchTerminator) { |
+ parse_switches = false; |
+ continue; |
+ } |
+ |
wstring switch_string; |
wstring switch_value; |
if (IsSwitch(arg, &switch_string, &switch_value)) { |
@@ -113,11 +125,22 @@ |
program_ = base::SysNativeMBToWide(argv[0]); |
command_line_string_ = program_; |
+ bool parse_switches = true; |
for (int i = 1; i < argc; ++i) { |
std::wstring arg = base::SysNativeMBToWide(argv[i]); |
command_line_string_.append(L" "); |
command_line_string_.append(arg); |
+ if (!parse_switches) { |
+ loose_values_.push_back(arg); |
+ continue; |
+ } |
+ |
+ if (arg == kSwitchTerminator) { |
+ parse_switches = false; |
+ continue; |
+ } |
+ |
wstring switch_string; |
wstring switch_value; |
if (IsSwitch(arg, &switch_string, &switch_value)) { |