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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 return 0; | 43 return 0; |
44 } | 44 } |
45 | 45 |
46 // Fills in |switch_string| and |switch_value| if |string| is a switch. | 46 // Fills in |switch_string| and |switch_value| if |string| is a switch. |
47 // This will preserve the input switch prefix in the output |switch_string|. | 47 // This will preserve the input switch prefix in the output |switch_string|. |
48 bool IsSwitch(const CommandLine::StringType& string, | 48 bool IsSwitch(const CommandLine::StringType& string, |
49 CommandLine::StringType* switch_string, | 49 CommandLine::StringType* switch_string, |
50 CommandLine::StringType* switch_value) { | 50 CommandLine::StringType* switch_value) { |
51 switch_string->clear(); | 51 switch_string->clear(); |
52 switch_value->clear(); | 52 switch_value->clear(); |
53 if (GetSwitchPrefixLength(string) == 0) | 53 size_t prefix_length = GetSwitchPrefixLength(string); |
54 if (prefix_length == 0 || prefix_length == string.length()) | |
marja
2012/10/18 20:53:57
nit: extra space here
jochen (gone - plz use gerrit)
2012/10/18 21:06:42
Done.
| |
54 return false; | 55 return false; |
55 | 56 |
56 const size_t equals_position = string.find(kSwitchValueSeparator); | 57 const size_t equals_position = string.find(kSwitchValueSeparator); |
57 *switch_string = string.substr(0, equals_position); | 58 *switch_string = string.substr(0, equals_position); |
58 if (equals_position != CommandLine::StringType::npos) | 59 if (equals_position != CommandLine::StringType::npos) |
59 *switch_value = string.substr(equals_position + 1); | 60 *switch_value = string.substr(equals_position + 1); |
60 return true; | 61 return true; |
61 } | 62 } |
62 | 63 |
63 // Append switches and arguments, keeping switches before arguments. | 64 // Append switches and arguments, keeping switches before arguments. |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 int num_args = 0; | 396 int num_args = 0; |
396 wchar_t** args = NULL; | 397 wchar_t** args = NULL; |
397 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); | 398 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); |
398 | 399 |
399 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " | 400 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " |
400 << command_line; | 401 << command_line; |
401 InitFromArgv(num_args, args); | 402 InitFromArgv(num_args, args); |
402 LocalFree(args); | 403 LocalFree(args); |
403 } | 404 } |
404 #endif | 405 #endif |
OLD | NEW |