mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-17 23:44:22 +00:00
COMMON: Replace some vsnprintf/STRINGBUFLEN uses by vformat
This commit is contained in:
parent
d74e2d3224
commit
b81207a04e
@ -107,18 +107,13 @@ bool DebugManager::isDebugChannelEnabled(uint32 channel) {
|
||||
#ifndef DISABLE_TEXT_CONSOLE
|
||||
|
||||
static void debugHelper(const char *s, va_list va, bool caret = true) {
|
||||
char buf[STRINGBUFLEN];
|
||||
Common::String buf = Common::String::vformat(s, va);
|
||||
|
||||
vsnprintf(buf, STRINGBUFLEN, s, va);
|
||||
buf[STRINGBUFLEN-1] = '\0';
|
||||
|
||||
if (caret) {
|
||||
buf[STRINGBUFLEN-2] = '\0';
|
||||
strcat(buf, "\n");
|
||||
}
|
||||
if (caret)
|
||||
buf += '\n';
|
||||
|
||||
if (g_system)
|
||||
g_system->logMessage(LogMessageType::kDebug, buf);
|
||||
g_system->logMessage(LogMessageType::kDebug, buf.c_str());
|
||||
// TODO: Think of a good fallback in case we do not have
|
||||
// any OSystem yet.
|
||||
}
|
||||
|
@ -46,14 +46,14 @@ void setErrorHandler(ErrorHandler handler) {
|
||||
#ifndef DISABLE_TEXT_CONSOLE
|
||||
|
||||
void warning(const char *s, ...) {
|
||||
char buf[STRINGBUFLEN];
|
||||
Common::String output;
|
||||
va_list va;
|
||||
|
||||
va_start(va, s);
|
||||
vsnprintf(buf, STRINGBUFLEN, s, va);
|
||||
output = Common::String::vformat(s, va);
|
||||
va_end(va);
|
||||
|
||||
Common::String output = Common::String::format("WARNING: %s!\n", buf);
|
||||
output = "WARNING: " + output + "!\n";
|
||||
|
||||
if (g_system)
|
||||
g_system->logMessage(LogMessageType::kWarning, output.c_str());
|
||||
@ -64,6 +64,9 @@ void warning(const char *s, ...) {
|
||||
#endif
|
||||
|
||||
void NORETURN_PRE error(const char *s, ...) {
|
||||
// We don't use String::vformat here, as that require
|
||||
// using the heap, and that might be impossible at this
|
||||
// point, e.g. if the error was an "out-of-memory" error.
|
||||
char buf_input[STRINGBUFLEN];
|
||||
char buf_output[STRINGBUFLEN];
|
||||
va_list va;
|
||||
|
Loading…
x
Reference in New Issue
Block a user