diff --git a/Source/DSPTool/DSPTool.cpp b/Source/DSPTool/DSPTool.cpp index bd100e6d83..5cb0547b30 100644 --- a/Source/DSPTool/DSPTool.cpp +++ b/Source/DSPTool/DSPTool.cpp @@ -2,7 +2,11 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Common/Common.h" +#include +#include +#include + +#include "Common/CommonTypes.h" #include "Common/FileUtil.h" #include "Common/StringUtil.h" #include "Core/DSP/DSPCodeUtil.h" @@ -235,6 +239,23 @@ static bool PerformDisassembly(const std::string& input_name, const std::string& return true; } +static std::vector GetAssemblerFiles(const std::string& source) +{ + std::vector files; + std::size_t last_pos = 0; + std::size_t pos = 0; + + while ((pos = source.find('\n', last_pos)) != std::string::npos) + { + std::string temp = source.substr(last_pos, pos - last_pos); + if (!temp.empty()) + files.push_back(std::move(temp)); + last_pos = pos + 1; + } + + return files; +} + static bool PerformAssembly(const std::string& input_name, const std::string& output_name, const std::string& output_header_name, bool multiple, bool force, bool output_size) @@ -250,34 +271,23 @@ static bool PerformAssembly(const std::string& input_name, const std::string& ou { if (multiple) { + source.append("\n"); + // When specifying a list of files we must compile a header // (we can't assemble multiple files to one binary) // since we checked it before, we assume output_header_name isn't empty - int lines; - std::vector* codes; - std::vector files; - std::string header, currentSource; - size_t lastPos = 0, pos = 0; - - source.append("\n"); - - while ((pos = source.find('\n', lastPos)) != std::string::npos) - { - std::string temp = source.substr(lastPos, pos - lastPos); - if (!temp.empty()) - files.push_back(temp); - lastPos = pos + 1; - } - - lines = (int)files.size(); + std::string header; + std::string currentSource; + const std::vector files = GetAssemblerFiles(source); + int lines = static_cast(files.size()); if (lines == 0) { printf("ERROR: Must specify at least one file\n"); return false; } - codes = new std::vector[lines]; + std::vector* codes = new std::vector[lines]; for (int i = 0; i < lines; i++) {