OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 void CommandLine::InitFromArgv(int argc, | 213 void CommandLine::InitFromArgv(int argc, |
214 const CommandLine::CharType* const* argv) { | 214 const CommandLine::CharType* const* argv) { |
215 StringVector new_argv; | 215 StringVector new_argv; |
216 for (int i = 0; i < argc; ++i) | 216 for (int i = 0; i < argc; ++i) |
217 new_argv.push_back(argv[i]); | 217 new_argv.push_back(argv[i]); |
218 InitFromArgv(new_argv); | 218 InitFromArgv(new_argv); |
219 } | 219 } |
220 | 220 |
221 void CommandLine::InitFromArgv(const StringVector& argv) { | 221 void CommandLine::InitFromArgv(const StringVector& argv) { |
222 argv_ = StringVector(1); | 222 argv_ = StringVector(1); |
| 223 switches_.clear(); |
223 begin_args_ = 1; | 224 begin_args_ = 1; |
224 SetProgram(argv.empty() ? FilePath() : FilePath(argv[0])); | 225 SetProgram(argv.empty() ? FilePath() : FilePath(argv[0])); |
225 AppendSwitchesAndArguments(*this, argv); | 226 AppendSwitchesAndArguments(*this, argv); |
226 } | 227 } |
227 | 228 |
228 CommandLine::StringType CommandLine::GetCommandLineString() const { | 229 CommandLine::StringType CommandLine::GetCommandLineString() const { |
229 StringType string(argv_[0]); | 230 StringType string(argv_[0]); |
230 #if defined(OS_WIN) | 231 #if defined(OS_WIN) |
231 string = QuoteForCommandLineToArgvW(string); | 232 string = QuoteForCommandLineToArgvW(string); |
232 #endif | 233 #endif |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 int num_args = 0; | 410 int num_args = 0; |
410 wchar_t** args = NULL; | 411 wchar_t** args = NULL; |
411 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); | 412 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); |
412 | 413 |
413 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " | 414 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " |
414 << command_line; | 415 << command_line; |
415 InitFromArgv(num_args, args); | 416 InitFromArgv(num_args, args); |
416 LocalFree(args); | 417 LocalFree(args); |
417 } | 418 } |
418 #endif | 419 #endif |
OLD | NEW |