mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-15 08:49:20 +01:00
StringUtil: StringPopBackIf added
This commit is contained in:
parent
1209959012
commit
f28f23af1d
@ -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());
|
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
|
#ifdef _WIN32
|
||||||
|
|
||||||
std::string UTF16ToUTF8(const std::wstring& input)
|
std::string UTF16ToUTF8(const std::wstring& input)
|
||||||
|
@ -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 StringBeginsWith(const std::string& str, const std::string& begin);
|
||||||
bool StringEndsWith(const std::string& str, const std::string& end);
|
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 CP1252ToUTF8(const std::string& str);
|
||||||
std::string SHIFTJISToUTF8(const std::string& str);
|
std::string SHIFTJISToUTF8(const std::string& str);
|
||||||
|
@ -33,10 +33,8 @@ void HLE_OSPanic()
|
|||||||
std::string error = GetStringVA();
|
std::string error = GetStringVA();
|
||||||
std::string msg = GetStringVA(5);
|
std::string msg = GetStringVA(5);
|
||||||
|
|
||||||
if (!error.empty() && error.back() == '\n')
|
StringPopBackIf(&error, '\n');
|
||||||
error.pop_back();
|
StringPopBackIf(&msg, '\n');
|
||||||
if (!msg.empty() && msg.back() == '\n')
|
|
||||||
msg.pop_back();
|
|
||||||
|
|
||||||
PanicAlert("OSPanic: %s: %s", error.c_str(), msg.c_str());
|
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());
|
ERROR_LOG(OSREPORT, "%08x->%08x| OSPanic: %s: %s", LR, PC, error.c_str(), msg.c_str());
|
||||||
@ -77,8 +75,7 @@ void HLE_GeneralDebugPrint(ParameterType parameter_type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!report_message.empty() && report_message.back() == '\n')
|
StringPopBackIf(&report_message, '\n');
|
||||||
report_message.pop_back();
|
|
||||||
|
|
||||||
NPC = LR;
|
NPC = LR;
|
||||||
|
|
||||||
@ -116,8 +113,7 @@ void HLE_write_console()
|
|||||||
ERROR_LOG(OSREPORT, "__write_console uses an unreachable size pointer");
|
ERROR_LOG(OSREPORT, "__write_console uses an unreachable size pointer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!report_message.empty() && report_message.back() == '\n')
|
StringPopBackIf(&report_message, '\n');
|
||||||
report_message.pop_back();
|
|
||||||
|
|
||||||
NPC = LR;
|
NPC = LR;
|
||||||
|
|
||||||
@ -133,6 +129,7 @@ void HLE_LogDPrint(ParameterType parameter_type)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
std::string report_message = GetStringVA(4, parameter_type);
|
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());
|
NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,6 +169,7 @@ void HLE_LogFPrint(ParameterType parameter_type)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
std::string report_message = GetStringVA(4, parameter_type);
|
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());
|
NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user