[Scummvm-cvs-logs] scummvm master -> 8356656575b4c07229dc0e9bd97fa2f67573de73
digitall
digitall at scummvm.org
Thu Jun 2 03:23: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:
8356656575 GOB: Replace snprintf() usage with Common::String::format()
Commit: 8356656575b4c07229dc0e9bd97fa2f67573de73
https://github.com/scummvm/scummvm/commit/8356656575b4c07229dc0e9bd97fa2f67573de73
Author: D G Turner (digitall at scummvm.org)
Date: 2011-06-01T18:20:51-07:00
Commit Message:
GOB: Replace snprintf() usage with Common::String::format()
Safer and less portability issues.
Changed paths:
engines/gob/resources.cpp
engines/gob/save/savehandler.cpp
engines/gob/sound/sound.cpp
diff --git a/engines/gob/resources.cpp b/engines/gob/resources.cpp
index 92eec0e..d5497c2 100644
--- a/engines/gob/resources.cpp
+++ b/engines/gob/resources.cpp
@@ -603,10 +603,7 @@ bool Resources::dumpResource(const Resource &resource, uint16 id,
Common::String fileName = _fileBase;
- char idStr[7];
-
- snprintf(idStr, 7, "_%05d", id);
- fileName += idStr;
+ fileName += Common::String::format("_%05d", id);
fileName += ".";
fileName += ext;
diff --git a/engines/gob/save/savehandler.cpp b/engines/gob/save/savehandler.cpp
index 9e46f1d..71de629 100644
--- a/engines/gob/save/savehandler.cpp
+++ b/engines/gob/save/savehandler.cpp
@@ -154,8 +154,7 @@ Common::String SlotFileIndexed::build(int slot) const {
if ((slot < 0) || (((uint32) slot) >= _slotCount))
return Common::String();
- char buf[4];
- snprintf(buf, sizeof(buf), "%02d", slot);
+ Common::String buf = Common::String::format("%02d", slot);
return _base + "." + _ext + buf;
}
diff --git a/engines/gob/sound/sound.cpp b/engines/gob/sound/sound.cpp
index 0ad17c1..212116f 100644
--- a/engines/gob/sound/sound.cpp
+++ b/engines/gob/sound/sound.cpp
@@ -667,15 +667,13 @@ void Sound::bgPlay(const char *base, const char *ext, SoundType type, int count)
_bgatmos->stopBA();
_bgatmos->queueClear();
- int length = strlen(base) + 7;
- char *fileName = new char[length];
SoundDesc *sndDesc;
for (int i = 1; i <= count; i++) {
- snprintf(fileName, length, "%s%02d.%s", base, i, ext);
+ Common::String fileName = Common::String::format("%s%02d.%s", base, i, ext);
sndDesc = new SoundDesc;
- if (sampleLoad(sndDesc, type, fileName))
+ if (sampleLoad(sndDesc, type, fileName.c_str()))
_bgatmos->queueSample(*sndDesc);
else
delete sndDesc;
More information about the Scummvm-git-logs
mailing list