OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 19 matching lines...) Expand all Loading... |
30 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
31 const CommandLine::CharType* const kSwitchPrefixes[] = {L"--", L"-", L"/"}; | 31 const CommandLine::CharType* const kSwitchPrefixes[] = {L"--", L"-", L"/"}; |
32 #elif defined(OS_POSIX) | 32 #elif defined(OS_POSIX) |
33 // Unixes don't use slash as a switch. | 33 // Unixes don't use slash as a switch. |
34 const CommandLine::CharType* const kSwitchPrefixes[] = {"--", "-"}; | 34 const CommandLine::CharType* const kSwitchPrefixes[] = {"--", "-"}; |
35 #endif | 35 #endif |
36 | 36 |
37 size_t GetSwitchPrefixLength(const CommandLine::StringType& string) { | 37 size_t GetSwitchPrefixLength(const CommandLine::StringType& string) { |
38 for (size_t i = 0; i < arraysize(kSwitchPrefixes); ++i) { | 38 for (size_t i = 0; i < arraysize(kSwitchPrefixes); ++i) { |
39 CommandLine::StringType prefix(kSwitchPrefixes[i]); | 39 CommandLine::StringType prefix(kSwitchPrefixes[i]); |
40 if (string.find(prefix) == 0) | 40 if (string.compare(0, prefix.length(), prefix) == 0) |
41 return prefix.length(); | 41 return prefix.length(); |
42 } | 42 } |
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) { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 int num_args = 0; | 393 int num_args = 0; |
394 wchar_t** args = NULL; | 394 wchar_t** args = NULL; |
395 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); | 395 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); |
396 | 396 |
397 PLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " << | 397 PLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " << |
398 command_line; | 398 command_line; |
399 InitFromArgv(num_args, args); | 399 InitFromArgv(num_args, args); |
400 LocalFree(args); | 400 LocalFree(args); |
401 } | 401 } |
402 #endif | 402 #endif |
OLD | NEW |