summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/StringExtras.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-01-26 20:36:29 +0000
committerChris Lattner <sabre@nondot.org>2006-01-26 20:36:29 +0000
commit8211e82e40b8f6c0e200933f25aa4d9fe2cf4edc (patch)
tree5dbe5416d3c851c49f2b7ddaee128c832ed055c0 /include/llvm/ADT/StringExtras.h
parentdc42989b5546053898f6b4f0b783224487db627f (diff)
downloadllvm-8211e82e40b8f6c0e200933f25aa4d9fe2cf4edc.tar.gz
llvm-8211e82e40b8f6c0e200933f25aa4d9fe2cf4edc.tar.bz2
llvm-8211e82e40b8f6c0e200933f25aa4d9fe2cf4edc.tar.xz
add some methods for case-insensitive string compares
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25659 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringExtras.h')
-rw-r--r--include/llvm/ADT/StringExtras.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h
index 32f9b0c907..bd8333909c 100644
--- a/include/llvm/ADT/StringExtras.h
+++ b/include/llvm/ADT/StringExtras.h
@@ -113,6 +113,27 @@ static inline std::string LowercaseString(const std::string &S) {
return result;
}
+/// StringsEqualNoCase - Return true if the two strings are equal, ignoring
+/// case.
+static inline bool StringsEqualNoCase(const std::string &LHS,
+ const std::string &RHS) {
+ if (LHS.size() != RHS.size()) return false;
+ for (unsigned i = 0, e = LHS.size(); i != e; ++i)
+ if (tolower(LHS[i]) != tolower(RHS[i])) return false;
+ return true;
+}
+
+/// StringsEqualNoCase - Return true if the two strings are equal, ignoring
+/// case.
+static inline bool StringsEqualNoCase(const std::string &LHS,
+ const char *RHS) {
+ for (unsigned i = 0, e = LHS.size(); i != e; ++i) {
+ if (RHS[i] == 0) return false; // RHS too short.
+ if (tolower(LHS[i]) != tolower(RHS[i])) return false;
+ }
+ return RHS[LHS.size()] == 0; // Not too long?
+}
+
/// getToken - This function extracts one token from source, ignoring any
/// leading characters that appear in the Delimiters string, and ending the
/// token at any of the characters that appear in the Delimiters string. If