size optimization - use GetNSISString to do complicated stirng processing
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4971 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
b00c69290f
commit
05d910c289
6 changed files with 58 additions and 21 deletions
|
@ -2083,6 +2083,20 @@ void CEXEBuild::PrepareInstTypes()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void CEXEBuild::AddStandardStrings()
|
||||||
|
{
|
||||||
|
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
|
if (uninstall_mode)
|
||||||
|
{
|
||||||
|
cur_header->str_uninstchild = add_string("$TEMP\\$1");
|
||||||
|
cur_header->str_uninstcmd = add_string("\"$TEMP\\$1\" $0 _?=$INSTDIR\\");
|
||||||
|
}
|
||||||
|
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
||||||
|
cur_header->str_wininit = add_string("$WINDIR\\wininit.ini");
|
||||||
|
#endif//NSIS_SUPPORT_MOVEONREBOOT
|
||||||
|
}
|
||||||
|
|
||||||
void CEXEBuild::PrepareHeaders(IGrowBuf *hdrbuf)
|
void CEXEBuild::PrepareHeaders(IGrowBuf *hdrbuf)
|
||||||
{
|
{
|
||||||
GrowBuf blocks_buf;
|
GrowBuf blocks_buf;
|
||||||
|
@ -2236,13 +2250,20 @@ int CEXEBuild::prepare_uninstaller() {
|
||||||
build_uninst.flags|=build_header.flags&(CH_FLAGS_PROGRESS_COLORED|CH_FLAGS_NO_ROOT_DIR);
|
build_uninst.flags|=build_header.flags&(CH_FLAGS_PROGRESS_COLORED|CH_FLAGS_NO_ROOT_DIR);
|
||||||
|
|
||||||
set_uninstall_mode(1);
|
set_uninstall_mode(1);
|
||||||
|
|
||||||
DefineInnerLangString(NLF_UCAPTION);
|
DefineInnerLangString(NLF_UCAPTION);
|
||||||
|
|
||||||
if (resolve_coderefs("uninstall"))
|
if (resolve_coderefs("uninstall"))
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
|
|
||||||
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
||||||
// set sections to the first insttype
|
// set sections to the first insttype
|
||||||
PrepareInstTypes();
|
PrepareInstTypes();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Add standard strings to string table
|
||||||
|
AddStandardStrings();
|
||||||
|
|
||||||
set_uninstall_mode(0);
|
set_uninstall_mode(0);
|
||||||
}
|
}
|
||||||
else if (uninstaller_writes_used)
|
else if (uninstaller_writes_used)
|
||||||
|
@ -2332,6 +2353,9 @@ int CEXEBuild::write_output(void)
|
||||||
// Set XML manifest
|
// Set XML manifest
|
||||||
RET_UNLESS_OK( SetManifest() );
|
RET_UNLESS_OK( SetManifest() );
|
||||||
|
|
||||||
|
// Add standard strings to string table
|
||||||
|
AddStandardStrings();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Save all changes to the exe header
|
// Save all changes to the exe header
|
||||||
close_res_editor();
|
close_res_editor();
|
||||||
|
|
|
@ -244,6 +244,7 @@ class CEXEBuild {
|
||||||
int AddVersionInfo();
|
int AddVersionInfo();
|
||||||
int ProcessPages();
|
int ProcessPages();
|
||||||
void PrepareInstTypes();
|
void PrepareInstTypes();
|
||||||
|
void AddStandardStrings();
|
||||||
void PrepareHeaders(IGrowBuf *hdrbuf);
|
void PrepareHeaders(IGrowBuf *hdrbuf);
|
||||||
int SetVarsSection();
|
int SetVarsSection();
|
||||||
int SetManifest();
|
int SetManifest();
|
||||||
|
|
|
@ -197,45 +197,42 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
char s[] = "Au_.exe";
|
||||||
|
|
||||||
mystrcat(state_temp_dir,"~nsu.tmp\\");
|
mystrcat(state_temp_dir,"~nsu.tmp");
|
||||||
CreateDirectory(state_temp_dir,NULL);
|
CreateDirectory(state_temp_dir,NULL);
|
||||||
|
|
||||||
|
if (!state_install_directory[0])
|
||||||
|
mystrcpy(state_install_directory,state_exe_directory);
|
||||||
|
|
||||||
|
mystrcpy(g_usrvars[0], realcmds);
|
||||||
|
mystrcpy(g_usrvars[1], s);
|
||||||
|
|
||||||
for (x = 0; x < 26; x ++)
|
for (x = 0; x < 26; x ++)
|
||||||
{
|
{
|
||||||
static char s[]="Au_.exe";
|
static char buf2[NSIS_MAX_STRLEN];
|
||||||
static char buf2[NSIS_MAX_STRLEN*2];
|
|
||||||
static char ibuf[NSIS_MAX_STRLEN];
|
static char ibuf[NSIS_MAX_STRLEN];
|
||||||
|
|
||||||
*(LPWORD)buf2=CHAR2_TO_WORD('\"',0);
|
GetNSISString(buf2,g_header->str_uninstchild); // $TEMP\$1
|
||||||
mystrcat(buf2,state_temp_dir);
|
|
||||||
mystrcat(buf2,s);
|
|
||||||
|
|
||||||
DeleteFile(buf2+1); // clean up after all the other ones if they are there
|
DeleteFile(buf2); // clean up after all the other ones if they are there
|
||||||
|
|
||||||
if (m_Err) // not done yet
|
if (m_Err) // not done yet
|
||||||
{
|
{
|
||||||
// get current name
|
// get current name
|
||||||
int l=GetModuleFileName(NULL,ibuf,sizeof(ibuf));
|
int l=GetModuleFileName(NULL,ibuf,sizeof(ibuf));
|
||||||
// check if it is ?Au_.exe - if so, fuck it
|
// check if it is ?u_.exe - if so, fuck it
|
||||||
if (!lstrcmpi(ibuf+l-(sizeof(s)-2),s+1)) break;
|
if (!lstrcmpi(ibuf+l-(sizeof(s)-2),s+1)) break;
|
||||||
|
|
||||||
// copy file
|
// copy file
|
||||||
if (CopyFile(ibuf,buf2+1,TRUE))
|
if (CopyFile(ibuf,buf2,TRUE))
|
||||||
{
|
{
|
||||||
HANDLE hProc;
|
HANDLE hProc;
|
||||||
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
||||||
MoveFileOnReboot(buf2+1,NULL);
|
MoveFileOnReboot(buf2,NULL);
|
||||||
MoveFileOnReboot(state_temp_dir,NULL);
|
MoveFileOnReboot(state_temp_dir,NULL);
|
||||||
#endif
|
#endif
|
||||||
if (state_install_directory[0]) mystrcpy(ibuf,state_install_directory);
|
GetNSISString(buf2,g_header->str_uninstcmd); // "$TEMP\$1" $0 _?=$INSTDIR\
|
||||||
else trimslashtoend(ibuf);
|
|
||||||
mystrcat(buf2,"\" ");
|
|
||||||
mystrcat(buf2,realcmds);
|
|
||||||
mystrcat(buf2," _?=");
|
|
||||||
mystrcat(buf2,ibuf);
|
|
||||||
// add a trailing backslash to make sure is_valid_instpath will not fail when it shouldn't
|
|
||||||
addtrailingslash(buf2);
|
|
||||||
hProc=myCreateProcess(buf2,state_temp_dir);
|
hProc=myCreateProcess(buf2,state_temp_dir);
|
||||||
if (hProc)
|
if (hProc)
|
||||||
{
|
{
|
||||||
|
@ -245,7 +242,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s[0]++;
|
g_usrvars[1][0]++;
|
||||||
}
|
}
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,6 +329,14 @@ typedef struct
|
||||||
|
|
||||||
int install_directory_ptr; // default install dir.
|
int install_directory_ptr; // default install dir.
|
||||||
int install_directory_auto_append; // auto append part
|
int install_directory_auto_append; // auto append part
|
||||||
|
|
||||||
|
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
|
int str_uninstchild;
|
||||||
|
int str_uninstcmd;
|
||||||
|
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
||||||
|
int str_wininit;
|
||||||
|
#endif//NSIS_SUPPORT_MOVEONREBOOT
|
||||||
} header;
|
} header;
|
||||||
|
|
||||||
#ifdef NSIS_SUPPORT_CODECALLBACKS
|
#ifdef NSIS_SUPPORT_CODECALLBACKS
|
||||||
|
|
|
@ -448,8 +448,7 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
|
||||||
return;
|
return;
|
||||||
cchRenameLine = wsprintf(szRenameLine,"%s=%s\r\n",tmpbuf,wininit);
|
cchRenameLine = wsprintf(szRenameLine,"%s=%s\r\n",tmpbuf,wininit);
|
||||||
|
|
||||||
GetWindowsDirectory(wininit, 1024-16);
|
GetNSISString(wininit, g_header->str_wininit);
|
||||||
mystrcat(wininit, "\\wininit.ini");
|
|
||||||
hfile = myOpenFile(wininit, GENERIC_READ | GENERIC_WRITE, OPEN_ALWAYS);
|
hfile = myOpenFile(wininit, GENERIC_READ | GENERIC_WRITE, OPEN_ALWAYS);
|
||||||
|
|
||||||
if (hfile != INVALID_HANDLE_VALUE)
|
if (hfile != INVALID_HANDLE_VALUE)
|
||||||
|
|
|
@ -95,6 +95,14 @@ void header_writer::write(const header *data)
|
||||||
|
|
||||||
m_sink->write_int(data->install_directory_ptr);
|
m_sink->write_int(data->install_directory_ptr);
|
||||||
m_sink->write_int(data->install_directory_auto_append);
|
m_sink->write_int(data->install_directory_auto_append);
|
||||||
|
|
||||||
|
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
|
m_sink->write_int(data->str_uninstchild);
|
||||||
|
m_sink->write_int(data->str_uninstcmd);
|
||||||
|
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
||||||
|
m_sink->write_int(data->str_wininit);
|
||||||
|
#endif//NSIS_SUPPORT_MOVEONREBOOT
|
||||||
}
|
}
|
||||||
|
|
||||||
void section_writer::write(const section *data)
|
void section_writer::write(const section *data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue