[Scummvm-cvs-logs] scummvm master -> 0d379b3783e368160476c78d31b05a9e9914e782

digitall digitall at scummvm.org
Thu Jun 2 04:46:33 CEST 2011


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

Summary:
0d379b3783 CINE: Replace snprintf() usage with Common::String::format()


Commit: 0d379b3783e368160476c78d31b05a9e9914e782
    https://github.com/scummvm/scummvm/commit/0d379b3783e368160476c78d31b05a9e9914e782
Author: D G Turner (digitall at scummvm.org)
Date: 2011-06-01T19:44:31-07:00

Commit Message:
CINE: Replace snprintf() usage with Common::String::format()

Safer and less portability issues.

Changed paths:
    engines/cine/detection.cpp
    engines/cine/saveload.cpp
    engines/cine/various.cpp



diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp
index 0ef2c87..64eee45 100644
--- a/engines/cine/detection.cpp
+++ b/engines/cine/detection.cpp
@@ -185,10 +185,7 @@ void CineMetaEngine::removeSaveState(const char *target, int slot) const {
 	memset(saveNames, 0, sizeof(saveNames));
 
 	Common::InSaveFile *in;
-	char tmp[80];
-
-	snprintf(tmp, 80, "%s.dir", target);
-	in = g_system->getSavefileManager()->openForLoading(tmp);
+	in = g_system->getSavefileManager()->openForLoading(Common::String::format("%s.dir", target));
 
 	if (!in)
 		return;
@@ -202,12 +199,10 @@ void CineMetaEngine::removeSaveState(const char *target, int slot) const {
 	strncpy(saveNames[slot], slotName, 20);
 
 	// Update savegame descriptions
-	char indexFile[80];
-	snprintf(indexFile, 80, "%s.dir", target);
-
+	Common::String indexFile = Common::String::format("%s.dir", target);
 	Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(indexFile);
 	if (!out) {
-		warning("Unable to open file %s for saving", indexFile);
+		warning("Unable to open file %s for saving", indexFile.c_str());
 		return;
 	}
 
@@ -246,12 +241,11 @@ Common::Error CineEngine::saveGameState(int slot, const char *desc) {
 	currentSaveName[slot][sizeof(CommandeType) - 1] = 0;
 
 	// Update savegame descriptions
-	char indexFile[80];
-	snprintf(indexFile, 80, "%s.dir", _targetName.c_str());
+	Common::String indexFile = Common::String::format("%s.dir", _targetName.c_str());
 
 	Common::OutSaveFile *fHandle = _saveFileMan->openForSaving(indexFile);
 	if (!fHandle) {
-		warning("Unable to open file %s for saving", indexFile);
+		warning("Unable to open file %s for saving", indexFile.c_str());
 		return Common::kUnknownError;
 	}
 
diff --git a/engines/cine/saveload.cpp b/engines/cine/saveload.cpp
index 700875e..e51d07b 100644
--- a/engines/cine/saveload.cpp
+++ b/engines/cine/saveload.cpp
@@ -460,10 +460,7 @@ void saveSeqList(Common::OutSaveFile &out) {
 
 bool CineEngine::loadSaveDirectory() {
 	Common::InSaveFile *fHandle;
-	char tmp[80];
-
-	snprintf(tmp, 80, "%s.dir", _targetName.c_str());
-	fHandle = _saveFileMan->openForLoading(tmp);
+	fHandle = _saveFileMan->openForLoading(Common::String::format("%s.dir", _targetName.c_str()));
 
 	if (!fHandle) {
 		return false;
diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp
index 1892a78..81e72d6 100644
--- a/engines/cine/various.cpp
+++ b/engines/cine/various.cpp
@@ -440,13 +440,12 @@ void CineEngine::makeSystemMenu() {
 
 					getMouseData(mouseUpdateStatus, (uint16 *)&mouseButton, (uint16 *)&mouseX, (uint16 *)&mouseY);
 					if (!makeMenuChoice(confirmMenu, 2, mouseX, mouseY + 8, 100)) {
-						char saveString[256], tmp[80];
-
-						snprintf(tmp, 80, "%s.dir", _targetName.c_str());
+						char saveString[256];
+						Common::String tmp = Common::String::format("%s.dir", _targetName.c_str());
 
 						Common::OutSaveFile *fHandle = _saveFileMan->openForSaving(tmp);
 						if (!fHandle) {
-							warning("Unable to open file %s for saving", tmp);
+							warning("Unable to open file %s for saving", tmp.c_str());
 							break;
 						}
 






More information about the Scummvm-git-logs mailing list