From 9e3913e8e9c25916911ef5e9f2a2d5b17e9e8c5c Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 23 Jun 2015 15:32:17 +0200 Subject: fixed stdio message printing for strings longer than 255 characters * there's no reason for formatting into a buffer of fixed length first, since all that is done to the format string is adding a prefix and suffix (line feed). * the new implementation should also be slightly faster. --- src/interface.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index 337e5d2..41cc93d 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -111,24 +111,26 @@ template void Interface::stdio_vmsg(MessageType type, const gchar *fmt, va_list ap) { - gchar buf[255]; - - g_vsnprintf(buf, sizeof(buf), fmt, ap); + FILE *stream = stdout; switch (type) { case MSG_USER: - g_printf("%s\n", buf); break; case MSG_INFO: - g_printf("Info: %s\n", buf); + fputs("Info: ", stream); break; case MSG_WARNING: - g_fprintf(stderr, "Warning: %s\n", buf); + stream = stderr; + fputs("Warning: ", stream); break; case MSG_ERROR: - g_fprintf(stderr, "Error: %s\n", buf); + stream = stderr; + fputs("Error: ", stream); break; } + + g_vfprintf(stream, fmt, ap); + fputc('\n', stream); } template -- cgit v1.2.3