Use a common helper macro to declare some UI output related variables

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6800 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2016-11-22 23:11:33 +00:00
parent ca0c51491b
commit d698d166d5
6 changed files with 18 additions and 15 deletions

View file

@ -19,9 +19,8 @@
using namespace std; using namespace std;
int g_noconfig=0; int g_noconfig=0; // TODO: Not used?
int g_display_errors=1; NSISRT_DEFINEGLOBALS();
FILE *g_output=stdout;
int GetTLBVersion(tstring& filepath, DWORD& high, DWORD & low) int GetTLBVersion(tstring& filepath, DWORD& high, DWORD & low)
{ {

View file

@ -6,14 +6,14 @@
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "../util.h" // HACKHACK: for NSISRT_DEFINEGLOBALS
using namespace std; // for std::min using namespace std; // for std::min
int g_display_errors = 1; NSISRT_DEFINEGLOBALS(); // HACKHACK: This really belongs in textrunner.cpp?
FILE *g_output = stderr;
void quit() { void quit() {
_ftprintf(g_output, _T("MMap quit\n")); _ftprintf(g_errout, _T("MMap quit\n"));
} }
class MMapTest : public CppUnit::TestFixture { class MMapTest : public CppUnit::TestFixture {

View file

@ -28,7 +28,7 @@ class WinCharTest : public CppUnit::TestFixture {
public: public:
void setUp() { void setUp() {
NSISRT_Initialize(); NSISRT_Initialize(); // HACKHACK: This really belongs in textrunner.cpp?
} }
void testFromTchar() { void testFromTchar() {

View file

@ -36,9 +36,8 @@
using namespace std; using namespace std;
NSISRT_DEFINEGLOBALS();
bool g_dopause=false, g_warnaserror=false; bool g_dopause=false, g_warnaserror=false;
int g_display_errors=1;
FILE *g_output, *g_errout;
NStreamEncoding g_outputenc; NStreamEncoding g_outputenc;
#ifdef _WIN32 #ifdef _WIN32
UINT g_wincon_orgoutcp; UINT g_wincon_orgoutcp;
@ -296,7 +295,6 @@ static inline int makensismain(int argc, TCHAR **argv)
assert(sizeof(WINWCHAR) == sizeof(WCHAR)); // Not really required but if WCHAR changes we need to know assert(sizeof(WINWCHAR) == sizeof(WCHAR)); // Not really required but if WCHAR changes we need to know
g_argv0=argv[0]; g_argv0=argv[0];
g_output=stdout, g_errout=stderr;
if (!NSISRT_Initialize()) if (!NSISRT_Initialize())
{ {

View file

@ -1115,6 +1115,14 @@ int WinStdIO_wprintf(const wchar_t*Fmt, ...)
} }
#endif #endif
void PrintColorFmtErrMsg(const TCHAR *fmtstr, va_list args)
{
PrintColorFmtMsg_WARN(_T("")); // flush g_output
SetPrintColorERR();
_vftprintf(g_errout, fmtstr, args), fflush(g_errout);
ResetPrintColor();
}
void PrintColorFmtMsg(unsigned int type, const TCHAR *fmtstr, va_list args) void PrintColorFmtMsg(unsigned int type, const TCHAR *fmtstr, va_list args)
{ {
#ifdef _WIN32 #ifdef _WIN32

View file

@ -105,6 +105,8 @@ public:
int sane_system(const TCHAR *command); int sane_system(const TCHAR *command);
#define NSISRT_DEFINEGLOBALS() int g_display_errors=1; FILE *g_output=stdout, *g_errout=stderr
void PrintColorFmtErrMsg(const TCHAR *fmtstr, va_list args);
void PrintColorFmtMsg(unsigned int type, const TCHAR *fmtstr, va_list args); void PrintColorFmtMsg(unsigned int type, const TCHAR *fmtstr, va_list args);
void FlushOutputAndResetPrintColor(); void FlushOutputAndResetPrintColor();
#ifdef _WIN32 #ifdef _WIN32
@ -161,11 +163,7 @@ inline void PrintColorFmtMsg_ERR(const TCHAR *fmtstr, ...)
{ {
va_list val; va_list val;
va_start(val,fmtstr); va_start(val,fmtstr);
PrintColorFmtMsg_WARN(_T("")); // flush g_output PrintColorFmtErrMsg(fmtstr, val);
SetPrintColorERR();
extern FILE *g_errout;
_vftprintf(g_errout, fmtstr, val), fflush(g_errout);
ResetPrintColor();
va_end(val); va_end(val);
} }