aboutsummaryrefslogtreecommitdiff
path: root/common/str.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2009-09-23 00:14:06 +0000
committerJohannes Schickel2009-09-23 00:14:06 +0000
commit75113ad5f325f7b6ab802becf845705f97dd629e (patch)
tree9a85782d7ee18226dc8355e3add9b4c37905693a /common/str.cpp
parentebde95b3d85ffd0cfc93d84a7e4cf6c75b485408 (diff)
downloadscummvm-rg350-75113ad5f325f7b6ab802becf845705f97dd629e.tar.gz
scummvm-rg350-75113ad5f325f7b6ab802becf845705f97dd629e.tar.bz2
scummvm-rg350-75113ad5f325f7b6ab802becf845705f97dd629e.zip
COMMON: Add "ignoreCase" parameter to matchString.
svn-id: r44265
Diffstat (limited to 'common/str.cpp')
-rw-r--r--common/str.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/common/str.cpp b/common/str.cpp
index b422a34c3c..0d00cd9378 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -352,12 +352,12 @@ bool String::contains(char x) const {
return strchr(c_str(), x) != NULL;
}
-bool String::matchString(const char *pat, bool pathMode) const {
- return Common::matchString(c_str(), pat, pathMode);
+bool String::matchString(const char *pat, bool ignoreCase, bool pathMode) const {
+ return Common::matchString(c_str(), pat, ignoreCase, pathMode);
}
-bool String::matchString(const String &pat, bool pathMode) const {
- return Common::matchString(c_str(), pat.c_str(), pathMode);
+bool String::matchString(const String &pat, bool ignoreCase, bool pathMode) const {
+ return Common::matchString(c_str(), pat.c_str(), ignoreCase, pathMode);
}
void String::deleteLastChar() {
@@ -664,7 +664,7 @@ Common::String normalizePath(const Common::String &path, const char sep) {
return result;
}
-bool matchString(const char *str, const char *pat, bool pathMode) {
+bool matchString(const char *str, const char *pat, bool ignoreCase, bool pathMode) {
assert(str);
assert(pat);
@@ -681,7 +681,7 @@ bool matchString(const char *str, const char *pat, bool pathMode) {
switch (*pat) {
case '*':
- // Record pattern / string possition for backtracking
+ // Record pattern / string position for backtracking
p = ++pat;
q = str;
// If pattern ended with * -> match
@@ -690,7 +690,8 @@ bool matchString(const char *str, const char *pat, bool pathMode) {
break;
default:
- if (*pat != *str) {
+ if ((!ignoreCase && *pat != *str) ||
+ (ignoreCase && tolower(*pat) != tolower(*str))) {
if (p) {
// No match, oops -> try to backtrack
pat = p;