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/environment.h" | 5 #include "base/environment.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 bool GetVar(const char* variable_name, std::string* result) override { | 28 bool GetVar(const char* variable_name, std::string* result) override { |
29 if (GetVarImpl(variable_name, result)) | 29 if (GetVarImpl(variable_name, result)) |
30 return true; | 30 return true; |
31 | 31 |
32 // Some commonly used variable names are uppercase while others | 32 // Some commonly used variable names are uppercase while others |
33 // are lowercase, which is inconsistent. Let's try to be helpful | 33 // are lowercase, which is inconsistent. Let's try to be helpful |
34 // and look for a variable name with the reverse case. | 34 // and look for a variable name with the reverse case. |
35 // I.e. HTTP_PROXY may be http_proxy for some users/systems. | 35 // I.e. HTTP_PROXY may be http_proxy for some users/systems. |
36 char first_char = variable_name[0]; | 36 char first_char = variable_name[0]; |
37 std::string alternate_case_var; | 37 std::string alternate_case_var; |
38 if (first_char >= 'a' && first_char <= 'z') | 38 if (IsAsciiLower(first_char)) |
39 alternate_case_var = ToUpperASCII(variable_name); | 39 alternate_case_var = ToUpperASCII(variable_name); |
40 else if (first_char >= 'A' && first_char <= 'Z') | 40 else if (IsAsciiUpper(first_char)) |
41 alternate_case_var = ToLowerASCII(variable_name); | 41 alternate_case_var = ToLowerASCII(variable_name); |
42 else | 42 else |
43 return false; | 43 return false; |
44 return GetVarImpl(alternate_case_var.c_str(), result); | 44 return GetVarImpl(alternate_case_var.c_str(), result); |
45 } | 45 } |
46 | 46 |
47 bool SetVar(const char* variable_name, | 47 bool SetVar(const char* variable_name, |
48 const std::string& new_value) override { | 48 const std::string& new_value) override { |
49 return SetVarImpl(variable_name, new_value); | 49 return SetVarImpl(variable_name, new_value); |
50 } | 50 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 for (size_t i = 0; i < result_indices.size(); i++) | 230 for (size_t i = 0; i < result_indices.size(); i++) |
231 result[i] = &storage_data[result_indices[i]]; | 231 result[i] = &storage_data[result_indices[i]]; |
232 result[result_indices.size()] = 0; // Null terminator. | 232 result[result_indices.size()] = 0; // Null terminator. |
233 | 233 |
234 return result; | 234 return result; |
235 } | 235 } |
236 | 236 |
237 #endif // OS_POSIX | 237 #endif // OS_POSIX |
238 | 238 |
239 } // namespace base | 239 } // namespace base |
OLD | NEW |