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:
parent
ca0c51491b
commit
d698d166d5
6 changed files with 18 additions and 15 deletions
|
@ -6,14 +6,14 @@
|
|||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "../util.h" // HACKHACK: for NSISRT_DEFINEGLOBALS
|
||||
|
||||
using namespace std; // for std::min
|
||||
|
||||
int g_display_errors = 1;
|
||||
FILE *g_output = stderr;
|
||||
NSISRT_DEFINEGLOBALS(); // HACKHACK: This really belongs in textrunner.cpp?
|
||||
|
||||
void quit() {
|
||||
_ftprintf(g_output, _T("MMap quit\n"));
|
||||
_ftprintf(g_errout, _T("MMap quit\n"));
|
||||
}
|
||||
|
||||
class MMapTest : public CppUnit::TestFixture {
|
||||
|
|
|
@ -28,7 +28,7 @@ class WinCharTest : public CppUnit::TestFixture {
|
|||
|
||||
public:
|
||||
void setUp() {
|
||||
NSISRT_Initialize();
|
||||
NSISRT_Initialize(); // HACKHACK: This really belongs in textrunner.cpp?
|
||||
}
|
||||
|
||||
void testFromTchar() {
|
||||
|
|
|
@ -36,9 +36,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
NSISRT_DEFINEGLOBALS();
|
||||
bool g_dopause=false, g_warnaserror=false;
|
||||
int g_display_errors=1;
|
||||
FILE *g_output, *g_errout;
|
||||
NStreamEncoding g_outputenc;
|
||||
#ifdef _WIN32
|
||||
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
|
||||
|
||||
g_argv0=argv[0];
|
||||
g_output=stdout, g_errout=stderr;
|
||||
|
||||
if (!NSISRT_Initialize())
|
||||
{
|
||||
|
|
|
@ -1115,6 +1115,14 @@ int WinStdIO_wprintf(const wchar_t*Fmt, ...)
|
|||
}
|
||||
#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)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -105,6 +105,8 @@ public:
|
|||
|
||||
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 FlushOutputAndResetPrintColor();
|
||||
#ifdef _WIN32
|
||||
|
@ -161,11 +163,7 @@ inline void PrintColorFmtMsg_ERR(const TCHAR *fmtstr, ...)
|
|||
{
|
||||
va_list val;
|
||||
va_start(val,fmtstr);
|
||||
PrintColorFmtMsg_WARN(_T("")); // flush g_output
|
||||
SetPrintColorERR();
|
||||
extern FILE *g_errout;
|
||||
_vftprintf(g_errout, fmtstr, val), fflush(g_errout);
|
||||
ResetPrintColor();
|
||||
PrintColorFmtErrMsg(fmtstr, val);
|
||||
va_end(val);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue