From f5105a50b1c39090a356702d485fdfa9ccdbceb3 Mon Sep 17 00:00:00 2001 From: kichik Date: Sat, 6 Aug 2005 12:47:46 +0000 Subject: [PATCH] size optimization: added __stdcall wrapper for lstrcat git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4210 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/exehead/Main.c | 16 ++++++++-------- Source/exehead/Ui.c | 6 +++--- Source/exehead/exec.c | 12 ++++++------ Source/exehead/util.c | 17 +++++++++++------ Source/exehead/util.h | 1 + 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/Source/exehead/Main.c b/Source/exehead/Main.c index cfaf6693..a84b2570 100644 --- a/Source/exehead/Main.c +++ b/Source/exehead/Main.c @@ -94,7 +94,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, if (!ValidateTempDir()) { GetWindowsDirectory(state_temp_dir, NSIS_MAX_STRLEN - 5); // leave space for \Temp - lstrcat(state_temp_dir, "\\Temp"); + mystrcat(state_temp_dir, "\\Temp"); if (!ValidateTempDir()) { goto end; @@ -193,7 +193,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, { int x; - lstrcat(state_temp_dir,"~nsu.tmp\\"); + mystrcat(state_temp_dir,"~nsu.tmp\\"); CreateDirectory(state_temp_dir,NULL); for (x = 0; x < 26; x ++) @@ -203,8 +203,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, static char ibuf[NSIS_MAX_STRLEN]; *(LPWORD)buf2=CHAR2_TO_WORD('\"',0); - lstrcat(buf2,state_temp_dir); - lstrcat(buf2,s); + mystrcat(buf2,state_temp_dir); + mystrcat(buf2,s); DeleteFile(buf2+1); // clean up after all the other ones if they are there @@ -224,10 +224,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, #endif if (state_install_directory[0]) mystrcpy(ibuf,state_install_directory); else trimslashtoend(ibuf); - lstrcat(buf2,"\" "); - lstrcat(buf2,realcmds); - lstrcat(buf2," _?="); - lstrcat(buf2,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); diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index e00a91c9..ce68865f 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -162,7 +162,7 @@ static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lPara #ifndef NSIS_CONFIG_LOG_ODS void NSISCALL build_g_logfile() { - lstrcat(addtrailingslash(mystrcpy(g_log_file,state_install_directory)),"install.log"); + mystrcat(addtrailingslash(mystrcpy(g_log_file,state_install_directory)),"install.log"); } #endif #endif @@ -882,7 +882,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar // display name gives just the folder name if (lstrcmpi(post_str, g_tmp)) { - lstrcat(addtrailingslash(dir), post_str); + mystrcat(addtrailingslash(dir), post_str); } } @@ -1383,7 +1383,7 @@ void NSISCALL update_status_text(int strtab, const char *text) { if (text) { if (tmplen + mystrlen(text) >= sizeof(tmp)) return; - lstrcat(tmp, text); + mystrcat(tmp, text); } if ((updateflag & 4)) my_SetWindowText(insthwnd2, tmp); diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index e1fb889d..77b68389 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -333,8 +333,8 @@ static int NSISCALL ExecuteEntry(entry *entry_) mystrcpy(buf1,buf3); if (mystrlen(buf3)+mystrlen(buf2) < NSIS_MAX_STRLEN-3) { - lstrcat(buf1,"->"); - lstrcat(buf1,buf2); + mystrcat(buf1,"->"); + mystrcat(buf1,buf2); } log_printf2("Rename: %s",buf1); if (MoveFile(buf3,buf2)) @@ -420,7 +420,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) { mystrcpy(buf0,buf3); } - else lstrcat(addtrailingslash(mystrcpy(buf0,state_output_directory)),buf3); + else mystrcat(addtrailingslash(mystrcpy(buf0,state_output_directory)),buf3); validate_filename(buf0); _tryagain: if (overwriteflag >= 3) // check date and time @@ -493,7 +493,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) if (ret == -2) { GetNSISString(buf0,LANG_ERRORWRITING); - lstrcat(buf0,buf3); + mystrcat(buf0,buf3); } else { @@ -1057,7 +1057,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) buf1[mystrlen(buf1)+1]=0; GetNSISString(buf2,LANG_COPYTO); - lstrcat(buf2,buf1); + mystrcat(buf2,buf1); op.pFrom=buf0; op.pTo=buf1; @@ -1403,7 +1403,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) } else { - lstrcat(addtrailingslash(mystrcpy(buf1,state_install_directory)),buf0); + mystrcat(addtrailingslash(mystrcpy(buf1,state_install_directory)),buf0); } validate_filename(buf1); diff --git a/Source/exehead/util.c b/Source/exehead/util.c index 0146713f..c3c3714b 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -116,12 +116,12 @@ void NSISCALL myDelete(char *buf, int flags) mystrcpy(lbuf,buf); #ifdef NSIS_SUPPORT_RMDIR if (flags & DEL_DIR) - lstrcat(lbuf,"\\*.*"); + mystrcat(lbuf,"\\*.*"); else #endif//NSIS_SUPPORT_RMDIR trimslashtoend(buf); - lstrcat(buf,"\\"); + mystrcat(buf,"\\"); fn=buf+mystrlen(buf); @@ -218,7 +218,7 @@ void NSISCALL myDelete(char *buf, int flags) char *NSISCALL addtrailingslash(char *str) { - if (lastchar(str)!='\\') lstrcat(str,"\\"); + if (lastchar(str)!='\\') mystrcat(str,"\\"); return str; } @@ -419,7 +419,7 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew) cchRenameLine = wsprintf(szRenameLine,"%s=%s\r\n",tmpbuf,wininit); GetWindowsDirectory(wininit, 1024-16); - lstrcat(wininit, "\\wininit.ini"); + mystrcat(wininit, "\\wininit.ini"); hfile = CreateFile(wininit, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); @@ -554,6 +554,11 @@ int NSISCALL mystrlen(const char *in) return lstrlen(in); } +char * NSISCALL mystrcat(char *out, const char *concat) +{ + return lstrcat(out, concat); +} + char ps_tmpbuf[NSIS_MAX_STRLEN*2]; #define SYSREGKEY "Software\\Microsoft\\Windows\\CurrentVersion" @@ -642,7 +647,7 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab) if (*out && append) { - lstrcat(out, append); + mystrcat(out, append); } validate_filename(out); @@ -747,7 +752,7 @@ void NSISCALL log_write(int close) if (fp!=INVALID_HANDLE_VALUE) { DWORD d; - lstrcat(log_text,"\r\n"); + mystrcat(log_text,"\r\n"); WriteFile(fp,log_text,mystrlen(log_text),&d,NULL); } } diff --git a/Source/exehead/util.h b/Source/exehead/util.h index 3c727da5..cbeb5b7e 100644 --- a/Source/exehead/util.h +++ b/Source/exehead/util.h @@ -12,6 +12,7 @@ int NSISCALL myatoi(char *s); void NSISCALL myitoa(char *s, int d); char * NSISCALL mystrcpy(char *out, const char *in); int NSISCALL mystrlen(const char *in); +char * NSISCALL mystrcat(char *out, const char *concat); char * NSISCALL mystrstr(char *a, char *b); WIN32_FIND_DATA * NSISCALL file_exists(char *buf); char * NSISCALL my_GetTempFileName(char *buf, const char *dir);