From 4b0d6b184368b9fb10421acfc0dac1cf7b05373a Mon Sep 17 00:00:00 2001 From: anders_k Date: Tue, 16 Feb 2016 14:59:04 +0000 Subject: [PATCH] Use a warning helper function so "warn as error" works everywhere git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6709 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/build.cpp | 68 +++++++++++++++++++++++++----------------------- Source/build.h | 1 + 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/Source/build.cpp b/Source/build.cpp index 4d1a109e..228a6a31 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -3404,44 +3404,22 @@ void CEXEBuild::set_verbosity(int lvl) g_display_errors = display_errors; } -void CEXEBuild::warning(const TCHAR *s, ...) +void CEXEBuild::warninghelper(const TCHAR *msg) { - ExpandoString buf; - va_list val; - va_start(val,s); - buf.StrFmt(s,val); - va_end(val); + m_warnings.add(msg,0); - m_warnings.add(buf,0); - notify(MakensisAPI::NOTIFY_WARNING,buf.GetPtr()); - if (display_warnings) - { - PrintColorFmtMsg_WARN(_T("warning: %") NPRIs _T("\n"),buf.GetPtr()); - } -} - -void CEXEBuild::warning_fl(const TCHAR *s, ...) -{ - ExpandoString buf; - va_list val; - va_start(val,s); - size_t cchMsg = buf.StrFmt(s,val); - va_end(val); - - buf.Reserve(cchMsg+2+_tcslen(curfilename)+50+1+1); - _stprintf(&buf[cchMsg],_T(" (%") NPRIs _T(":%u)"),curfilename,linecnt); - - m_warnings.add(buf,0); - - MakensisAPI::notify_e hostcode = MakensisAPI::NOTIFY_WARNING; extern bool g_warnaserror; + MakensisAPI::notify_e hostnotifyevnt = MakensisAPI::NOTIFY_WARNING; if (g_warnaserror) - hostcode = MakensisAPI::NOTIFY_ERROR, display_warnings = display_errors; - notify(hostcode,buf.GetPtr()); + { + hostnotifyevnt = MakensisAPI::NOTIFY_ERROR; + display_warnings = display_errors; + } + notify(hostnotifyevnt, msg); if (display_warnings) { - PrintColorFmtMsg_WARN(_T("warning: %") NPRIs _T("\n"),buf.GetPtr()); + PrintColorFmtMsg_WARN(_T("warning: %") NPRIs _T("\n"), msg); } if (g_warnaserror) { @@ -3452,6 +3430,30 @@ void CEXEBuild::warning_fl(const TCHAR *s, ...) } } +void CEXEBuild::warning(const TCHAR *s, ...) +{ + ExpandoString buf; + va_list val; + va_start(val,s); + buf.StrFmt(s,val); + va_end(val); + + warninghelper(buf.GetPtr()); +} + +void CEXEBuild::warning_fl(const TCHAR *s, ...) +{ + ExpandoString buf; + va_list val; + va_start(val,s); + size_t cchMsg = buf.StrFmt(s, val); + va_end(val); + + buf.Reserve(cchMsg+2+_tcslen(curfilename)+50+1+!0); + _stprintf(&buf[cchMsg], _T(" (%") NPRIs _T(":%u)"), curfilename, linecnt); + warninghelper(buf.GetPtr()); +} + void CEXEBuild::ERROR_MSG(const TCHAR *s, ...) const { if (display_errors || notify_hwnd) @@ -3462,10 +3464,10 @@ void CEXEBuild::ERROR_MSG(const TCHAR *s, ...) const buf.StrFmt(s,val); va_end(val); - notify(MakensisAPI::NOTIFY_ERROR,buf.GetPtr()); + notify(MakensisAPI::NOTIFY_ERROR, buf.GetPtr()); if (display_errors) { - PrintColorFmtMsg_ERR(_T("%") NPRIs ,buf.GetPtr()); + PrintColorFmtMsg_ERR(_T("%") NPRIs, buf.GetPtr()); } } } diff --git a/Source/build.h b/Source/build.h index 7bd865c2..19f3b25f 100644 --- a/Source/build.h +++ b/Source/build.h @@ -306,6 +306,7 @@ class CEXEBuild { int resolve_coderefs(const TCHAR *str); void print_warnings(); + void warninghelper(const TCHAR *msg); int uninstall_generate(); /** Are we defining an uninstall version of the code?