[Scummvm-git-logs] scummvm master -> a53c713eb0eda645cc3baabfe4978e46933b1c35

bluegr noreply at scummvm.org
Wed Apr 30 15:51:01 UTC 2025


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

Summary:
a53c713eb0 ENGINES: Deduplicate escapeString and fix unused-function warnings


Commit: a53c713eb0eda645cc3baabfe4978e46933b1c35
    https://github.com/scummvm/scummvm/commit/a53c713eb0eda645cc3baabfe4978e46933b1c35
Author: Orgad Shaneh (orgads at gmail.com)
Date: 2025-04-30T18:50:58+03:00

Commit Message:
ENGINES: Deduplicate escapeString and fix unused-function warnings

The code that uses them in glk and scumm is in #if 0.

Changed paths:
    engines/advancedDetector.cpp
    engines/glk/detection.cpp
    engines/metaengine.cpp
    engines/metaengine.h
    engines/scumm/detection.cpp


diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 96816966bef..663e98d4c22 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -668,23 +668,6 @@ static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngineBase:
 	return true;
 }
 
-// Add backslash before double quotes (") and backslashes themselves (\)
-Common::String escapeString(const char *string) {
-	if (string == nullptr)
-		return "";
-
-	Common::String res = "";
-
-	for (int i = 0; string[i] != '\0'; i++) {
-		if (string[i] == '"' || string[i] == '\\')
-			res += "\\";
-
-		res += string[i];
-	}
-
-	return res;
-}
-
 void AdvancedMetaEngineDetectionBase::dumpDetectionEntries() const {
 	const byte *descPtr;
 
diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp
index 5852a56dc61..697c7631f43 100644
--- a/engines/glk/detection.cpp
+++ b/engines/glk/detection.cpp
@@ -316,23 +316,6 @@ uint GlkMetaEngineDetection::getMD5Bytes() const {
 	return 5000;
 }
 
-// Add backslash before double quotes (") and backslashes themselves (\)
-static Common::String escapeString(const char *string) {
-	if (string == nullptr)
-		return "";
-
-	Common::String res = "";
-
-	for (int i = 0; string[i] != '\0'; i++) {
-		if (string[i] == '"' || string[i] == '\\')
-			res += "\\";
-
-		res += string[i];
-	}
-
-	return res;
-}
-
 void GlkMetaEngineDetection::dumpDetectionEntries() const {
 #if 0
 	enum class EngineName : uint8 {
diff --git a/engines/metaengine.cpp b/engines/metaengine.cpp
index 54817148599..ec96298415b 100644
--- a/engines/metaengine.cpp
+++ b/engines/metaengine.cpp
@@ -38,6 +38,23 @@
 
 const char MetaEngineDetection::GAME_NOT_IMPLEMENTED[] = _s("Game not implemented");
 
+// Add backslash before double quotes (") and backslashes themselves (\)
+Common::String MetaEngineDetection::escapeString(const char *string) {
+	if (string == nullptr)
+		return "";
+
+	Common::String res = "";
+
+	for (int i = 0; string[i] != '\0'; i++) {
+		if (string[i] == '"' || string[i] == '\\')
+			res += "\\";
+
+		res += string[i];
+	}
+
+	return res;
+}
+
 Common::String MetaEngine::getSavegameFile(int saveGameIdx, const char *target) const {
 	if (!target)
 		target = getName();
diff --git a/engines/metaengine.h b/engines/metaengine.h
index 3157582297f..116cd4c5491 100644
--- a/engines/metaengine.h
+++ b/engines/metaengine.h
@@ -124,6 +124,12 @@ struct ExtendedSavegameHeader {
  * To instantiate actual Engine objects, see the class @ref MetaEngine.
  */
 class MetaEngineDetection : public PluginObject {
+protected:
+	/** Internal: Add backslash before double quotes (") and backslashes themselves (\)
+	 *  Used for dumping detection entries.
+	 */
+	static Common::String escapeString(const char *string);
+
 public:
 	/**
 	 * This is the message to use in detection tables when
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index c9cb04b8edc..f2c9b20f952 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -107,23 +107,6 @@ PlainGameList ScummMetaEngineDetection::getSupportedGames() const {
 	return PlainGameList(gameDescriptions);
 }
 
-// Add backslash before double quotes (") and backslashes themselves (\)
-static Common::String escapeString(const char *string) {
-	if (string == nullptr)
-		return "";
-
-	Common::String res = "";
-
-	for (int i = 0; string[i] != '\0'; i++) {
-		if (string[i] == '"' || string[i] == '\\')
-			res += "\\";
-
-		res += string[i];
-	}
-
-	return res;
-}
-
 GameFilenamePattern ScummMetaEngineDetection::matchGameFilenamePattern(const MD5Table *entry) const {
 	GameFilenamePattern bestMatch = GameFilenamePattern();
 




More information about the Scummvm-git-logs mailing list