Merge pull request #4751 from lioncash/string

DSPAssembler: Replace char buffer + sprintf with StringFromFormat in ShowError
This commit is contained in:
Markus Wick 2017-01-26 10:24:27 +01:00 committed by GitHub
commit 5baffb39e8
1 changed files with 12 additions and 8 deletions

View File

@ -17,6 +17,7 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/StringUtil.h"
#include "Core/DSP/DSPDisassembler.h" #include "Core/DSP/DSPDisassembler.h"
#include "Core/DSP/DSPTables.h" #include "Core/DSP/DSPTables.h"
@ -92,19 +93,22 @@ void DSPAssembler::ShowError(err_t err_code, const char* extra_info)
if (!settings_.force) if (!settings_.force)
failed = true; failed = true;
char error_buffer[1024]; std::string error = StringFromFormat("%u : %s ", code_line, cur_line.c_str());
char* buf_ptr = error_buffer;
buf_ptr += sprintf(buf_ptr, "%i : %s ", code_line, cur_line.c_str());
if (!extra_info) if (!extra_info)
extra_info = "-"; extra_info = "-";
if (m_current_param == 0) if (m_current_param == 0)
buf_ptr += {
sprintf(buf_ptr, "ERROR: %s Line: %d : %s\n", err_string[err_code], code_line, extra_info); error +=
StringFromFormat("ERROR: %s Line: %u : %s\n", err_string[err_code], code_line, extra_info);
}
else else
buf_ptr += sprintf(buf_ptr, "ERROR: %s Line: %d Param: %d : %s\n", err_string[err_code], {
error += StringFromFormat("ERROR: %s Line: %u Param: %d : %s\n", err_string[err_code],
code_line, m_current_param, extra_info); code_line, m_current_param, extra_info);
last_error_str = error_buffer; }
last_error_str = std::move(error);
last_error = err_code; last_error = err_code;
} }