[Scummvm-git-logs] scummvm master -> 08ae52608c07be9848718f699e26ec63bb55f607

bluegr bluegr at gmail.com
Sun Mar 3 21:44:33 CET 2019


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
85333d8050 COMMON: Allow '\#' to match '#' in matchString
08ae52608c SCI: Fix sync36 patch files not being loaded


Commit: 85333d805036f423114ce811d701b21d2509ec52
    https://github.com/scummvm/scummvm/commit/85333d805036f423114ce811d701b21d2509ec52
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2019-03-03T22:44:29+02:00

Commit Message:
COMMON: Allow '\#' to match '#' in matchString

matchString patterns couldn't be used to find files with the # character
as it was only treated as a digit wildcard. SCI expected that to work as
it looks for files that start with the # character.

Changed paths:
    common/str.cpp
    common/str.h
    test/common/str.h


diff --git a/common/str.cpp b/common/str.cpp
index 8ed652f..24341dd 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -884,6 +884,7 @@ bool matchString(const char *str, const char *pat, bool ignoreCase, bool pathMod
 
 	const char *p = nullptr;
 	const char *q = nullptr;
+	bool escaped = false;
 
 	for (;;) {
 		if (pathMode && *str == '/') {
@@ -893,6 +894,7 @@ bool matchString(const char *str, const char *pat, bool ignoreCase, bool pathMod
 				return false;
 		}
 
+		const char curPat = *pat;
 		switch (*pat) {
 		case '*':
 			if (*str) {
@@ -912,12 +914,23 @@ bool matchString(const char *str, const char *pat, bool ignoreCase, bool pathMod
 				return true;
 			break;
 
+		case '\\':
+			if (!escaped) {
+				pat++;
+				break;
+			}
+			// fallthrough
+
 		case '#':
-			if (!isDigit(*str))
-				return false;
-			pat++;
-			str++;
-			break;
+			// treat # as a wildcard for digits unless escaped
+			if (!escaped) {
+				if (!isDigit(*str))
+					return false;
+				pat++;
+				str++;
+				break;
+			}
+			// fallthrough
 
 		default:
 			if ((!ignoreCase && *pat != *str) ||
@@ -940,6 +953,8 @@ bool matchString(const char *str, const char *pat, bool ignoreCase, bool pathMod
 			pat++;
 			str++;
 		}
+
+		escaped = !escaped && (curPat == '\\');
 	}
 }
 
diff --git a/common/str.h b/common/str.h
index 704114b..54044cf 100644
--- a/common/str.h
+++ b/common/str.h
@@ -179,6 +179,7 @@ public:
 	 *      "*": any character, any amount of times.
 	 *      "?": any character, only once.
 	 *      "#": any decimal digit, only once.
+	 *      "\#": #, only once.
 	 *
 	 * Example strings/patterns:
 	 *      String: monkey.s01   Pattern: monkey.s??    => true
diff --git a/test/common/str.h b/test/common/str.h
index 783ed53..3c69d17 100644
--- a/test/common/str.h
+++ b/test/common/str.h
@@ -335,6 +335,10 @@ class StringTestSuite : public CxxTest::TestSuite
 		TS_ASSERT(Common::matchString("monkey.s01",  "monkey.s##"));
 		TS_ASSERT(!Common::matchString("monkey.s01", "monkey.###"));
 
+		TS_ASSERT(Common::matchString("monkey.s0#", "monkey.s0\\#"));
+		TS_ASSERT(!Common::matchString("monkey.s0#", "monkey.s0#"));
+		TS_ASSERT(!Common::matchString("monkey.s01", "monkey.s0\\#"));
+
 		TS_ASSERT(!Common::String("").matchString("*_"));
 		TS_ASSERT(Common::String("a").matchString("a***"));
 	}


Commit: 08ae52608c07be9848718f699e26ec63bb55f607
    https://github.com/scummvm/scummvm/commit/08ae52608c07be9848718f699e26ec63bb55f607
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2019-03-03T22:44:29+02:00

Commit Message:
SCI: Fix sync36 patch files not being loaded

Fixes GK1 bug #10788

Changed paths:
    engines/sci/resource.cpp


diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index b2b422f..df91fb8 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -1613,7 +1613,7 @@ void ResourceManager::readResourcePatchesBase36() {
 			SearchMan.listMatchingMembers(files, "A???????.???");
 			SearchMan.listMatchingMembers(files, "B???????.???");
 		} else {
-			SearchMan.listMatchingMembers(files, "#???????.???");
+			SearchMan.listMatchingMembers(files, "\\#???????.???");
 #ifdef ENABLE_SCI32
 			SearchMan.listMatchingMembers(files, "S???????.???");
 			SearchMan.listMatchingMembers(files, "T???????.???");





More information about the Scummvm-git-logs mailing list