From 94e3856b769f0380d1dbd2bc4f8a5dcaa5d1c358 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 27 Oct 2013 21:12:25 +0000 Subject: [PATCH] SDL2/non-Windows: Before showing "simple message box", replace tabs with spaces. Because the one implemented on top of X shows a special mark for tabs instead of whitespace. Also, in wm_msgbox(), use vsnprintf. git-svn-id: https://svn.eduke32.com/eduke32@4120 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/sdlayer.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 698a65545..3af08abcb 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -154,7 +154,7 @@ int32_t wm_msgbox(char *name, char *fmt, ...) UNREFERENCED_PARAMETER(name); va_start(va,fmt); - vsprintf(buf,fmt,va); + vsnprintf(buf,sizeof(buf),fmt,va); va_end(va); #if defined(__APPLE__) @@ -162,6 +162,16 @@ int32_t wm_msgbox(char *name, char *fmt, ...) #elif defined HAVE_GTK2 if (gtkbuild_msgbox(name, buf) >= 0) return 1; #elif SDL_MAJOR_VERSION==2 +# if !defined _WIN32 + // Replace all tab chars with spaces because the hand-rolled SDL message + // box diplays the former as N/L instead of whitespace. + { + int32_t i; + for (i=0; i<(int32_t)sizeof(buf); i++) + if (buf[i] == '\t') + buf[i] = ' '; + } +# endif return SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, name, buf, NULL); #endif puts(buf);