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
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
set_uninstall_mode(1);
|
||||
|
||||
DefineInnerLangString(NLF_UCAPTION);
|
||||
|
||||
if (resolve_coderefs("uninstall"))
|
||||
return PS_ERROR;
|
||||
|
||||
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
||||
// set sections to the first insttype
|
||||
PrepareInstTypes();
|
||||
#endif
|
||||
|
||||
// Add standard strings to string table
|
||||
AddStandardStrings();
|
||||
|
||||
set_uninstall_mode(0);
|
||||
}
|
||||
else if (uninstaller_writes_used)
|
||||
|
@ -2332,6 +2353,9 @@ int CEXEBuild::write_output(void)
|
|||
// Set XML manifest
|
||||
RET_UNLESS_OK( SetManifest() );
|
||||
|
||||
// Add standard strings to string table
|
||||
AddStandardStrings();
|
||||
|
||||
try {
|
||||
// Save all changes to the exe header
|
||||
close_res_editor();
|
||||
|
|
|
@ -244,6 +244,7 @@ class CEXEBuild {
|
|||
int AddVersionInfo();
|
||||
int ProcessPages();
|
||||
void PrepareInstTypes();
|
||||
void AddStandardStrings();
|
||||
void PrepareHeaders(IGrowBuf *hdrbuf);
|
||||
int SetVarsSection();
|
||||
int SetManifest();
|
||||
|
|
|
@ -197,45 +197,42 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
|||
else
|
||||
{
|
||||
int x;
|
||||
char s[] = "Au_.exe";
|
||||
|
||||
mystrcat(state_temp_dir,"~nsu.tmp\\");
|
||||
mystrcat(state_temp_dir,"~nsu.tmp");
|
||||
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 ++)
|
||||
{
|
||||
static char s[]="Au_.exe";
|
||||
static char buf2[NSIS_MAX_STRLEN*2];
|
||||
static char buf2[NSIS_MAX_STRLEN];
|
||||
static char ibuf[NSIS_MAX_STRLEN];
|
||||
|
||||
*(LPWORD)buf2=CHAR2_TO_WORD('\"',0);
|
||||
mystrcat(buf2,state_temp_dir);
|
||||
mystrcat(buf2,s);
|
||||
GetNSISString(buf2,g_header->str_uninstchild); // $TEMP\$1
|
||||
|
||||
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
|
||||
{
|
||||
// get current name
|
||||
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;
|
||||
|
||||
// copy file
|
||||
if (CopyFile(ibuf,buf2+1,TRUE))
|
||||
if (CopyFile(ibuf,buf2,TRUE))
|
||||
{
|
||||
HANDLE hProc;
|
||||
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
||||
MoveFileOnReboot(buf2+1,NULL);
|
||||
MoveFileOnReboot(buf2,NULL);
|
||||
MoveFileOnReboot(state_temp_dir,NULL);
|
||||
#endif
|
||||
if (state_install_directory[0]) mystrcpy(ibuf,state_install_directory);
|
||||
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);
|
||||
GetNSISString(buf2,g_header->str_uninstcmd); // "$TEMP\$1" $0 _?=$INSTDIR\
|
||||
hProc=myCreateProcess(buf2,state_temp_dir);
|
||||
if (hProc)
|
||||
{
|
||||
|
@ -245,7 +242,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
|||
}
|
||||
}
|
||||
}
|
||||
s[0]++;
|
||||
g_usrvars[1][0]++;
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
|
|
|
@ -329,6 +329,14 @@ typedef struct
|
|||
|
||||
int install_directory_ptr; // default install dir.
|
||||
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;
|
||||
|
||||
#ifdef NSIS_SUPPORT_CODECALLBACKS
|
||||
|
|
|
@ -448,8 +448,7 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
|
|||
return;
|
||||
cchRenameLine = wsprintf(szRenameLine,"%s=%s\r\n",tmpbuf,wininit);
|
||||
|
||||
GetWindowsDirectory(wininit, 1024-16);
|
||||
mystrcat(wininit, "\\wininit.ini");
|
||||
GetNSISString(wininit, g_header->str_wininit);
|
||||
hfile = myOpenFile(wininit, GENERIC_READ | GENERIC_WRITE, OPEN_ALWAYS);
|
||||
|
||||
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_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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue