List plug-in directories when plug-in call fails

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7011 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2018-06-25 21:33:30 +00:00
parent 2eb0d5cdf1
commit bfdec13982
7 changed files with 56 additions and 9 deletions

View file

@ -1046,6 +1046,11 @@ typedef struct tagVS_FIXEDFILEINFO {
#else
# define NSIS_CXX_NOEXCEPT() throw() // Can't specialize __declspec(nothrow) because MSVC requires it before the function name
#endif
#if defined(_MSC_VER) && _MSC_VER <= 1200
# define NSIS_CXX_TYPENAME // VC6 can't handle typename in some places but GCC requires it
#else
# define NSIS_CXX_TYPENAME typename
#endif
#define BUGBUG64TRUNCATE(cast,xpr) ( (cast) (xpr) )
/*
@ -1090,4 +1095,12 @@ FORCEINLINE BOOL NoDepr_GetVersionExW(OSVERSIONINFOW*p) { __pragma(warning(push)
#endif //~ _MSC_VER >= 1500
#endif //~ _MSC_VER
#ifdef __cplusplus
namespace STLHelpers
{
template<class M> struct mapped_type_helper { typedef typename M::value_type::second_type type; }; // VC6 uses referent_type and not mapped_type
}
#endif //~ __cplusplus
#endif // EOF

View file

@ -76,6 +76,16 @@ V get_paired_value(const C& cntnr, const K& key, const V& defval)
}
static tstring GetDllPath(const tstring&fullpath)
{
tstring::size_type platsep = fullpath.rfind(PLATFORM_PATH_SEPARATOR_STR);
tstring::size_type unixsep = platsep;
if (PLATFORM_PATH_SEPARATOR_C != _T('/')) unixsep = fullpath.rfind(_T("/")); // Ideally get_dir_name would do this for us
tstring::size_type lastsep = platsep != string::npos && unixsep != string::npos ? STD_MAX(platsep, unixsep) : STD_MIN(platsep, unixsep);
if (lastsep == string::npos) return _T("");
return fullpath.substr(0, lastsep);
}
static inline tstring GetDllName(const tstring&command)
{
return get_string_prefix(command, _T("::"));
@ -253,4 +263,28 @@ bool Plugins::IsPluginCallSyntax(const tstring& token)
return dllname.length() + 2 < token.length();
}
struct PrintPluginDirsHelper {
template<class C> static void print(const C&c, const char*indent = "")
{
std::/*unordered_*/set<typename STLHelpers::mapped_type_helper<C>::type
#ifdef _WIN32
, Plugins::strnocasecmp
#endif
> seen;
for (NSIS_CXX_TYPENAME C::const_iterator it = c.begin(); it != c.end(); ++it)
{
const tstring path = GetDllPath(it->second);
if (contains(seen, path)) continue;
seen.insert(path);
_ftprintf(g_output, _T("%") NPRIns _T("%") NPRIs _T("\n"), indent, path.c_str());
}
}
};
void Plugins::PrintPluginDirs()
{
_ftprintf(g_output, _T("Plugin directories:\n"));
PrintPluginDirsHelper::print(m_dllname_to_path, " ");
}
#endif

View file

@ -57,6 +57,7 @@ class Plugins
int GetDllDataHandle(bool uninst, const tstring& command) const;
void SetDllDataHandle(bool uninst, tstring&canoniccmd, int dataHandle);
static bool IsPluginCallSyntax(const tstring& token);
void PrintPluginDirs();
private: // methods
void GetExports(const tstring &pathToDll, bool pe64, bool displayInfo);

View file

@ -169,15 +169,11 @@ namespace MakensisAPI {
#define FLAG_OFFSET(flag) (FIELD_OFFSET(exec_flags_t, flag)/sizeof(int))
class DiagState {
template<class M> struct mapped_type_helper { typedef typename M::value_type::second_type type; }; // VC6 uses referent_type and not mapped_type
template<class M> struct mapped_type_helper { typedef typename STLHelpers::mapped_type_helper<M>::type type; };
template<class C, class K, class V> void insert_or_assign(C&c, const K&k, V val)
{
typename C::value_type item(k, val);
#if defined(_MSC_VER) && _MSC_VER <= 1200
std::pair<C::iterator, bool> ret = c.insert(item);
#else
std::pair<typename C::iterator, bool> ret = c.insert(item);
#endif
std::pair<NSIS_CXX_TYPENAME C::iterator, bool> ret = c.insert(item);
if (!ret.second) ret.first->second = val;
}
template<class C, class K> typename mapped_type_helper<C>::type get_paired_value(const C&c, const K&k, typename mapped_type_helper<C>::type defval) const

View file

@ -516,7 +516,7 @@ typedef struct {
#define REGROOTVIEW32 0x40000000
#define REGROOTVIEW64 0x20000000
#define REGROOTVIEWTOSAMVIEW(rv) ( ((UINT_PTR)(rv)&(REGROOTVIEW32|REGROOTVIEW64)) >> 21 ) // REGROOTVIEWxx to KEY_WOW64_xxKEY
#define REGROOTVIEWTOSAMVIEW(rv) ( (UINT)(((UINT_PTR)(rv)&(REGROOTVIEW32|REGROOTVIEW64)) >> 21) ) // REGROOTVIEWxx to KEY_WOW64_xxKEY
#define IsRegRootkeyForcedView(hKey) ( ((UINT_PTR) (hKey) & (REGROOTVIEW32|REGROOTVIEW64)) )
#define MAKEREGROOTVIEW(r, fv) ( (HKEY) ((UINT_PTR)(r) | (fv)) )
#define HKSHCTX ( (HKEY) 0 ) // Converted to HKCU or HKLM by GetRegRootKey

View file

@ -297,7 +297,10 @@ parse_again:
{
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
if (Plugins::IsPluginCallSyntax(tokstr0))
{
if (m_pPlugins && display_warnings) m_pPlugins->PrintPluginDirs();
ERROR_MSG(_T("Plugin%") NPRIs _T(" not found, cannot call %") NPRIs _T("\n"),m_pPlugins && m_pPlugins->IsKnownPlugin(tokstr0) ? _T(" function") : _T(""),tokstr0);
}
else
#endif
ERROR_MSG(_T("Invalid command: \"%") NPRIs _T("\"\n"),tokstr0);

View file

@ -1023,14 +1023,14 @@ int RunChildProcessRedirected(LPCWSTR cmdprefix, LPCWSTR cmdmain, bool ForceUTF8
{
bool fullbuf = false, utf8 = CP_UTF8 == cp, okt;
char iobuf[512];
DWORD cbRead, cbOfs = 0, cchwb = 0;
DWORD cbRead, cbOfs = 0, cchwb = 0, i;
WCHAR wbuf[100], wchbuf[2+1]; // A surrogate pair + \0
for(;;)
{
BOOL okr = ReadFile(hSORd, iobuf+cbOfs, sizeof(iobuf)-cbOfs, &cbRead, 0);
cbRead += cbOfs, cbOfs = 0;
unsigned char cbTrail, cch;
for(DWORD i = 0; i < cbRead;)
for(i = 0; i < cbRead;)
{
cch = 0;
if (utf8)