Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Unified Diff: base/command_line.cc

Issue 19740: Merge r2876 to the 1.0 release branch.... (Closed) Base URL: svn://chrome-svn/chrome/branches/release_154.next/src/
Patch Set: Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/command_line.h ('k') | base/command_line_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)) {
« no previous file with comments | « base/command_line.h ('k') | base/command_line_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698