From dce2f551ac69c5c640abb1ae4eb53cb846d78c40 Mon Sep 17 00:00:00 2001 From: anders_k Date: Sun, 9 Mar 2014 23:04:51 +0000 Subject: [PATCH] Print error when ExeHeadStringList::find is unable to convert to narrow string git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6449 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/strlist.cpp | 10 ++++++++++ Source/strlist.h | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/strlist.cpp b/Source/strlist.cpp index 52a4f38d..a8c217a3 100644 --- a/Source/strlist.cpp +++ b/Source/strlist.cpp @@ -18,6 +18,9 @@ #include "strlist.h" #include "utf.h" +#ifndef NDEBUG +#include "util.h" // For PrintColorFmtMsg_ERR +#endif #ifdef _UNICODE char* convert_processed_string_to_ansi(char *out, const TCHAR *in, WORD codepage); // defined in build.cpp @@ -120,6 +123,13 @@ unsigned int ExeHeadStringList::find(const void *ptr, unsigned int cchF, WORD co { cbMB = WideCharToMultiByte(codepage,0,find,cchF,bufMB,cbF,0,0); } +#ifndef NDEBUG + if (!cbMB) + { + const TCHAR *fmt = _T("Unable to convert%")NPRINs _T(" string \"%")NPRIs _T("\" to codepage %u\n"); + PrintColorFmtMsg_ERR(fmt,(processed ? " processed" : ""),find,codepage); + } +#endif assert(cbMB); cbF = cbMB, find = (const wchar_t*) bufMB; } diff --git a/Source/strlist.h b/Source/strlist.h index 80f07b3c..44571223 100644 --- a/Source/strlist.h +++ b/Source/strlist.h @@ -143,13 +143,13 @@ public: bool get(unsigned int offset, tstring&str) const; unsigned int getnum() const; unsigned int gettotalsize() const { return m_gr.get() ? m_gr.getlen() : (m_wide ? 2 : 1); } - void* getstorageptr() const { return m_gr.get() ? m_gr.get() : (void*)L""; } + const void* getstorageptr() const { return m_gr.get() ? m_gr.get() : (void*)L""; } protected: unsigned int find(const void *str, unsigned int cchF, WORD codepage, bool processed, char**ppBufMB) const; GrowBuf m_gr; - bool m_wide; + bool m_wide; // Are we storing wide or narrow strings enum {WIDEDIV=2}; // ExeHead expects us to provide offsets this way, also helps UTF16 offsets for shell constants to fit in < 0xFF };