LangStrings now act as functions, they don't need to be defined before used. Uninstaller LangStrings must now be refernced with un.
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1982 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
389f90b78d
commit
352c5a87ab
4 changed files with 43 additions and 44 deletions
|
@ -415,7 +415,7 @@ int CEXEBuild::preprocess_string(char *out, const char *in)
|
|||
strncpy(tbuf,p,63);
|
||||
tbuf[63]=0;
|
||||
if (strstr(tbuf," ")) strstr(tbuf," ")[0]=0;
|
||||
warning("unknown variable \"%s\" detected, ignoring\n",tbuf);
|
||||
warning("unknown variable \"%s\" detected, ignoring",tbuf);
|
||||
i = '$';
|
||||
}
|
||||
}
|
||||
|
@ -436,10 +436,16 @@ int CEXEBuild::add_string_main(const char *string, int process) // returns offse
|
|||
char *p = strchr(cp, ')');
|
||||
if (p) {
|
||||
*p = 0;
|
||||
if (!strnicmp(cp,"un.",3)) {
|
||||
warning("Installer language strings can't start with un. (%s)!", string);
|
||||
free(cp);
|
||||
return 0;
|
||||
}
|
||||
if (build_userlangstrings.find(cp, 0, &idx) < 0) idx = -1;
|
||||
}
|
||||
free(cp);
|
||||
if (idx >= 0) return -((int)(idx+1+(sizeof(common_strings)+sizeof(installer_strings))/sizeof(int)));
|
||||
if (idx < 0) SetUserString(cp, 0, 0, process);
|
||||
return -((int)(idx+1+(sizeof(common_strings)+sizeof(installer_strings))/sizeof(int)));
|
||||
}
|
||||
|
||||
if (!process) return build_strlist.add(string,2);
|
||||
|
@ -459,10 +465,16 @@ int CEXEBuild::add_string_uninst(const char *string, int process) // returns off
|
|||
char *p = strchr(cp, ')');
|
||||
if (p) {
|
||||
*p = 0;
|
||||
if (strnicmp(cp,"un.",3)) {
|
||||
warning("Uninstaller language strings must start with un. (%s)!", string);
|
||||
free(cp);
|
||||
return 0;
|
||||
}
|
||||
if (ubuild_userlangstrings.find(cp, 0, &idx) < 0) idx = -1;
|
||||
}
|
||||
free(cp);
|
||||
if (idx >= 0) return -((int)(idx+1+(sizeof(common_strings)+sizeof(uninstall_strings))/sizeof(int)));
|
||||
if (idx < 0) SetUserString(cp, 0, 0, process);
|
||||
return -((int)(idx+1+(sizeof(common_strings)+sizeof(uninstall_strings))/sizeof(int)));
|
||||
}
|
||||
|
||||
if (!process) return ubuild_strlist.add(string,2);
|
||||
|
|
|
@ -85,19 +85,10 @@ StringTable* CEXEBuild::GetTable(LANGID &lang) {
|
|||
}
|
||||
memset(table, 0, sizeof(StringTable)-sizeof(GrowBuf)*2);
|
||||
table->lang_id = lang;
|
||||
|
||||
int zero = 0;
|
||||
|
||||
// make sure all of the user's strings tables are the same size
|
||||
for (unsigned int j = 0; j < string_tables.size(); j++) {
|
||||
int i = build_userlangstrings.getnum();
|
||||
i -= table->user_strings.getlen() / sizeof(int);
|
||||
while (i--) table->user_strings.add(&zero, sizeof(int));
|
||||
table->user_strings.resize(build_userlangstrings.getnum()*sizeof(int), 1);
|
||||
table->user_ustrings.resize(ubuild_userlangstrings.getnum()*sizeof(int), 1);
|
||||
|
||||
i = ubuild_userlangstrings.getnum();
|
||||
i -= table->user_ustrings.getlen() / sizeof(int);
|
||||
while (i--) table->user_ustrings.add(&zero, sizeof(int));
|
||||
}
|
||||
string_tables.push_back(table);
|
||||
}
|
||||
|
||||
|
@ -201,45 +192,39 @@ int CEXEBuild::SetString(char *string, int id, int process, StringTable *table)
|
|||
}
|
||||
|
||||
int CEXEBuild::SetUserString(char *name, LANGID lang, char *string, int process/*=1*/) {
|
||||
StringTable *table = GetTable(lang);
|
||||
if (!table) return PS_ERROR;
|
||||
StringTable *table = 0;
|
||||
if (string) {
|
||||
table = GetTable(lang);
|
||||
if (!table) return PS_ERROR;
|
||||
}
|
||||
|
||||
GrowBuf *user_strings;
|
||||
StringList *user_strings_list;
|
||||
GrowBuf *user_strings = 0;
|
||||
StringList *user_strings_list = 0;
|
||||
bool uninst;
|
||||
if (!(uninst = !strnicmp(name,"un.",3))) {
|
||||
user_strings=&table->user_strings;
|
||||
if (string) user_strings=&table->user_strings;
|
||||
user_strings_list=&build_userlangstrings;
|
||||
}
|
||||
else {
|
||||
name += 3;
|
||||
user_strings=&table->user_ustrings;
|
||||
if (string) user_strings=&table->user_ustrings;
|
||||
user_strings_list=&ubuild_userlangstrings;
|
||||
}
|
||||
|
||||
int idx;
|
||||
if (user_strings_list->find(name, 0, &idx) < 0) {
|
||||
// if lang string doesn't exist yet
|
||||
user_strings_list->add(name, 0);
|
||||
user_strings_list->find(name, 0, &idx);
|
||||
}
|
||||
|
||||
#define MAX(a, b) (a > b ? a : b)
|
||||
user_strings->resize(MAX((unsigned int)user_strings->getlen(), (idx+1)*sizeof(unsigned int)));
|
||||
((int*)user_strings->get())[idx] = uninst ? add_string_uninst(string,process) : add_string_main(string,process);
|
||||
|
||||
int zero = 0;
|
||||
|
||||
// make sure all of the user's strings tables are the same size
|
||||
for (unsigned int j = 0; j < string_tables.size(); j++) {
|
||||
int i = user_strings_list->getnum();
|
||||
if (uninst) i -= string_tables[j]->user_ustrings.getlen() / sizeof(int);
|
||||
else i -= string_tables[j]->user_strings.getlen() / sizeof(int);
|
||||
while (i--) {
|
||||
if (uninst) string_tables[j]->user_ustrings.add(&zero, sizeof(int));
|
||||
else string_tables[j]->user_strings.add(&zero, sizeof(int));
|
||||
unsigned int new_size = user_strings_list->getnum() * sizeof(int);
|
||||
for (int i = 0; i < string_tables.size(); i++) {
|
||||
if (uninst) string_tables[i]->user_ustrings.resize(new_size, 1);
|
||||
else string_tables[i]->user_strings.resize(new_size, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (string)
|
||||
((int*)user_strings->get())[idx] = uninst ? add_string_uninst(string,process) : add_string_main(string,process);
|
||||
|
||||
return PS_OK;
|
||||
}
|
||||
|
||||
|
@ -281,7 +266,7 @@ int CEXEBuild::WriteStringTables() {
|
|||
build_langtables.add(&string_tables[i]->common, sizeof(common_strings));
|
||||
build_langtables.add(&string_tables[i]->installer, sizeof(installer_strings));
|
||||
if (build_userlangstrings.getnum())
|
||||
build_langtables.add(string_tables[i]->user_strings.get(), build_userlangstrings.getnum()*sizeof(int));
|
||||
build_langtables.add(string_tables[i]->user_strings.get(), string_tables[i]->user_strings.getlen());
|
||||
}
|
||||
build_header.common.language_tables_num = st_num;
|
||||
build_header.common.language_table_size = build_langtables.getlen() / st_num;
|
||||
|
@ -291,7 +276,7 @@ int CEXEBuild::WriteStringTables() {
|
|||
ubuild_langtables.add(&string_tables[i]->ucommon, sizeof(common_strings));
|
||||
ubuild_langtables.add(&string_tables[i]->uninstall, sizeof(uninstall_strings));
|
||||
if (ubuild_userlangstrings.getnum())
|
||||
ubuild_langtables.add(string_tables[i]->user_ustrings.get(), ubuild_userlangstrings.getnum()*sizeof(int));
|
||||
ubuild_langtables.add(string_tables[i]->user_ustrings.get(), string_tables[i]->user_ustrings.getlen());
|
||||
}
|
||||
build_uninst.common.language_tables_num = st_num;
|
||||
build_uninst.common.language_table_size = ubuild_langtables.getlen() / st_num;
|
||||
|
|
|
@ -2480,7 +2480,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
c=VK_F1-1+atoi(s+1);
|
||||
if (atoi(s+1) < 1 || atoi(s+1) > 24)
|
||||
{
|
||||
warning("CreateShortCut: F-key \"%s\" out of range (%s:%d)\n",s,curfilename,linecnt);
|
||||
warning("CreateShortCut: F-key \"%s\" out of range (%s:%d)",s,curfilename,linecnt);
|
||||
}
|
||||
}
|
||||
else if (s[0] >= 'a' && s[0] <= 'z' && !s[1])
|
||||
|
@ -2490,7 +2490,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
else
|
||||
{
|
||||
c=s[0];
|
||||
warning("CreateShortCut: unrecognized hotkey \"%s\" (%s:%d)\n",s,curfilename,linecnt);
|
||||
warning("CreateShortCut: unrecognized hotkey \"%s\" (%s:%d)",s,curfilename,linecnt);
|
||||
}
|
||||
ent.offsets[4] |= (c) << 16;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ class IGrowBuf
|
|||
{
|
||||
public:
|
||||
virtual int add(const void *data, int len)=0;
|
||||
virtual void resize(int newlen)=0;
|
||||
virtual void resize(int newlen, int zero=0)=0;
|
||||
virtual int getlen()=0;
|
||||
virtual void *get()=0;
|
||||
};
|
||||
|
@ -26,9 +26,10 @@ class GrowBuf : public IGrowBuf
|
|||
return m_used-len;
|
||||
}
|
||||
|
||||
void resize(int newlen)
|
||||
void resize(int newlen, int zero=0)
|
||||
{
|
||||
int os=m_alloc;
|
||||
int ou=m_used;
|
||||
m_used=newlen;
|
||||
if (newlen > m_alloc)
|
||||
{
|
||||
|
@ -60,6 +61,7 @@ class GrowBuf : public IGrowBuf
|
|||
free(m_s);
|
||||
}
|
||||
m_s=n;
|
||||
if (zero) memset((char*)m_s+ou,0,m_used-ou);
|
||||
}
|
||||
if (!m_used && m_alloc > 65535) // only free if you resize to 0 and we're > 64k
|
||||
{
|
||||
|
@ -227,7 +229,7 @@ class MMapBuf : public IGrowBuf
|
|||
return getlen()-len;
|
||||
}
|
||||
|
||||
void resize(int newlen)
|
||||
void resize(int newlen, int zero=0)
|
||||
{
|
||||
if (!m_gb_u && newlen < (16<<20)) // still in db mode
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue