diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-06-23 15:32:17 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-06-23 15:32:17 +0200 |
commit | 9e3913e8e9c25916911ef5e9f2a2d5b17e9e8c5c (patch) | |
tree | 8947bfc6687d3973e87f43268e90f9136bd9366c /src/interface.cpp | |
parent | d9e2250d31bfa4857ee73e0430ee890e3b72a92a (diff) | |
download | sciteco-9e3913e8e9c25916911ef5e9f2a2d5b17e9e8c5c.tar.gz |
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.
Diffstat (limited to 'src/interface.cpp')
-rw-r--r-- | src/interface.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
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 <class InterfaceImpl, class ViewImpl> void Interface<InterfaceImpl, ViewImpl>::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 <class InterfaceImpl, class ViewImpl> |