From 6a37a02eee55644d70b7dd07b994b5676e26efa8 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 6 May 2017 19:55:42 -0400 Subject: [PATCH] Switched to `std::ostringstream` to avoid the need to make a string length count (and I was one off when loading a disk). --- StaticAnalyser/Commodore/StaticAnalyser.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/StaticAnalyser/Commodore/StaticAnalyser.cpp b/StaticAnalyser/Commodore/StaticAnalyser.cpp index 23018563a..c1d6aa472 100644 --- a/StaticAnalyser/Commodore/StaticAnalyser.cpp +++ b/StaticAnalyser/Commodore/StaticAnalyser.cpp @@ -13,6 +13,8 @@ #include "Disk.hpp" #include "../../Storage/Cartridge/Encodings/CommodoreROM.hpp" +#include + using namespace StaticAnalyser::Commodore; static std::list> @@ -75,15 +77,15 @@ void StaticAnalyser::Commodore::AddTargets( if(files.size()) { target.vic20.memory_model = Vic20MemoryModel::Unexpanded; - if(files.front().is_basic()) { - char command[16]; - snprintf(command, 16, "LOAD\"%s\",%d,0\nRUN\n", is_disk ? "*" : "", device); - target.loadingCommand = command; + std::ostringstream string_stream; + string_stream << "LOAD\"" << (is_disk ? "*" : "") << "\"," << device << ","; + if(files.front().is_basic()) { + string_stream << "0"; } else { - char command[16]; - snprintf(command, 16, "LOAD\"%s\",%d,1\nRUN\n", is_disk ? "*" : "", device); - target.loadingCommand = command; + string_stream << "1"; } + string_stream << "\nRUN\n"; + target.loadingCommand = string_stream.str(); // make a first guess based on loading address switch(files.front().starting_address) {