Author: tfaber
Date: Fri Oct 7 15:25:20 2016
New Revision: 72923
URL:
http://svn.reactos.org/svn/reactos?rev=72923&view=rev
Log:
[DWNL]
- Handle arbitrary console buffer width in write_status
CORE-10228 #resolve
Modified:
trunk/reactos/base/applications/network/dwnl/dwnl.c
Modified: trunk/reactos/base/applications/network/dwnl/dwnl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/dwnl/dwnl.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/dwnl/dwnl.c [iso-8859-1] Fri Oct 7 15:25:20
2016
@@ -2,6 +2,7 @@
#include <urlmon.h>
#include <wininet.h>
#include <tchar.h>
+#include <strsafe.h>
/* FIXME: add correct definitions to urlmon.idl */
#ifdef UNICODE
@@ -41,21 +42,21 @@
write_status(LPCTSTR lpFmt, ...)
{
va_list args;
-
- /* FIXME: Determine line length! */
- TCHAR szTxt[80];
- int c;
+ TCHAR szTxt[128];
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
va_start(args, lpFmt);
- _vstprintf(szTxt, lpFmt, args);
+ StringCbVPrintf(szTxt, sizeof(szTxt), lpFmt, args);
va_end(args);
- c = _tcslen(szTxt);
- while (c < (sizeof(szTxt) / sizeof(szTxt[0])) - 1)
- szTxt[c++] = _T(' ');
- szTxt[c] = _T('\0');
-
- _tprintf(_T("\r%.79s"), szTxt);
+ if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
+ {
+ _tprintf(_T("\r%*.*s"), -(csbi.dwSize.X - 1), csbi.dwSize.X - 1,
szTxt);
+ }
+ else
+ {
+ _putts(szTxt);
+ }
}
static void