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

Unified Diff: base/command_line.cc

Issue 4949004: Add a unit test for CommandLine that makes sure that GetProgram will not retu... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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 | « no previous file | 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 66131)
+++ base/command_line.cc (working copy)
@@ -46,6 +46,17 @@
const char kSwitchValueSeparator[] = "=";
#endif
+namespace {
+
+// Trims the quotes from the beginning and end of a path.
+CommandLine::StringType TrimQuotes(const FilePath::StringType& path) {
+ if (!path.empty() && path[0] == '"' && path[path.length() - 1] == '"')
+ return path.substr(1, path.length() - 2);
+ return path;
+}
+
+} // end namespace
+
#if defined(OS_WIN)
// Lowercase a string. This is used to lowercase switch names.
// Is this what we really want? It seems crazy to me. I've left it in
@@ -114,9 +125,9 @@
CommandLine::CommandLine(const FilePath& program) {
if (!program.empty()) {
- program_ = program.value();
+ program_ = TrimQuotes(program.value());
Evan Martin 2010/11/15 21:01:08 I think this is wrong. A FilePath is a platonic i
// TODO(evanm): proper quoting here.
- command_line_string_ = L'"' + program.value() + L'"';
+ command_line_string_ = L'"' + program_ + L'"';
}
}
@@ -167,7 +178,7 @@
}
CommandLine::CommandLine(const FilePath& program) {
- argv_.push_back(program.value());
+ argv_.push_back(TrimQuotes(program.value());
}
#endif
« no previous file with comments | « no previous file | base/command_line_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698