diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index 80c74ac8a7..6548205fb0 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -405,6 +405,12 @@ bool StringEndsWith(const std::string& str, const std::string& end) return str.size() >= end.size() && std::equal(end.rbegin(), end.rend(), str.rbegin()); } +void StringPopBackIf(std::string* s, char c) +{ + if (!s->empty() && s->back() == c) + s->pop_back(); +} + #ifdef _WIN32 std::string UTF16ToUTF8(const std::wstring& input) diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index 3ea288bb4d..86d7ba1e9c 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -119,6 +119,7 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st bool StringBeginsWith(const std::string& str, const std::string& begin); bool StringEndsWith(const std::string& str, const std::string& end); +void StringPopBackIf(std::string* s, char c); std::string CP1252ToUTF8(const std::string& str); std::string SHIFTJISToUTF8(const std::string& str); diff --git a/Source/Core/Core/HLE/HLE_OS.cpp b/Source/Core/Core/HLE/HLE_OS.cpp index aa3fc590cc..12a5ec1370 100644 --- a/Source/Core/Core/HLE/HLE_OS.cpp +++ b/Source/Core/Core/HLE/HLE_OS.cpp @@ -33,6 +33,9 @@ void HLE_OSPanic() std::string error = GetStringVA(); std::string msg = GetStringVA(5); + StringPopBackIf(&error, '\n'); + StringPopBackIf(&msg, '\n'); + PanicAlert("OSPanic: %s: %s", error.c_str(), msg.c_str()); ERROR_LOG(OSREPORT, "%08x->%08x| OSPanic: %s: %s", LR, PC, error.c_str(), msg.c_str()); @@ -72,6 +75,8 @@ void HLE_GeneralDebugPrint(ParameterType parameter_type) } } + StringPopBackIf(&report_message, '\n'); + NPC = LR; NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str()); @@ -108,6 +113,8 @@ void HLE_write_console() ERROR_LOG(OSREPORT, "__write_console uses an unreachable size pointer"); } + StringPopBackIf(&report_message, '\n'); + NPC = LR; NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str()); @@ -122,6 +129,7 @@ void HLE_LogDPrint(ParameterType parameter_type) return; std::string report_message = GetStringVA(4, parameter_type); + StringPopBackIf(&report_message, '\n'); NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str()); } @@ -161,6 +169,7 @@ void HLE_LogFPrint(ParameterType parameter_type) return; std::string report_message = GetStringVA(4, parameter_type); + StringPopBackIf(&report_message, '\n'); NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str()); } @@ -251,9 +260,6 @@ std::string GetStringVA(u32 str_reg, ParameterType parameter_type) } } - if (!result.empty() && result.back() == '\n') - result.pop_back(); - return result; }