llvm.org GIT mirror llvm / 8211e82
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 Chris Lattner 14 years ago
1 changed file(s) with 21 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
112112 return result;
113113 }
114114
115 /// StringsEqualNoCase - Return true if the two strings are equal, ignoring
116 /// case.
117 static inline bool StringsEqualNoCase(const std::string &LHS,
118 const std::string &RHS) {
119 if (LHS.size() != RHS.size()) return false;
120 for (unsigned i = 0, e = LHS.size(); i != e; ++i)
121 if (tolower(LHS[i]) != tolower(RHS[i])) return false;
122 return true;
123 }
124
125 /// StringsEqualNoCase - Return true if the two strings are equal, ignoring
126 /// case.
127 static inline bool StringsEqualNoCase(const std::string &LHS,
128 const char *RHS) {
129 for (unsigned i = 0, e = LHS.size(); i != e; ++i) {
130 if (RHS[i] == 0) return false; // RHS too short.
131 if (tolower(LHS[i]) != tolower(RHS[i])) return false;
132 }
133 return RHS[LHS.size()] == 0; // Not too long?
134 }
135
115136 /// getToken - This function extracts one token from source, ignoring any
116137 /// leading characters that appear in the Delimiters string, and ending the
117138 /// token at any of the characters that appear in the Delimiters string. If