summaryrefslogtreecommitdiff
path: root/base/command_line.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/command_line.cc')
-rw-r--r--base/command_line.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/base/command_line.cc b/base/command_line.cc
index c6f3197091..40b65b9e85 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -7,9 +7,9 @@
#include <algorithm>
#include <ostream>
-#include "base/basictypes.h"
#include "base/files/file_path.h"
#include "base/logging.h"
+#include "base/macros.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -75,7 +75,11 @@ void AppendSwitchesAndArguments(CommandLine* command_line,
bool parse_switches = true;
for (size_t i = 1; i < argv.size(); ++i) {
CommandLine::StringType arg = argv[i];
+#if defined(OS_WIN)
TrimWhitespace(arg, TRIM_ALL, &arg);
+#else
+ TrimWhitespaceASCII(arg, TRIM_ALL, &arg);
+#endif
CommandLine::StringType switch_string;
CommandLine::StringType switch_value;
@@ -263,11 +267,15 @@ FilePath CommandLine::GetProgram() const {
}
void CommandLine::SetProgram(const FilePath& program) {
+#if defined(OS_WIN)
TrimWhitespace(program.value(), TRIM_ALL, &argv_[0]);
+#else
+ TrimWhitespaceASCII(program.value(), TRIM_ALL, &argv_[0]);
+#endif
}
bool CommandLine::HasSwitch(const base::StringPiece& switch_string) const {
- DCHECK_EQ(StringToLowerASCII(switch_string.as_string()), switch_string);
+ DCHECK_EQ(ToLowerASCII(switch_string), switch_string);
return switches_by_stringpiece_.find(switch_string) !=
switches_by_stringpiece_.end();
}
@@ -297,7 +305,7 @@ FilePath CommandLine::GetSwitchValuePath(
CommandLine::StringType CommandLine::GetSwitchValueNative(
const base::StringPiece& switch_string) const {
- DCHECK_EQ(StringToLowerASCII(switch_string.as_string()), switch_string);
+ DCHECK_EQ(ToLowerASCII(switch_string), switch_string);
auto result = switches_by_stringpiece_.find(switch_string);
return result == switches_by_stringpiece_.end() ? StringType()
: *(result->second);
@@ -315,7 +323,7 @@ void CommandLine::AppendSwitchPath(const std::string& switch_string,
void CommandLine::AppendSwitchNative(const std::string& switch_string,
const CommandLine::StringType& value) {
#if defined(OS_WIN)
- const std::string switch_key = StringToLowerASCII(switch_string);
+ const std::string switch_key = ToLowerASCII(switch_string);
StringType combined_switch_string(ASCIIToUTF16(switch_key));
#elif defined(OS_POSIX)
const std::string& switch_key = switch_string;
@@ -394,8 +402,9 @@ void CommandLine::PrependWrapper(const CommandLine::StringType& wrapper) {
return;
// The wrapper may have embedded arguments (like "gdb --args"). In this case,
// we don't pretend to do anything fancy, we just split on spaces.
- StringVector wrapper_argv;
- SplitString(wrapper, FILE_PATH_LITERAL(' '), &wrapper_argv);
+ StringVector wrapper_argv = SplitString(
+ wrapper, FilePath::StringType(1, ' '), base::TRIM_WHITESPACE,
+ base::SPLIT_WANT_ALL);
// Prepend the wrapper and update the switches/arguments |begin_args_|.
argv_.insert(argv_.begin(), wrapper_argv.begin(), wrapper_argv.end());
begin_args_ += wrapper_argv.size();