mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
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
This commit is contained in:
parent
dc42989b55
commit
8211e82e40
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user