Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: base/environment.cc

Issue 1280473002: Update ToLower/UpperASCII API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/files/file_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 7 #include <vector>
8 8
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 15 matching lines...) Expand all
26 if (GetVarImpl(variable_name, result)) 26 if (GetVarImpl(variable_name, result))
27 return true; 27 return true;
28 28
29 // Some commonly used variable names are uppercase while others 29 // Some commonly used variable names are uppercase while others
30 // are lowercase, which is inconsistent. Let's try to be helpful 30 // are lowercase, which is inconsistent. Let's try to be helpful
31 // and look for a variable name with the reverse case. 31 // and look for a variable name with the reverse case.
32 // I.e. HTTP_PROXY may be http_proxy for some users/systems. 32 // I.e. HTTP_PROXY may be http_proxy for some users/systems.
33 char first_char = variable_name[0]; 33 char first_char = variable_name[0];
34 std::string alternate_case_var; 34 std::string alternate_case_var;
35 if (first_char >= 'a' && first_char <= 'z') 35 if (first_char >= 'a' && first_char <= 'z')
36 alternate_case_var = StringToUpperASCII(std::string(variable_name)); 36 alternate_case_var = ToUpperASCII(variable_name);
37 else if (first_char >= 'A' && first_char <= 'Z') 37 else if (first_char >= 'A' && first_char <= 'Z')
38 alternate_case_var = StringToLowerASCII(std::string(variable_name)); 38 alternate_case_var = ToLowerASCII(variable_name);
39 else 39 else
40 return false; 40 return false;
41 return GetVarImpl(alternate_case_var.c_str(), result); 41 return GetVarImpl(alternate_case_var.c_str(), result);
42 } 42 }
43 43
44 bool SetVar(const char* variable_name, 44 bool SetVar(const char* variable_name,
45 const std::string& new_value) override { 45 const std::string& new_value) override {
46 return SetVarImpl(variable_name, new_value); 46 return SetVarImpl(variable_name, new_value);
47 } 47 }
48 48
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 for (size_t i = 0; i < result_indices.size(); i++) 227 for (size_t i = 0; i < result_indices.size(); i++)
228 result[i] = &storage_data[result_indices[i]]; 228 result[i] = &storage_data[result_indices[i]];
229 result[result_indices.size()] = 0; // Null terminator. 229 result[result_indices.size()] = 0; // Null terminator.
230 230
231 return result.Pass(); 231 return result.Pass();
232 } 232 }
233 233
234 #endif // OS_POSIX 234 #endif // OS_POSIX
235 235
236 } // namespace base 236 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/files/file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698