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

Side by Side Diff: base/string_util.cc

Issue 340057: Add first-class support for user scripts (Closed)
Patch Set: newness Created 11 years, 1 month 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/string_util.h" 5 #include "base/string_util.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <ctype.h> 9 #include <ctype.h>
10 #include <errno.h> 10 #include <errno.h>
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 return false; 844 return false;
845 if (case_sensitive) { 845 if (case_sensitive) {
846 return str.compare(str_length - search_length, search_length, search) == 0; 846 return str.compare(str_length - search_length, search_length, search) == 0;
847 } else { 847 } else {
848 return std::equal(search.begin(), search.end(), 848 return std::equal(search.begin(), search.end(),
849 str.begin() + (str_length - search_length), 849 str.begin() + (str_length - search_length),
850 CaseInsensitiveCompare<typename STR::value_type>()); 850 CaseInsensitiveCompare<typename STR::value_type>());
851 } 851 }
852 } 852 }
853 853
854 bool EndsWith(const std::string& str, const std::string& search,
855 bool case_sensitive) {
856 return EndsWithT(str, search, case_sensitive);
857 }
858
854 bool EndsWith(const std::wstring& str, const std::wstring& search, 859 bool EndsWith(const std::wstring& str, const std::wstring& search,
855 bool case_sensitive) { 860 bool case_sensitive) {
856 return EndsWithT(str, search, case_sensitive); 861 return EndsWithT(str, search, case_sensitive);
857 } 862 }
858 863
859 #if !defined(WCHAR_T_IS_UTF16) 864 #if !defined(WCHAR_T_IS_UTF16)
860 bool EndsWith(const string16& str, const string16& search, 865 bool EndsWith(const string16& str, const string16& search,
861 bool case_sensitive) { 866 bool case_sensitive) {
862 return EndsWithT(str, search, case_sensitive); 867 return EndsWithT(str, search, case_sensitive);
863 } 868 }
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 // Each input byte creates two output hex characters. 1810 // Each input byte creates two output hex characters.
1806 std::string ret(size * 2, '\0'); 1811 std::string ret(size * 2, '\0');
1807 1812
1808 for (size_t i = 0; i < size; ++i) { 1813 for (size_t i = 0; i < size; ++i) {
1809 char b = reinterpret_cast<const char*>(bytes)[i]; 1814 char b = reinterpret_cast<const char*>(bytes)[i];
1810 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf]; 1815 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf];
1811 ret[(i * 2) + 1] = kHexChars[b & 0xf]; 1816 ret[(i * 2) + 1] = kHexChars[b & 0xf];
1812 } 1817 }
1813 return ret; 1818 return ret;
1814 } 1819 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698