Changes to format of strings tables
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@686 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
ac00a53e1a
commit
8b9d432f7e
3 changed files with 103 additions and 106 deletions
|
@ -68,10 +68,10 @@ extern char *english_strings[] = {
|
||||||
|
|
||||||
int CEXEBuild::SetString(char *string, int id, int process, WORD lang/*=0*/) {
|
int CEXEBuild::SetString(char *string, int id, int process, WORD lang/*=0*/) {
|
||||||
lang = lang?lang:build_nlfs.size()?build_nlfs[build_nlfs.size()-1]->GetLang():0;
|
lang = lang?lang:build_nlfs.size()?build_nlfs[build_nlfs.size()-1]->GetLang():0;
|
||||||
lang = lang?lang:string_tables.size()?string_tables[0]->lang_id:1033; // Default is English (1033)
|
lang = lang?lang:string_tables.size()?string_tables[0]->common.lang_id:1033; // Default is English (1033)
|
||||||
StringTable *table = 0;
|
StringTable *table = 0;
|
||||||
for (int i = 0; i < string_tables.size(); i++) {
|
for (int i = 0; i < string_tables.size(); i++) {
|
||||||
if (lang == string_tables[i]->lang_id) {
|
if (lang == string_tables[i]->common.lang_id) {
|
||||||
table = string_tables[i];
|
table = string_tables[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ int CEXEBuild::SetString(char *string, int id, int process, WORD lang/*=0*/) {
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
memset(table, -1, sizeof(StringTable));
|
memset(table, -1, sizeof(StringTable));
|
||||||
table->lang_id = table->ucommon.lang_id = table->installer.lang_id = table->uninstall.lang_id = lang;
|
table->common.lang_id = table->ucommon.lang_id = lang;
|
||||||
string_tables.push_back(table);
|
string_tables.push_back(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,10 +159,10 @@ int CEXEBuild::SetString(char *string, int id, int process, StringTable *table)
|
||||||
bool CEXEBuild::_IsSet(int *str, WORD lang) {
|
bool CEXEBuild::_IsSet(int *str, WORD lang) {
|
||||||
if (!str) return false;
|
if (!str) return false;
|
||||||
lang = lang?lang:build_nlfs.size()?build_nlfs[build_nlfs.size()-1]->GetLang():0;
|
lang = lang?lang:build_nlfs.size()?build_nlfs[build_nlfs.size()-1]->GetLang():0;
|
||||||
lang = lang?lang:string_tables.size()?string_tables[0]->lang_id:1033; // Default is English (1033)
|
lang = lang?lang:string_tables.size()?string_tables[0]->common.lang_id:1033; // Default is English (1033)
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < string_tables.size(); i++) {
|
for (i = 0; i < string_tables.size(); i++) {
|
||||||
if (lang == string_tables[i]->lang_id) {
|
if (lang == string_tables[i]->common.lang_id) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,14 +176,14 @@ int CEXEBuild::WriteStringTables() {
|
||||||
|
|
||||||
// If we have no tables (user didn't set any string and didn't load any NLF) create the default one
|
// If we have no tables (user didn't set any string and didn't load any NLF) create the default one
|
||||||
if (string_tables.size() == 0) {
|
if (string_tables.size() == 0) {
|
||||||
build_header.str_tables_num = 1;
|
build_header.common.str_tables_num = 1;
|
||||||
StringTable *table = (StringTable*)malloc(sizeof(StringTable));
|
StringTable *table = (StringTable*)malloc(sizeof(StringTable));
|
||||||
if (!table) {
|
if (!table) {
|
||||||
ERROR_MSG("Internal compiler error #12345: malloc(%d) failed\n",sizeof(StringTable));
|
ERROR_MSG("Internal compiler error #12345: malloc(%d) failed\n",sizeof(StringTable));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
memset(table, -1, sizeof(StringTable));
|
memset(table, -1, sizeof(StringTable));
|
||||||
table->lang_id=table->ucommon.lang_id=table->installer.lang_id=table->uninstall.lang_id=1033; // English
|
table->common.lang_id=table->ucommon.lang_id=1033; // English
|
||||||
string_tables.push_back(table);
|
string_tables.push_back(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,35 +193,35 @@ int CEXEBuild::WriteStringTables() {
|
||||||
FillDefaultsIfNeeded(string_tables[i]);
|
FillDefaultsIfNeeded(string_tables[i]);
|
||||||
|
|
||||||
// Add string tables into datablock
|
// Add string tables into datablock
|
||||||
GrowBuf ist;
|
|
||||||
for (i = 0; i < st_num; i++)
|
|
||||||
ist.add(&string_tables[i]->installer, sizeof(installer_strings));
|
|
||||||
build_header.str_tables_num = st_num;
|
|
||||||
build_header.str_tables = add_data((char*)ist.get(), st_num*sizeof(installer_strings), &build_datablock);
|
|
||||||
|
|
||||||
GrowBuf cst;
|
GrowBuf cst;
|
||||||
for (i = 0; i < st_num; i++)
|
for (i = 0; i < st_num; i++)
|
||||||
cst.add(&string_tables[i]->common, sizeof(common_strings));
|
cst.add(&string_tables[i]->common, sizeof(common_strings));
|
||||||
|
build_header.common.str_tables_num = st_num;
|
||||||
build_header.common.str_tables = add_data((char*)cst.get(), st_num*sizeof(common_strings), &build_datablock);
|
build_header.common.str_tables = add_data((char*)cst.get(), st_num*sizeof(common_strings), &build_datablock);
|
||||||
|
|
||||||
GrowBuf ust;
|
GrowBuf ist;
|
||||||
for (i = 0; i < st_num; i++)
|
for (i = 0; i < st_num; i++)
|
||||||
ust.add(&string_tables[i]->uninstall, sizeof(uninstall_strings));
|
ist.add(&string_tables[i]->installer, sizeof(installer_strings));
|
||||||
build_uninst.str_tables_num = st_num;
|
build_header.common.inst_str_tables = add_data((char*)ist.get(), st_num*sizeof(installer_strings), &build_datablock);
|
||||||
build_uninst.str_tables = add_data((char*)ust.get(), st_num*sizeof(uninstall_strings), &ubuild_datablock);
|
|
||||||
|
|
||||||
GrowBuf ucst;
|
GrowBuf ucst;
|
||||||
for (i = 0; i < st_num; i++)
|
for (i = 0; i < st_num; i++)
|
||||||
ucst.add(&string_tables[i]->ucommon, sizeof(common_strings));
|
ucst.add(&string_tables[i]->ucommon, sizeof(common_strings));
|
||||||
|
build_uninst.common.str_tables_num = st_num;
|
||||||
build_uninst.common.str_tables = add_data((char*)ucst.get(), st_num*sizeof(common_strings), &ubuild_datablock);
|
build_uninst.common.str_tables = add_data((char*)ucst.get(), st_num*sizeof(common_strings), &ubuild_datablock);
|
||||||
|
|
||||||
|
GrowBuf ust;
|
||||||
|
for (i = 0; i < st_num; i++)
|
||||||
|
ust.add(&string_tables[i]->uninstall, sizeof(uninstall_strings));
|
||||||
|
build_uninst.common.inst_str_tables = add_data((char*)ust.get(), st_num*sizeof(uninstall_strings), &ubuild_datablock);
|
||||||
|
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEXEBuild::FillDefaultsIfNeeded(StringTable *table, NLF *nlf/*=0*/) {
|
void CEXEBuild::FillDefaultsIfNeeded(StringTable *table, NLF *nlf/*=0*/) {
|
||||||
if (!nlf) {
|
if (!nlf) {
|
||||||
for (int i = 0; i < build_nlfs.size(); i++) {
|
for (int i = 0; i < build_nlfs.size(); i++) {
|
||||||
if (build_nlfs[i]->GetLang() == table->lang_id) {
|
if (build_nlfs[i]->GetLang() == table->common.lang_id) {
|
||||||
nlf = build_nlfs[i];
|
nlf = build_nlfs[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
struct StringTable {
|
struct StringTable {
|
||||||
union {
|
common_strings common;
|
||||||
WORD lang_id;
|
|
||||||
common_strings common;
|
|
||||||
};
|
|
||||||
common_strings ucommon;
|
common_strings ucommon;
|
||||||
installer_strings installer;
|
installer_strings installer;
|
||||||
uninstall_strings uninstall;
|
uninstall_strings uninstall;
|
||||||
|
|
|
@ -1350,14 +1350,14 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
||||||
}
|
}
|
||||||
build_nlfs.push_back(newNLF);
|
build_nlfs.push_back(newNLF);
|
||||||
for (i = 0; i < string_tables.size(); i++) {
|
for (i = 0; i < string_tables.size(); i++) {
|
||||||
if (newNLF->GetLang() == string_tables[i]->lang_id) {
|
if (newNLF->GetLang() == string_tables[i]->common.lang_id) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i < string_tables.size()) {
|
if (i < string_tables.size()) {
|
||||||
StringTable *table = (StringTable*)malloc(sizeof(StringTable));
|
StringTable *table = (StringTable*)malloc(sizeof(StringTable));
|
||||||
memset(table, -1, sizeof(StringTable));
|
memset(table, -1, sizeof(StringTable));
|
||||||
table->lang_id=table->ucommon.lang_id=table->installer.lang_id=table->uninstall.lang_id=newNLF->GetLang();
|
table->common.lang_id=table->ucommon.lang_id=newNLF->GetLang();
|
||||||
string_tables.push_back(table);
|
string_tables.push_back(table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue