From 50f5ddc5ead608ecf8055209b704c9a20e59ca10 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 21 Dec 2003 07:04:33 +0000 Subject: [PATCH] work around stupid Windows error formatting returning \r\n at the end of error strings --- stepmania/src/RageUtil.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index de692a5387..88be4e061e 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -179,12 +179,18 @@ CString werr_ssprintf( int err, const char *fmt, ...) 0, err, 0, buf, sizeof(buf), NULL); #endif - va_list va; + /* Why is FormatMessage returning text ending with \r\n? */ + CString text = buf; + text.Replace( "\n", "" ); + text.Replace( "\r", " " ); /* foo\r\nbar -> foo bar */ + TrimRight( text ); /* "foo\r\n" -> "foo" */ + + va_list va; va_start(va, fmt); CString s = vssprintf( fmt, va ); va_end(va); - return s += ssprintf( " (%s)", buf ); + return s += ssprintf( " (%s)", text.c_str() ); } #endif