diff --git a/Source/build.cpp b/Source/build.cpp index 044fefdd..d4b2f40b 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -1082,6 +1082,7 @@ int CEXEBuild::write_output(void) // Added by Amir Szekely 3rd August 2002 if (WriteStringTables() == PS_ERROR) return PS_ERROR; + build_header.common.num_string_bytes=build_strlist.getlen(); /*#ifdef NSIS_CONFIG_COMPONENTPAGE if (build_header.componenttext_ptr < 0 && @@ -1373,6 +1374,7 @@ int CEXEBuild::write_output(void) hdrcomp.add(build_sections.get(),build_sections.getlen()); hdrcomp.add(build_entries.get(),build_entries.getlen()); hdrcomp.add(build_strlist.get(),build_strlist.getlen()); + hdrcomp.add(build_langtables.get(),build_langtables.getlen()); if (add_data((char*)hdrcomp.get(),hdrcomp.getlen(),&ihd) < 0) return PS_ERROR; @@ -1638,6 +1640,8 @@ int CEXEBuild::uninstall_generate() { firstheader fh={0,}; + build_uninst.common.num_string_bytes=ubuild_strlist.getlen(); + GrowBuf uhd; // add one more bit (the code+strtabs) to the uninstall datablock { @@ -1646,6 +1650,7 @@ int CEXEBuild::uninstall_generate() udata.add(&build_uninst,sizeof(build_uninst)); udata.add(ubuild_entries.get(),ubuild_entries.getlen()); udata.add(ubuild_strlist.get(),ubuild_strlist.getlen()); + udata.add(ubuild_langtables.get(),ubuild_langtables.getlen()); set_uninstall_mode(1); fh.length_of_header=udata.getlen(); diff --git a/Source/build.h b/Source/build.h index 2b434974..58577866 100644 --- a/Source/build.h +++ b/Source/build.h @@ -195,6 +195,7 @@ class CEXEBuild { GrowBuf build_functions, ubuild_functions, *cur_functions; GrowBuf build_labels, ubuild_labels, *cur_labels; StringList build_strlist,ubuild_strlist; + GrowBuf build_langtables, ubuild_langtables; MMapBuf build_datablock, ubuild_datablock; // use GrowBuf here instead of MMapBuf if you want IGrowBuf *cur_datablock; diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index a0d968d0..08cb62d1 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -366,19 +366,12 @@ int NSISCALL ui_doinstall(void) // Added by Amir Szekely 3rd August 2002 // Multilingual support { - int size; - lang_num=g_inst_header->common.str_tables_num; - size=lang_num*sizeof(common_strings); - cur_common_strings_table=common_strings_tables=(common_strings*)my_GlobalAlloc(size); - GetCompressedDataFromDataBlockToMemory(g_inst_header->common.str_tables,(char*)common_strings_tables,size); - #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT - if (g_is_uninstaller) - size=lang_num*sizeof(uninstall_strings); - else - #endif - size=lang_num*sizeof(installer_strings); - cur_install_strings_table=install_strings_tables=(char *)my_GlobalAlloc(size); - GetCompressedDataFromDataBlockToMemory(g_inst_header->common.inst_str_tables,install_strings_tables,size); + extern char *g_db_strtab; + lang_num=g_inst_cmnheader->str_tables_num; + cur_common_strings_table=common_strings_tables= + (common_strings*)(g_db_strtab+g_inst_cmnheader->num_string_bytes); + cur_install_strings_table=install_strings_tables= + (char*)((unsigned long)common_strings_tables+lang_num*sizeof(common_strings)); myitoa(state_language, GetUserDefaultLangID()); set_language(); diff --git a/Source/exehead/fileform.c b/Source/exehead/fileform.c index 1868e6b2..47b85c5e 100644 --- a/Source/exehead/fileform.c +++ b/Source/exehead/fileform.c @@ -24,7 +24,7 @@ static int bz2_needreinit; #include "ui.h" -static char *g_db_strtab; +char *g_db_strtab; static int g_db_offset; HANDLE g_db_hFile; @@ -223,8 +223,6 @@ static int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int out } #else//NSIS_COMPRESS_WHOLE - -#if 0 // SHOUDLNT NEED THIS IF EVEYRTHING IS IN PROPER ORDER static char _inbuffer[IBUFSIZE]; static char _outbuffer[OBUFSIZE]; extern int m_length; @@ -301,55 +299,6 @@ static int NSISCALL __ensuredata(int amount) return 0; } -#else // JUSTINS CLASSIC VERSION - -static char _inbuffer[IBUFSIZE]; -static char _outbuffer[OBUFSIZE]; -static int __ensuredata(int amount) -{ - int needed=amount-(dbd_size-dbd_pos); - if (needed>0) - { - SetFilePointer(g_db_hFile,dbd_srcpos,NULL,FILE_BEGIN); - SetFilePointer(dbd_hFile,dbd_size,NULL,FILE_BEGIN); - for (;;) - { - int err; - DWORD or; - if (!ReadFile(g_db_hFile,(LPVOID)_inbuffer,min(IBUFSIZE,dbd_fulllen-dbd_srcpos),&or,NULL)) return -1; - dbd_srcpos+=or; - g_inflate_stream.next_in=_inbuffer; - g_inflate_stream.avail_in=or; - do - { - DWORD r,t; - g_inflate_stream.next_out=_outbuffer; - g_inflate_stream.avail_out=OBUFSIZE; - err=inflate(&g_inflate_stream); - if (err<0) - { - return -3; - } - r=g_inflate_stream.next_out-_outbuffer; - if (r) - { - if (!WriteFile(dbd_hFile,_outbuffer,r,&t,NULL) || r != t) - { - return -2; - } - dbd_size+=r; - } - else if (g_inflate_stream.avail_in || !or) return -3; - else break; - } - while (g_inflate_stream.avail_in); - if (amount-(dbd_size-dbd_pos) <= 0) break; - } - SetFilePointer(dbd_hFile,dbd_pos,NULL,FILE_BEGIN); - } - return 0; -} -#endif static int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen) { diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index 67fbf978..4885069c 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -283,10 +283,9 @@ typedef struct typedef struct { int str_tables_num; // number of strings tables in array - int str_tables; // offset to common string tables array - int inst_str_tables; // offset to install/uninstall string tables array int num_entries; // total number of entries + int num_string_bytes; // total number of bytes taken by strings #ifdef NSIS_SUPPORT_BGBG int bg_color1, bg_color2, bg_textcolor; diff --git a/Source/lang.cpp b/Source/lang.cpp index def346e1..edc3ee6c 100644 --- a/Source/lang.cpp +++ b/Source/lang.cpp @@ -214,27 +214,19 @@ int CEXEBuild::WriteStringTables() { FillDefaultsIfNeeded(string_tables[i]); // Add string tables into datablock - GrowBuf cst; for (i = 0; i < st_num; i++) - cst.add(&string_tables[i]->common, sizeof(common_strings)); + build_langtables.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); - GrowBuf ist; for (i = 0; i < st_num; i++) - ist.add(&string_tables[i]->installer, sizeof(installer_strings)); - build_header.common.inst_str_tables = add_data((char*)ist.get(), st_num*sizeof(installer_strings), &build_datablock); + build_langtables.add(&string_tables[i]->installer, sizeof(installer_strings)); - GrowBuf ucst; for (i = 0; i < st_num; i++) - ucst.add(&string_tables[i]->ucommon, sizeof(common_strings)); + ubuild_langtables.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); - 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); + ubuild_langtables.add(&string_tables[i]->uninstall, sizeof(uninstall_strings)); return PS_OK; }