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

Unified Diff: base/command_line.cc

Issue 11305010: Extract arguments reconstruction logic out of GetCommandLineString() into GetArgumentsString(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: some more quotes working only on OS_WIN Created 8 years, 2 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
diff --git a/base/command_line.cc b/base/command_line.cc
index 29467e3196b41a328f6de6e3eefaae26af7d2aed..f4553ea15b1c59fb89710840f831f749d2170d05 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -228,31 +228,42 @@ CommandLine::StringType CommandLine::GetCommandLineString() const {
#if defined(OS_WIN)
string = QuoteForCommandLineToArgvW(string);
#endif
+ StringType params(GetArgumentsString());
+ if (!params.empty()) {
+ string.append(StringType(FILE_PATH_LITERAL(" ")));
+ string.append(params);
+ }
+ return string;
+}
+
+CommandLine::StringType CommandLine::GetArgumentsString() const {
+ StringType params;
// Append switches and arguments.
bool parse_switches = true;
for (size_t i = 1; i < argv_.size(); ++i) {
- CommandLine::StringType arg = argv_[i];
- CommandLine::StringType switch_string;
- CommandLine::StringType switch_value;
+ StringType arg = argv_[i];
+ StringType switch_string;
+ StringType switch_value;
parse_switches &= arg != kSwitchTerminator;
- string.append(StringType(FILE_PATH_LITERAL(" ")));
+ if (i > 1)
+ params.append(StringType(FILE_PATH_LITERAL(" ")));
if (parse_switches && IsSwitch(arg, &switch_string, &switch_value)) {
- string.append(switch_string);
+ params.append(switch_string);
if (!switch_value.empty()) {
#if defined(OS_WIN)
switch_value = QuoteForCommandLineToArgvW(switch_value);
#endif
- string.append(kSwitchValueSeparator + switch_value);
+ params.append(kSwitchValueSeparator + switch_value);
}
}
else {
#if defined(OS_WIN)
arg = QuoteForCommandLineToArgvW(arg);
#endif
- string.append(arg);
+ params.append(arg);
}
}
- return string;
+ return params;
}
FilePath CommandLine::GetProgram() const {
« 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