From 7065c87a0d67ba4ec0536e52a465688edadbc602 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 19 Jul 2010 14:54:25 +0000 Subject: replaced use of snprintf by String::printf svn-id: r51030 --- engines/testbed/graphics.cpp | 4 ++-- engines/testbed/misc.cpp | 14 +++++--------- engines/testbed/misc.h | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) (limited to 'engines/testbed') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 70bf267456..bac680ae7e 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -918,9 +918,9 @@ bool GFXtests::pixelFormats() { colors[5] = iter->RGBToColor(47, 78, 36); Common::Point pt(0, 170); - char msg[100]; + Common::String msg; // XXX: Can use snprintf? - snprintf(msg, sizeof(msg), "Testing Pixel Formats, %d of %d", numFormatsTested, pfList.size()); + msg = Common::String::printf("Testing Pixel Formats, %d of %d", numFormatsTested, pfList.size()); Testsuite::writeOnScreen(msg, pt, true); // CopyRectToScreen could have been used, but that may involve writing code which diff --git a/engines/testbed/misc.cpp b/engines/testbed/misc.cpp index 8a27e324ec..7e21398451 100644 --- a/engines/testbed/misc.cpp +++ b/engines/testbed/misc.cpp @@ -27,12 +27,8 @@ namespace Testbed { -void MiscTests::getHumanReadableFormat(TimeDate &td, Common::String &date) { - // XXX: can use snprintf? - char strDate[100]; - snprintf(strDate, 100, "%d:%d:%d on %d/%d/%d (dd/mm/yy)", td.tm_hour, td.tm_min, td.tm_sec, td.tm_mday, td.tm_mon, td.tm_year + 1900); - date = strDate; - return; +Common::String MiscTests::getHumanReadableFormat(TimeDate &td) { + return Common::String::printf("%d:%d:%d on %d/%d/%d (dd/mm/yyyy)", td.tm_hour, td.tm_min, td.tm_sec, td.tm_mday, td.tm_mon + 1, td.tm_year + 1900); } void MiscTests::timerCallback(void *arg) { @@ -75,7 +71,7 @@ bool MiscTests::testDateTime() { g_system->getTimeAndDate(t1); Testsuite::logDetailedPrintf("Current Time and Date: "); Common::String dateTimeNow; - getHumanReadableFormat(t1, dateTimeNow); + dateTimeNow = getHumanReadableFormat(t1); if (Testsuite::isSessionInteractive) { // Directly verify date @@ -87,13 +83,13 @@ bool MiscTests::testDateTime() { } g_system->getTimeAndDate(t1); - getHumanReadableFormat(t1, dateTimeNow); + dateTimeNow = getHumanReadableFormat(t1); Testsuite::logDetailedPrintf("%s\n", dateTimeNow.c_str()); // Now, Put some delay g_system->delayMillis(2000); g_system->getTimeAndDate(t2); Testsuite::logDetailedPrintf("Time and Date 2s later: "); - getHumanReadableFormat(t2, dateTimeNow); + dateTimeNow = getHumanReadableFormat(t2); Testsuite::logDetailedPrintf("%s\n", dateTimeNow.c_str()); if (t1.tm_year == t2.tm_year && t1.tm_mon == t2.tm_mon && t1.tm_mday == t2.tm_mday) { diff --git a/engines/testbed/misc.h b/engines/testbed/misc.h index d1a9b48182..1ca01224e5 100644 --- a/engines/testbed/misc.h +++ b/engines/testbed/misc.h @@ -43,7 +43,7 @@ namespace MiscTests { // Miscellaneous tests include testing datetime, timers and mutexes // Helper functions for Misc tests -void getHumanReadableFormat(TimeDate &td, Common::String &date); +Common::String getHumanReadableFormat(TimeDate &td); void timerCallback(void *arg); void criticalSection(void *arg); -- cgit v1.2.3