Some TCHAR fixes, linker flag for Unicode, and cosmetic touch without real changes
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6052 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
d7ffe58b2e
commit
01d88a1ed6
11 changed files with 1126 additions and 1118 deletions
|
@ -122,6 +122,8 @@ makensis_env.Append(CCFLAGS = ['/Fa${TARGET}.lst']) # listing file name
|
||||||
|
|
||||||
makensis_env.Append(LINKFLAGS = ['/opt:nowin98']) # 512 bytes align
|
makensis_env.Append(LINKFLAGS = ['/opt:nowin98']) # 512 bytes align
|
||||||
makensis_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file
|
makensis_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file
|
||||||
|
if defenv['UNICODE']:
|
||||||
|
makensis_env.Append(LINKFLAGS = ['/stack:2097152']) # need 2 MB of stack in Unicode (default is 1 MB)
|
||||||
|
|
||||||
### plugin environment
|
### plugin environment
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,11 @@ int CVersionStrigList::add(LANGID langid, int codepage)
|
||||||
_stprintf(Buff, _T("%04x"), langid);
|
_stprintf(Buff, _T("%04x"), langid);
|
||||||
int pos = SortedStringListND<struct version_string_list>::add(Buff);
|
int pos = SortedStringListND<struct version_string_list>::add(Buff);
|
||||||
if (pos == -1) return false;
|
if (pos == -1) return false;
|
||||||
((struct version_string_list*)m_gr.get())[pos].pChildStrings = new DefineList;
|
|
||||||
((struct version_string_list*)m_gr.get())[pos].codepage = codepage;
|
version_string_list *data = ((version_string_list *)m_gr.get())+ pos;
|
||||||
((struct version_string_list*)m_gr.get())[pos].lang_id = langid;
|
data->pChildStrings = new DefineList;
|
||||||
|
data->codepage = codepage;
|
||||||
|
data->lang_id = langid;
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,11 @@ int ConstantsStringList::add(const TCHAR *name, int value1, int value2)
|
||||||
int pos=SortedStringListND<struct constantstring>::add(name);
|
int pos=SortedStringListND<struct constantstring>::add(name);
|
||||||
if (pos == -1) return -1;
|
if (pos == -1) return -1;
|
||||||
|
|
||||||
((struct constantstring*)m_gr.get())[pos].index = m_index;
|
constantstring *ptr = ((constantstring*) m_gr.get()) + pos;
|
||||||
((struct constantstring*)m_gr.get())[pos].pos = pos;
|
ptr->index = m_index;
|
||||||
((struct constantstring*)m_gr.get())[pos].value1 = value1;
|
ptr->pos = pos;
|
||||||
((struct constantstring*)m_gr.get())[pos].value2 = value2;
|
ptr->value1 = value1;
|
||||||
|
ptr->value2 = value2;
|
||||||
|
|
||||||
int temp = m_index;
|
int temp = m_index;
|
||||||
m_index++;
|
m_index++;
|
||||||
|
|
|
@ -2219,7 +2219,7 @@ void CEXEBuild::PrepareHeaders(IGrowBuf *hdrbuf)
|
||||||
entry_writer::write_block(cur_entries, &sink);
|
entry_writer::write_block(cur_entries, &sink);
|
||||||
|
|
||||||
cur_header->blocks[NB_STRINGS].offset = sizeof(header) + blocks_buf.getlen();
|
cur_header->blocks[NB_STRINGS].offset = sizeof(header) + blocks_buf.getlen();
|
||||||
blocks_buf.add(cur_strlist->get(), cur_strlist->getlen());
|
blocks_buf.add(cur_strlist->get(), cur_strlist->getcount()*sizeof(TCHAR));
|
||||||
|
|
||||||
cur_header->blocks[NB_LANGTABLES].offset = sizeof(header) + blocks_buf.getlen();
|
cur_header->blocks[NB_LANGTABLES].offset = sizeof(header) + blocks_buf.getlen();
|
||||||
lang_table_writer::write_block(cur_langtables, &sink, cur_header->langtable_size);
|
lang_table_writer::write_block(cur_langtables, &sink, cur_header->langtable_size);
|
||||||
|
@ -2653,7 +2653,7 @@ int CEXEBuild::write_output(void)
|
||||||
int ne=build_header.blocks[NB_ENTRIES].num;
|
int ne=build_header.blocks[NB_ENTRIES].num;
|
||||||
INFO_MSG(_T("%d instruction%s (%d bytes), "),ne,ne==1?_T(""):_T("s"),ne*sizeof(entry));
|
INFO_MSG(_T("%d instruction%s (%d bytes), "),ne,ne==1?_T(""):_T("s"),ne*sizeof(entry));
|
||||||
int ns=build_strlist.getnum();
|
int ns=build_strlist.getnum();
|
||||||
INFO_MSG(_T("%d string%s (%d bytes), "),ns,ns==1?_T(""):_T("s"),build_strlist.getlen());
|
INFO_MSG(_T("%d string%s (%d bytes), "),ns,ns==1?_T(""):_T("s"),build_strlist.getcount()*sizeof(TCHAR));
|
||||||
int nlt=build_header.blocks[NB_LANGTABLES].num;
|
int nlt=build_header.blocks[NB_LANGTABLES].num;
|
||||||
INFO_MSG(_T("%d language table%s (%d bytes).\n"),nlt,nlt==1?_T(""):_T("s"),build_langtables.getlen());
|
INFO_MSG(_T("%d language table%s (%d bytes).\n"),nlt,nlt==1?_T(""):_T("s"),build_langtables.getlen());
|
||||||
if (ubuild_entries.getlen())
|
if (ubuild_entries.getlen())
|
||||||
|
@ -2682,7 +2682,7 @@ int CEXEBuild::write_output(void)
|
||||||
ne=build_uninst.blocks[NB_ENTRIES].num;
|
ne=build_uninst.blocks[NB_ENTRIES].num;
|
||||||
INFO_MSG(_T("%d instruction%s (%d bytes), "),ne,ne==1?_T(""):_T("s"),ubuild_entries.getlen());
|
INFO_MSG(_T("%d instruction%s (%d bytes), "),ne,ne==1?_T(""):_T("s"),ubuild_entries.getlen());
|
||||||
ns=ubuild_strlist.getnum();
|
ns=ubuild_strlist.getnum();
|
||||||
INFO_MSG(_T("%d string%s (%d bytes), "),ns,ns==1?_T(""):_T("s"),ubuild_strlist.getlen());
|
INFO_MSG(_T("%d string%s (%d bytes), "),ns,ns==1?_T(""):_T("s"),ubuild_strlist.getcount()*sizeof(TCHAR));
|
||||||
nlt=build_uninst.blocks[NB_LANGTABLES].num;
|
nlt=build_uninst.blocks[NB_LANGTABLES].num;
|
||||||
INFO_MSG(_T("%d language table%s (%d bytes).\n"),nlt,nlt==1?_T(""):_T("s"),ubuild_langtables.getlen());
|
INFO_MSG(_T("%d language table%s (%d bytes).\n"),nlt,nlt==1?_T(""):_T("s"),ubuild_langtables.getlen());
|
||||||
}
|
}
|
||||||
|
@ -3287,7 +3287,7 @@ void CEXEBuild::INFO_MSG(const TCHAR *s, ...) const
|
||||||
|
|
||||||
void CEXEBuild::print_warnings()
|
void CEXEBuild::print_warnings()
|
||||||
{
|
{
|
||||||
int nw=0,x=m_warnings.getlen();
|
int nw=0,x=m_warnings.getcount();
|
||||||
if (!x || !display_warnings) return;
|
if (!x || !display_warnings) return;
|
||||||
TCHAR *p=m_warnings.get();
|
TCHAR *p=m_warnings.get();
|
||||||
while (x>0) if (!p[--x]) nw++;
|
while (x>0) if (!p[--x]) nw++;
|
||||||
|
|
|
@ -488,6 +488,8 @@ typedef struct {
|
||||||
// don't want false end of string values so we shift then OR with 0x8080
|
// don't want false end of string values so we shift then OR with 0x8080
|
||||||
#define CODE_SHORT(x) (WORD)((((WORD)(x) & 0x7F) | (((WORD)(x) & 0x3F80) << 1) | 0x8080))
|
#define CODE_SHORT(x) (WORD)((((WORD)(x) & 0x7F) | (((WORD)(x) & 0x3F80) << 1) | 0x8080))
|
||||||
#define MAX_CODED 16383 // 0x3FFF
|
#define MAX_CODED 16383 // 0x3FFF
|
||||||
|
// This macro takes a pointer to char
|
||||||
|
#define DECODE_SHORT(c) (((c[1] & 0x7F) << 7) | (c[0] & 0x7F))
|
||||||
|
|
||||||
#define NSIS_INSTDIR_INVALID 1
|
#define NSIS_INSTDIR_INVALID 1
|
||||||
#define NSIS_INSTDIR_NOT_ENOUGH_SPACE 2
|
#define NSIS_INSTDIR_NOT_ENOUGH_SPACE 2
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -148,21 +148,19 @@ NLFString NLFStrings[NLF_STRINGS] = {
|
||||||
// LangStringList
|
// LangStringList
|
||||||
// ==============
|
// ==============
|
||||||
|
|
||||||
LangStringList::LangStringList() {
|
|
||||||
m_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LangStringList::add(const TCHAR *name, int *sn/*=0*/)
|
int LangStringList::add(const TCHAR *name, int *sn/*=0*/)
|
||||||
{
|
{
|
||||||
int pos = SortedStringListND<struct langstring>::add(name);
|
int pos = SortedStringListND<struct langstring>::add(name);
|
||||||
if (pos == -1) return -1;
|
if (pos == -1) return -1;
|
||||||
|
|
||||||
((struct langstring*)m_gr.get())[pos].sn = m_count;
|
langstring* lstrPtr = (langstring*)(m_gr.get()) + pos;
|
||||||
|
lstrPtr->sn = m_count;
|
||||||
if (sn) *sn = m_count;
|
if (sn) *sn = m_count;
|
||||||
m_count++;
|
m_count++;
|
||||||
((struct langstring*)m_gr.get())[pos].index = -1;
|
lstrPtr->index = -1;
|
||||||
((struct langstring*)m_gr.get())[pos].uindex = -1;
|
lstrPtr->uindex = -1;
|
||||||
((struct langstring*)m_gr.get())[pos].process = 1;
|
lstrPtr->process = 1;
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
@ -174,10 +172,11 @@ int LangStringList::get(const TCHAR *name, int *sn/*=0*/, int *index/*=0*/, int
|
||||||
if (sn) *sn = -1;
|
if (sn) *sn = -1;
|
||||||
int v=find(name);
|
int v=find(name);
|
||||||
if (v==-1) return -1;
|
if (v==-1) return -1;
|
||||||
if (index) *index = ((struct langstring*)m_gr.get())[v].index;
|
langstring* lstrPtr = (langstring*)(m_gr.get()) + v;
|
||||||
if (uindex) *uindex = ((struct langstring*)m_gr.get())[v].uindex;
|
if (index) *index = lstrPtr->index;
|
||||||
if (sn) *sn = ((struct langstring*)m_gr.get())[v].sn;
|
if (uindex) *uindex = lstrPtr->uindex;
|
||||||
if (process) *process = ((struct langstring*)m_gr.get())[v].process;
|
if (sn) *sn = lstrPtr->sn;
|
||||||
|
if (process) *process = lstrPtr->process;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,14 +185,11 @@ void LangStringList::set(int pos, int index/*=-1*/, int uindex/*=-1*/, int proce
|
||||||
if ((unsigned int)pos > (m_gr.getlen() / sizeof(struct langstring)))
|
if ((unsigned int)pos > (m_gr.getlen() / sizeof(struct langstring)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct langstring *data=(struct langstring *)m_gr.get();
|
struct langstring *data=((struct langstring *) m_gr.get()) + pos;
|
||||||
|
|
||||||
if (index >= 0)
|
if (index >= 0) data->index = index;
|
||||||
data[pos].index = index;
|
if (uindex >= 0) data->uindex = uindex;
|
||||||
if (uindex >= 0)
|
if (process >= 0) data->process = process;
|
||||||
data[pos].uindex = uindex;
|
|
||||||
if (process >= 0)
|
|
||||||
data[pos].process = process;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LangStringList::set(const TCHAR *name, int index, int uindex/*=-1*/, int process/*=-1*/)
|
void LangStringList::set(const TCHAR *name, int index, int uindex/*=-1*/, int process/*=-1*/)
|
||||||
|
@ -213,7 +209,7 @@ const TCHAR* LangStringList::pos2name(int pos)
|
||||||
|
|
||||||
const TCHAR* LangStringList::offset2name(int name)
|
const TCHAR* LangStringList::offset2name(int name)
|
||||||
{
|
{
|
||||||
if ((unsigned int)name > (unsigned int)m_strings.getlen())
|
if ((unsigned int)name > m_strings.getlen()/sizeof(TCHAR))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (const TCHAR*) m_strings.get() + name;
|
return (const TCHAR*) m_strings.get() + name;
|
||||||
|
|
|
@ -40,7 +40,7 @@ class LangStringList : public SortedStringListND<struct langstring>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* Default constructor */
|
/* Default constructor */
|
||||||
LangStringList();
|
LangStringList() : m_count(0) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a langstring struct with the string name of 'name' into this
|
* Adds a langstring struct with the string name of 'name' into this
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty.
|
* warranty.
|
||||||
*
|
*
|
||||||
* Doxygen comments by Jim Park -- 08/01/2007
|
* Unicode support and Doxygen comments by Jim Park -- 08/01/2007
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "strlist.h"
|
#include "strlist.h"
|
||||||
|
@ -29,9 +29,12 @@ int StringList::add(const TCHAR *str, int case_sensitive)
|
||||||
int StringList::find(const TCHAR *str, int case_sensitive, int *idx/*=NULL*/) const // returns -1 if not found
|
int StringList::find(const TCHAR *str, int case_sensitive, int *idx/*=NULL*/) const // returns -1 if not found
|
||||||
{
|
{
|
||||||
const TCHAR *s=get();
|
const TCHAR *s=get();
|
||||||
int ml=getlen();
|
int ml=getcount();
|
||||||
int offs=0;
|
int offs=0;
|
||||||
|
|
||||||
|
size_t str_slen = _tcslen(str);
|
||||||
|
size_t offs_slen;
|
||||||
|
|
||||||
if (idx) *idx=0;
|
if (idx) *idx=0;
|
||||||
while (offs < ml)
|
while (offs < ml)
|
||||||
{
|
{
|
||||||
|
@ -42,14 +45,16 @@ int StringList::find(const TCHAR *str, int case_sensitive, int *idx/*=NULL*/) co
|
||||||
return offs;
|
return offs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
offs_slen = _tcslen(s+offs);
|
||||||
|
|
||||||
// Check if just the end of the string matches str.
|
// Check if just the end of the string matches str.
|
||||||
if (case_sensitive==2 &&
|
if (case_sensitive==2 &&
|
||||||
_tcslen(str) < _tcslen(s+offs) && // check for end of string
|
str_slen < offs_slen && // check for end of string
|
||||||
!_tcscmp(s+offs+_tcslen(s+offs)-_tcslen(str),str))
|
!_tcscmp(s + offs + offs_slen - str_slen,str))
|
||||||
{
|
{
|
||||||
return offs+_tcslen(s+offs)-_tcslen(str);
|
return offs + offs_slen - str_slen;
|
||||||
}
|
}
|
||||||
offs+=_tcslen(s+offs)+1;
|
offs += offs_slen + 1;
|
||||||
|
|
||||||
if (idx) (*idx)++;
|
if (idx) (*idx)++;
|
||||||
}
|
}
|
||||||
|
@ -62,12 +67,12 @@ void StringList::delbypos(int pos)
|
||||||
TCHAR *s=(TCHAR*) m_gr.get();
|
TCHAR *s=(TCHAR*) m_gr.get();
|
||||||
int len=_tcslen(s+pos)+1;
|
int len=_tcslen(s+pos)+1;
|
||||||
|
|
||||||
if (pos+len < m_gr.getlen())
|
if (pos+len < getcount())
|
||||||
{
|
{
|
||||||
// Move everything after the string position to the current position.
|
// Move everything after the string position to the current position.
|
||||||
memcpy(s+pos,s+pos+len,m_gr.getlen()-(pos+len));
|
memcpy(s+pos,s+pos+len, (getcount()-pos+len)*sizeof(TCHAR));
|
||||||
}
|
}
|
||||||
m_gr.resize(m_gr.getlen()-len);
|
m_gr.resize(m_gr.getlen()-len*sizeof(TCHAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
// idx corresponds to the nth string in the list.
|
// idx corresponds to the nth string in the list.
|
||||||
|
@ -75,8 +80,8 @@ int StringList::idx2pos(int idx) const
|
||||||
{
|
{
|
||||||
TCHAR *s=(TCHAR*) m_gr.get();
|
TCHAR *s=(TCHAR*) m_gr.get();
|
||||||
int offs=0;
|
int offs=0;
|
||||||
int cnt=0;
|
size_t cnt=0;
|
||||||
if (idx>=0) while (offs < m_gr.getlen())
|
if (idx>=0) while (offs < getcount())
|
||||||
{
|
{
|
||||||
if (cnt++ == idx) return offs;
|
if (cnt++ == idx) return offs;
|
||||||
offs+=_tcslen(s+offs)+1;
|
offs+=_tcslen(s+offs)+1;
|
||||||
|
@ -87,7 +92,7 @@ int StringList::idx2pos(int idx) const
|
||||||
int StringList::getnum() const
|
int StringList::getnum() const
|
||||||
{
|
{
|
||||||
TCHAR *s=(TCHAR*) m_gr.get();
|
TCHAR *s=(TCHAR*) m_gr.get();
|
||||||
int ml=m_gr.getlen();
|
int ml=getcount();
|
||||||
int offs=0;
|
int offs=0;
|
||||||
int idx=0;
|
int idx=0;
|
||||||
while (offs < ml)
|
while (offs < ml)
|
||||||
|
@ -103,9 +108,9 @@ const TCHAR *StringList::get() const
|
||||||
return (const TCHAR*) m_gr.get();
|
return (const TCHAR*) m_gr.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
int StringList::getlen() const
|
int StringList::getcount() const
|
||||||
{
|
{
|
||||||
return m_gr.getlen();
|
return m_gr.getlen() / sizeof(TCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==========
|
// ==========
|
||||||
|
@ -213,9 +218,9 @@ TCHAR *FastStringList::get() const
|
||||||
return (TCHAR*)m_strings.get();
|
return (TCHAR*)m_strings.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
int FastStringList::getlen() const
|
int FastStringList::getcount() const
|
||||||
{
|
{
|
||||||
return m_strings.getlen();
|
return m_strings.getlen()/sizeof(TCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FastStringList::getnum() const
|
int FastStringList::getnum() const
|
||||||
|
|
|
@ -107,10 +107,10 @@ public:
|
||||||
const TCHAR *get() const;
|
const TCHAR *get() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the buffer size in bytes.
|
* Get the buffer size (number of TCHARs).
|
||||||
* @return The buffer size in bytes.
|
* @return The buffer size (number of TCHARs).
|
||||||
*/
|
*/
|
||||||
int getlen() const;
|
int getcount() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GrowBuf m_gr;
|
GrowBuf m_gr;
|
||||||
|
@ -538,11 +538,11 @@ class FastStringList : public SortedStringListND<struct string_t>
|
||||||
TCHAR *get() const;
|
TCHAR *get() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size of the collection of m_strings as bytes.
|
* The size of the collection of m_strings as a count of TCHARs.
|
||||||
*
|
*
|
||||||
* @return The size of m_strings in bytes.
|
* @return the size of m_strings as count of TCHARs.
|
||||||
*/
|
*/
|
||||||
int getlen() const;
|
int getcount() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of strings stored in the sorted array.
|
* The number of strings stored in the sorted array.
|
||||||
|
|
|
@ -32,12 +32,10 @@ class UserVarsStringList : public SortedStringListND<struct uservarstring>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* Default constructor */
|
/* Default constructor */
|
||||||
UserVarsStringList()
|
UserVarsStringList() : m_index(0) {}
|
||||||
{
|
|
||||||
m_index = 0;
|
|
||||||
}
|
|
||||||
/* Destructor */
|
/* Destructor */
|
||||||
~UserVarsStringList() { }
|
virtual ~UserVarsStringList() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a name to the UserVarsStringList. Sets reference count to
|
* Adds a name to the UserVarsStringList. Sets reference count to
|
||||||
|
@ -52,9 +50,10 @@ class UserVarsStringList : public SortedStringListND<struct uservarstring>
|
||||||
int pos=SortedStringListND<struct uservarstring>::add(name);
|
int pos=SortedStringListND<struct uservarstring>::add(name);
|
||||||
if (pos == -1) return -1;
|
if (pos == -1) return -1;
|
||||||
|
|
||||||
((struct uservarstring*)m_gr.get())[pos].index = m_index;
|
uservarstring* ustr = ((uservarstring*) m_gr.get()) + pos;
|
||||||
((struct uservarstring*)m_gr.get())[pos].pos = pos;
|
ustr->index = m_index;
|
||||||
((struct uservarstring*)m_gr.get())[pos].reference = ref_count;
|
ustr->pos = pos;
|
||||||
|
ustr->reference = ref_count;
|
||||||
|
|
||||||
int temp = m_index;
|
int temp = m_index;
|
||||||
m_index++;
|
m_index++;
|
||||||
|
@ -110,8 +109,7 @@ class UserVarsStringList : public SortedStringListND<struct uservarstring>
|
||||||
int inc_reference(int idx)
|
int inc_reference(int idx)
|
||||||
{
|
{
|
||||||
int pos=get_internal_idx(idx);
|
int pos=get_internal_idx(idx);
|
||||||
((struct uservarstring*)m_gr.get())[pos].reference++;
|
return ((struct uservarstring*) m_gr.get())[pos].reference++;
|
||||||
return (((struct uservarstring*)m_gr.get())[pos].reference)-1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue