aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/archive.cpp2
-rw-r--r--common/fs.cpp2
-rw-r--r--common/str.cpp15
-rw-r--r--common/str.h8
-rw-r--r--engines/sci/engine/kfile.cpp2
5 files changed, 16 insertions, 13 deletions
diff --git a/common/archive.cpp b/common/archive.cpp
index 86ae5b6795..ecc00f4cff 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -56,7 +56,7 @@ int Archive::listMatchingMembers(ArchiveMemberList &list, const String &pattern)
ArchiveMemberList::iterator it = allNames.begin();
for ( ; it != allNames.end(); ++it) {
- if ((*it)->getName().matchString(lowercasePattern, true)) {
+ if ((*it)->getName().matchString(lowercasePattern, false, true)) {
list.push_back(*it);
matches++;
}
diff --git a/common/fs.cpp b/common/fs.cpp
index 742177ea4a..1bc1c370b9 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -320,7 +320,7 @@ int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &patt
int matches = 0;
NodeCache::iterator it = _fileCache.begin();
for ( ; it != _fileCache.end(); ++it) {
- if (it->_key.matchString(lowercasePattern, true)) {
+ if (it->_key.matchString(lowercasePattern, false, true)) {
list.push_back(ArchiveMemberPtr(new FSNode(it->_value)));
matches++;
}
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;
diff --git a/common/str.h b/common/str.h
index 2fc88e9c91..f69fc268e1 100644
--- a/common/str.h
+++ b/common/str.h
@@ -170,12 +170,13 @@ public:
*
* @param str Text to be matched against the given pattern.
* @param pat Glob pattern.
+ * @param ignoreCase Whether to ignore the case when doing pattern match
* @param pathMode Whether to use path mode, i.e., whether slashes must be matched explicitly.
*
* @return true if str matches the pattern, false otherwise.
*/
- bool matchString(const char *pat, bool pathMode = false) const;
- bool matchString(const String &pat, bool pathMode = false) const;
+ bool matchString(const char *pat, bool ignoreCase = false, bool pathMode = false) const;
+ bool matchString(const String &pat, bool ignoreCase = false, bool pathMode = false) const;
inline const char *c_str() const { return _str; }
@@ -316,11 +317,12 @@ Common::String normalizePath(const Common::String &path, const char sep);
*
* @param str Text to be matched against the given pattern.
* @param pat Glob pattern.
+ * @param ignoreCase Whether to ignore the case when doing pattern match
* @param pathMode Whether to use path mode, i.e., whether slashes must be matched explicitly.
*
* @return true if str matches the pattern, false otherwise.
*/
-bool matchString(const char *str, const char *pat, bool pathMode = false);
+bool matchString(const char *str, const char *pat, bool ignoreCase = false, bool pathMode = false);
typedef Array<String> StringList;
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 51ef1ddb7c..e41be678c0 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -376,7 +376,7 @@ reg_t kDeviceInfo(EngineState *s, int, int argc, reg_t *argv) {
char *path2_s = s->segMan->derefString(argv[2]);
debug(3, "K_DEVICE_INFO_PATHS_EQUAL(%s,%s)", path1_s, path2_s);
- return make_reg(0, Common::matchString(path2_s, path1_s, true));
+ return make_reg(0, Common::matchString(path2_s, path1_s, false, true));
}
break;