[Scummvm-cvs-logs] SF.net SVN: scummvm:[44265] scummvm/trunk

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Wed Sep 23 02:14:07 CEST 2009


Revision: 44265
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44265&view=rev
Author:   lordhoto
Date:     2009-09-23 00:14:06 +0000 (Wed, 23 Sep 2009)

Log Message:
-----------
COMMON: Add "ignoreCase" parameter to matchString.

Modified Paths:
--------------
    scummvm/trunk/common/archive.cpp
    scummvm/trunk/common/fs.cpp
    scummvm/trunk/common/str.cpp
    scummvm/trunk/common/str.h
    scummvm/trunk/engines/sci/engine/kfile.cpp

Modified: scummvm/trunk/common/archive.cpp
===================================================================
--- scummvm/trunk/common/archive.cpp	2009-09-22 17:53:00 UTC (rev 44264)
+++ scummvm/trunk/common/archive.cpp	2009-09-23 00:14:06 UTC (rev 44265)
@@ -56,7 +56,7 @@
 
 	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++;
 		}

Modified: scummvm/trunk/common/fs.cpp
===================================================================
--- scummvm/trunk/common/fs.cpp	2009-09-22 17:53:00 UTC (rev 44264)
+++ scummvm/trunk/common/fs.cpp	2009-09-23 00:14:06 UTC (rev 44265)
@@ -320,7 +320,7 @@
 	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++;
 		}

Modified: scummvm/trunk/common/str.cpp
===================================================================
--- scummvm/trunk/common/str.cpp	2009-09-22 17:53:00 UTC (rev 44264)
+++ scummvm/trunk/common/str.cpp	2009-09-23 00:14:06 UTC (rev 44265)
@@ -352,12 +352,12 @@
 	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 @@
 	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 @@
 
 		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 @@
 			break;
 
 		default:
-			if (*pat != *str) {
+			if ((!ignoreCase && *pat != *str) ||
+				(ignoreCase && tolower(*pat) != tolower(*str))) {
 				if (p) {
 					// No match, oops -> try to backtrack
 					pat = p;

Modified: scummvm/trunk/common/str.h
===================================================================
--- scummvm/trunk/common/str.h	2009-09-22 17:53:00 UTC (rev 44264)
+++ scummvm/trunk/common/str.h	2009-09-23 00:14:06 UTC (rev 44265)
@@ -170,12 +170,13 @@
 	 *
 	 * @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 @@
  *
  * @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;

Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp	2009-09-22 17:53:00 UTC (rev 44264)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp	2009-09-23 00:14:06 UTC (rev 44265)
@@ -376,7 +376,7 @@
 		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;
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list