Small space-saving optimisations
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@693 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
1ee06159ec
commit
7a2cf3e5b8
5 changed files with 104 additions and 96 deletions
|
@ -147,14 +147,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
|||
if (cmdline[0] == 'D' && cmdline[1] == '=')
|
||||
{
|
||||
cmdline[-2]=0; // keep this from being passed to uninstaller if necessary
|
||||
lstrcpy(state_install_directory,cmdline+2);
|
||||
cmdline+=lstrlen(cmdline);
|
||||
mystrcpy(state_install_directory,cmdline+2);
|
||||
cmdline+=mystrlen(cmdline);
|
||||
}
|
||||
else while (*cmdline && *cmdline != ' ') cmdline=CharNext(cmdline);
|
||||
}
|
||||
while (*cmdline);
|
||||
|
||||
lstrcpy(g_caption,_LANG_GENERIC_ERROR);
|
||||
mystrcpy(g_caption,_LANG_GENERIC_ERROR);
|
||||
|
||||
g_hInstance=GetModuleHandle(NULL);
|
||||
GetModuleFileName(g_hInstance,state_exe_directory,NSIS_MAX_STRLEN);
|
||||
|
@ -285,8 +285,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
|||
cmdline+=2;
|
||||
if (is_valid_instpath(cmdline))
|
||||
{
|
||||
lstrcpy(state_install_directory,cmdline);
|
||||
lstrcpy(state_output_directory,cmdline);
|
||||
mystrcpy(state_install_directory,cmdline);
|
||||
mystrcpy(state_output_directory,cmdline);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -324,7 +324,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
|||
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
||||
MoveFileOnReboot(buf2+1,NULL);
|
||||
#endif
|
||||
if (state_install_directory[0]) lstrcpy(ibuf,state_install_directory);
|
||||
if (state_install_directory[0]) mystrcpy(ibuf,state_install_directory);
|
||||
else trimslashtoend(ibuf);
|
||||
if (!is_valid_instpath(ibuf)) break;
|
||||
done++;
|
||||
|
|
|
@ -104,24 +104,24 @@ HWND m_curwnd;
|
|||
static int m_whichcfg;
|
||||
|
||||
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
||||
BOOL SetDlgItemTextFromLang(HWND dlg, WORD id, langid_t lid) {
|
||||
static BOOL SetDlgItemTextFromLang(HWND dlg, WORD id, langid_t lid) {
|
||||
return SetDlgItemText(dlg,id,STR(GetLangString(lid)));
|
||||
}
|
||||
|
||||
BOOL SetUITextFromLang(HWND defhw, WORD def, WORD custom, langid_t lid) {
|
||||
static BOOL SetUITextFromLang(HWND defhw, WORD def, WORD custom, langid_t lid) {
|
||||
return SetDlgItemTextFromLang(custom?g_hwnd:defhw,custom?custom:def,lid);
|
||||
}
|
||||
|
||||
// no tab
|
||||
BOOL SetUITextNT(HWND defhw, WORD def, WORD custom, const char *text) {
|
||||
static BOOL SetUITextNT(HWND defhw, WORD def, WORD custom, const char *text) {
|
||||
return SetDlgItemText(custom?g_hwnd:defhw,custom?custom:def,text);
|
||||
}
|
||||
|
||||
UINT GetUIText(WORD def, WORD custom, char *str, int max_size) {
|
||||
static UINT GetUIText(WORD def, WORD custom, char *str, int max_size) {
|
||||
return GetDlgItemText(custom?g_hwnd:m_curwnd,custom?custom:def,str,max_size);
|
||||
}
|
||||
|
||||
HWND GetUIItem(HWND defhw, WORD def, WORD custom) {
|
||||
static HWND GetUIItem(HWND defhw, WORD def, WORD custom) {
|
||||
return GetDlgItem(custom?g_hwnd:defhw,custom?custom:def);
|
||||
}
|
||||
#endif
|
||||
|
@ -129,8 +129,7 @@ HWND GetUIItem(HWND defhw, WORD def, WORD custom) {
|
|||
#ifdef NSIS_CONFIG_LOG
|
||||
static void build_g_logfile()
|
||||
{
|
||||
lstrcpy(g_log_file,state_install_directory);
|
||||
addtrailingslash(g_log_file);
|
||||
addtrailingslash(mystrcpy(g_log_file,state_install_directory));
|
||||
lstrcat(g_log_file,"install.log");
|
||||
}
|
||||
#endif
|
||||
|
@ -259,7 +258,7 @@ int ui_doinstall(void)
|
|||
}
|
||||
// p is the path now, check for .exe extension
|
||||
|
||||
e=p+lstrlen(p)-4;
|
||||
e=p+mystrlen(p)-4;
|
||||
if (e > p)
|
||||
{
|
||||
// if filename ends in .exe, and is not a directory, remove the filename
|
||||
|
@ -275,7 +274,7 @@ int ui_doinstall(void)
|
|||
}
|
||||
}
|
||||
|
||||
lstrcpy(state_install_directory,p);
|
||||
mystrcpy(state_install_directory,p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +295,6 @@ int ui_doinstall(void)
|
|||
{
|
||||
// Added by Amir Szekely 3rd August 2002
|
||||
// Multilingual support
|
||||
char pa=0;
|
||||
int num=g_inst_header->common.str_tables_num;
|
||||
LANGID user_lang=GetUserDefaultLangID(), lang_mask=~(LANGID)0;
|
||||
int size=num*sizeof(common_strings);
|
||||
|
@ -320,13 +318,11 @@ lang_again:
|
|||
else
|
||||
#endif
|
||||
(installer_strings *)cur_install_strings_table+=size;
|
||||
pa++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!pa) {
|
||||
if ((size < num) && (lang_mask == ~(LANGID)0)) {
|
||||
lang_mask=0x3ff; // primary lang
|
||||
pa++;
|
||||
goto lang_again;
|
||||
}
|
||||
}
|
||||
|
@ -441,19 +437,19 @@ static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||
if (g_is_uninstaller)
|
||||
{
|
||||
islp=LANG_UNINST_TEXT>=0;
|
||||
islp = (LANG_UNINST_TEXT>=0);
|
||||
iscp++;
|
||||
}
|
||||
else
|
||||
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||
{
|
||||
#ifdef NSIS_CONFIG_LICENSEPAGE
|
||||
if (LANG_LICENSE_DATA>=0) islp++;
|
||||
islp = (LANG_LICENSE_DATA>=0);
|
||||
#endif//NSIS_CONFIG_LICENSEPAGE
|
||||
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
||||
if (LANG_COMP_TEXT>=0) iscp++;
|
||||
iscp = (LANG_COMP_TEXT>=0);
|
||||
#endif//NSIS_CONFIG_COMPONENTPAGE
|
||||
if (LANG_DIR_TEXT>=0) ispotentiallydp++;
|
||||
ispotentiallydp = (LANG_DIR_TEXT>=0);
|
||||
if (ispotentiallydp &&
|
||||
!((g_inst_cmnheader->misc_flags&2) &&
|
||||
is_valid_instpath(state_install_directory)
|
||||
|
@ -512,8 +508,8 @@ static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
(m_page == 2 || (m_page == 1 && !isdp)) ? LANGID_BTN_INSTALL :
|
||||
LANGID_BTN_NEXT
|
||||
);
|
||||
lstrcpy(g_tmp,g_caption);
|
||||
process_string_from_lang(g_tmp+lstrlen(g_tmp),LANGID_SUBCAPTION(m_page));
|
||||
mystrcpy(g_tmp,g_caption);
|
||||
process_string_from_lang(g_tmp+mystrlen(g_tmp),LANGID_SUBCAPTION(m_page));
|
||||
|
||||
SetWindowText(hwndDlg,g_tmp);
|
||||
|
||||
|
@ -647,7 +643,7 @@ static BOOL CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
|
||||
static void inttosizestr(int kb, char *str)
|
||||
{
|
||||
while (*str) str++;
|
||||
str += mystrlen(str);
|
||||
if (kb < 1024) wsprintf(str,"%dKB",kb);
|
||||
else if (kb < 1024*1024) wsprintf(str,"%d.%dMB",kb>>10,((kb*10)>>10)%10);
|
||||
else wsprintf(str,"%d.%dGB%s",kb>>20,((kb*10)>>20)%10,(GetVersion()&0x80000000) ? "+":"");
|
||||
|
@ -722,7 +718,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
if (p >= post_str && *++p)
|
||||
{
|
||||
post_str=p;
|
||||
p=name+lstrlen(name)-lstrlen(post_str);
|
||||
p=name+mystrlen(name)-mystrlen(post_str);
|
||||
if (p <= name || *CharPrev(name,p)!='\\' || lstrcmpi(p,post_str))
|
||||
{
|
||||
addtrailingslash(name);
|
||||
|
@ -773,13 +769,11 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
// Added by Amir Szekely 24th July 2002
|
||||
// Allows 'SpaceTexts none'
|
||||
if (LANG_SPACE_REQ >= 0) {
|
||||
lstrcpy(s,STR(LANG_SPACE_REQ));
|
||||
inttosizestr(total,s);
|
||||
inttosizestr(total,mystrcpy(s,STR(LANG_SPACE_REQ)));
|
||||
SetUITextNT(hwndDlg,IDC_SPACEREQUIRED,g_inst_header->space_req_id,s);
|
||||
if (available != -1)
|
||||
{
|
||||
lstrcpy(s,STR(LANG_SPACE_AVAIL));
|
||||
inttosizestr(available,s);
|
||||
inttosizestr(available,mystrcpy(s,STR(LANG_SPACE_AVAIL)));
|
||||
SetUITextNT(hwndDlg,IDC_SPACEAVAILABLE,g_inst_header->space_avail_id,s);
|
||||
}
|
||||
else
|
||||
|
@ -1124,8 +1118,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
if (g_inst_section[x].default_state&DFS_SET)
|
||||
total+=g_inst_section[x].size_kb;
|
||||
}
|
||||
lstrcpy(s,STR(LANG_SPACE_REQ));
|
||||
inttosizestr(total,s);
|
||||
inttosizestr(total,mystrcpy(s,STR(LANG_SPACE_REQ)));
|
||||
SetUITextNT(hwndDlg,IDC_SPACEREQUIRED,g_inst_header->space_req_id,s);
|
||||
}
|
||||
}
|
||||
|
@ -1148,7 +1141,7 @@ void update_status_text(const char *text1, const char *text2)
|
|||
RECT r;
|
||||
if (insthwnd)
|
||||
{
|
||||
if (lstrlen(text1)+lstrlen(text2) >= sizeof(ps_tmpbuf)) return;
|
||||
if (mystrlen(text1)+mystrlen(text2) >= sizeof(ps_tmpbuf)) return;
|
||||
wsprintf(ps_tmpbuf,"%s%s",text1,text2);
|
||||
if ((ui_st_updateflag&1))
|
||||
{
|
||||
|
@ -1281,8 +1274,8 @@ static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
if (!g_autoclose)
|
||||
{
|
||||
ShowWindow(g_hwnd,SW_SHOWNA);
|
||||
lstrcpy(g_tmp,g_caption);
|
||||
process_string_from_lang(g_tmp+lstrlen(g_caption),LANGID_SUBCAPTION(g_max_page+1));
|
||||
mystrcpy(g_tmp,g_caption);
|
||||
process_string_from_lang(g_tmp+mystrlen(g_tmp),LANGID_SUBCAPTION(g_max_page+1));
|
||||
update_status_text_from_lang(LANGID_COMPLETED,"");
|
||||
SetWindowText(g_hwnd,g_tmp);
|
||||
SetFocus(h);
|
||||
|
|
|
@ -62,6 +62,7 @@ static LONG myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyifempty)
|
|||
int retval=RegOpenKeyEx(thiskey,lpSubKey,0,KEY_ALL_ACCESS,&key);
|
||||
if (retval==ERROR_SUCCESS)
|
||||
{
|
||||
// NB - don't change this to static (recursive function)
|
||||
char buffer[MAX_PATH+1];
|
||||
while (RegEnumKey(key,0,buffer,MAX_PATH+1)==ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -113,7 +114,7 @@ int ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress)
|
|||
{
|
||||
extern int progress_bar_pos, progress_bar_len;
|
||||
progress_bar_pos+=rv;
|
||||
if (!progress_bar_len) progress_bar_len++;
|
||||
progress_bar_len+=(!progress_bar_len);
|
||||
SendMessage(hwndProgress,PBM_SETPOS,MulDiv(progress_bar_pos,30000,progress_bar_len),0);
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +202,7 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
if (parms[1])
|
||||
{
|
||||
update_status_text_from_lang(LANGID_OUTPUTDIR,buf2);
|
||||
lstrcpy(state_output_directory,buf2);
|
||||
mystrcpy(state_output_directory,buf2);
|
||||
}
|
||||
else update_status_text_from_lang(LANGID_CREATEDIR,buf2);
|
||||
recursive_create_directory(buf2);
|
||||
|
@ -230,8 +231,8 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
{
|
||||
process_string_fromtab(buf,parms[0]);
|
||||
process_string_fromtab(buf2,parms[1]);
|
||||
lstrcpy(buf4,buf);
|
||||
if (lstrlen(buf)+lstrlen(buf2) < NSIS_MAX_STRLEN-3)
|
||||
mystrcpy(buf4,buf);
|
||||
if (mystrlen(buf)+mystrlen(buf2) < NSIS_MAX_STRLEN-3)
|
||||
{
|
||||
lstrcat(buf4,"->");
|
||||
lstrcat(buf4,buf2);
|
||||
|
@ -279,7 +280,7 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
WIN32_FIND_DATA *fd=file_exists(buf);
|
||||
if (fd)
|
||||
{
|
||||
lstrcpy(fp,fd->cFileName);
|
||||
mystrcpy(fp,fd->cFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -319,14 +320,13 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
HANDLE hOut;
|
||||
int ret;
|
||||
int overwriteflag=parms[0];
|
||||
lstrcpy(buf,state_output_directory);
|
||||
addtrailingslash(buf);
|
||||
addtrailingslash(mystrcpy(buf,state_output_directory));
|
||||
|
||||
process_string_fromtab(buf4,parms[1]);
|
||||
log_printf3("File: overwriteflag=%d, name=\"%s\"",overwriteflag,buf4);
|
||||
if (validpathspec(buf4))
|
||||
{
|
||||
lstrcpy(buf,buf4);
|
||||
mystrcpy(buf,buf4);
|
||||
}
|
||||
else lstrcat(buf,buf4);
|
||||
_tryagain:
|
||||
|
@ -356,11 +356,11 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
return 0;
|
||||
}
|
||||
log_printf2("File: error creating \"%s\"",buf);
|
||||
lstrcpy(buf3,g_usrvars[0]);//save $0
|
||||
lstrcpy(g_usrvars[0],buf);
|
||||
mystrcpy(buf3,g_usrvars[0]);//save $0
|
||||
mystrcpy(g_usrvars[0],buf);
|
||||
|
||||
process_string_from_lang(buf2,LANGID_FILEERR);
|
||||
lstrcpy(g_usrvars[0],buf3); // restore $0
|
||||
mystrcpy(g_usrvars[0],buf3); // restore $0
|
||||
|
||||
switch (my_MessageBox(buf2,MB_ABORTRETRYIGNORE|MB_ICONSTOP))
|
||||
{
|
||||
|
@ -396,7 +396,7 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
}
|
||||
else
|
||||
{
|
||||
lstrcpy(buf,STR(LANG_ERRORDECOMPRESSING));
|
||||
mystrcpy(buf,STR(LANG_ERRORDECOMPRESSING));
|
||||
}
|
||||
log_printf2("%s",buf);
|
||||
my_MessageBox(buf,MB_OK|MB_ICONSTOP);
|
||||
|
@ -411,7 +411,7 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
HANDLE h;
|
||||
WIN32_FIND_DATA fd;
|
||||
process_string_fromtab(buf2,parms[0]);
|
||||
lstrcpy(buf,buf2);
|
||||
mystrcpy(buf,buf2);
|
||||
log_printf2("Delete: \"%s\"",buf);
|
||||
trimslashtoend(buf);
|
||||
h=FindFirstFile(buf2,&fd);
|
||||
|
@ -492,7 +492,7 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
#ifdef NSIS_SUPPORT_STROPTS
|
||||
case EW_STRLEN:
|
||||
process_string_fromtab(buf,parms[1]);
|
||||
myitoa(g_usrvars[parms[0]],lstrlen(buf));
|
||||
myitoa(g_usrvars[parms[0]],mystrlen(buf));
|
||||
return 0;
|
||||
case EW_ASSIGNVAR:
|
||||
{
|
||||
|
@ -504,16 +504,16 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
*p=0;
|
||||
if (parms[2] < 0 || newlen)
|
||||
{
|
||||
l=lstrlen(buf);
|
||||
l=mystrlen(buf);
|
||||
|
||||
if (start<0) start=l+start;
|
||||
if (start>=0)
|
||||
{
|
||||
if (start>l) start=l;
|
||||
lstrcpy(p,buf+start);
|
||||
mystrcpy(p,buf+start);
|
||||
if (newlen)
|
||||
{
|
||||
if (newlen<0) newlen=lstrlen(p)+newlen;
|
||||
if (newlen<0) newlen=mystrlen(p)+newlen;
|
||||
if (newlen<0) newlen=0;
|
||||
if (newlen < NSIS_MAX_STRLEN) p[newlen]=0;
|
||||
}
|
||||
|
@ -611,9 +611,9 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
log_printf2("Exch: stack < %d elements",parms[2]);
|
||||
break;
|
||||
}
|
||||
lstrcpy(buf,s->text);
|
||||
lstrcpy(s->text,g_st->text);
|
||||
lstrcpy(g_st->text,buf);
|
||||
mystrcpy(buf,s->text);
|
||||
mystrcpy(s->text,g_st->text);
|
||||
mystrcpy(g_st->text,buf);
|
||||
}
|
||||
else if (parms[1])
|
||||
{
|
||||
|
@ -623,7 +623,7 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
exec_errorflag++;
|
||||
return 0;
|
||||
}
|
||||
lstrcpy(g_usrvars[parms[0]],s->text);
|
||||
mystrcpy(g_usrvars[parms[0]],s->text);
|
||||
g_st=s->next;
|
||||
GlobalFree((HGLOBAL)s);
|
||||
}
|
||||
|
@ -870,8 +870,8 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
log_printf3("CopyFiles \"%s\"->\"%s\"",buf,buf2);
|
||||
op.hwnd=g_hwnd;
|
||||
op.wFunc=FO_COPY;
|
||||
buf[lstrlen(buf)+1]=0;
|
||||
buf2[lstrlen(buf2)+1]=0;
|
||||
buf[mystrlen(buf)+1]=0;
|
||||
buf2[mystrlen(buf2)+1]=0;
|
||||
|
||||
wsprintf(buf3,"%s%s",STR(LANG_COPYTO),buf2);
|
||||
|
||||
|
@ -933,8 +933,8 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
char *sec, *ent;
|
||||
sec=ent=0;
|
||||
#ifdef NSIS_CONFIG_LOG
|
||||
lstrcpy(buf2,"<RM>");
|
||||
lstrcpy(buf3,buf2);
|
||||
mystrcpy(buf2,"<RM>");
|
||||
mystrcpy(buf3,buf2);
|
||||
#endif
|
||||
process_string_fromtab(buf,parms[0]);
|
||||
if (parms[1]>=0)
|
||||
|
@ -1005,7 +1005,7 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
if (type <= 1)
|
||||
{
|
||||
process_string_fromtab(buf3,parms[3]);
|
||||
if (RegSetValueEx(hKey,buf2,0,type==1?REG_SZ:REG_EXPAND_SZ,buf3,lstrlen(buf3)+1) == ERROR_SUCCESS) exec_errorflag--;
|
||||
if (RegSetValueEx(hKey,buf2,0,type==1?REG_SZ:REG_EXPAND_SZ,buf3,mystrlen(buf3)+1) == ERROR_SUCCESS) exec_errorflag--;
|
||||
log_printf5("WriteRegStr: set %d\\%s\\%s to %s",rootkey,buf4,buf2,buf3);
|
||||
}
|
||||
else if (type == 2)
|
||||
|
@ -1120,7 +1120,7 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
else
|
||||
{
|
||||
process_string_fromtab(buf2,parms[1]);
|
||||
l=lstrlen(buf2);
|
||||
l=mystrlen(buf2);
|
||||
}
|
||||
if (!*t || !WriteFile((HANDLE)myatoi(t),buf2,l,&dw,NULL))
|
||||
{
|
||||
|
@ -1195,7 +1195,7 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
WIN32_FIND_DATA fd;
|
||||
if (*t && FindNextFile((HANDLE)myatoi(t),&fd))
|
||||
{
|
||||
lstrcpy(textout,fd.cFileName);
|
||||
mystrcpy(textout,fd.cFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1222,7 +1222,7 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
else
|
||||
{
|
||||
myitoa(handleout,(int)h);
|
||||
lstrcpy(textout,fd.cFileName);
|
||||
mystrcpy(textout,fd.cFileName);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -1236,12 +1236,11 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
|
||||
if (validpathspec(buf))
|
||||
{
|
||||
lstrcpy(buf2,buf);
|
||||
mystrcpy(buf2,buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
lstrcpy(buf2,state_install_directory);
|
||||
addtrailingslash(buf2);
|
||||
addtrailingslash(mystrcpy(buf2,state_install_directory));
|
||||
lstrcat(buf2,buf);
|
||||
}
|
||||
|
||||
|
@ -1384,7 +1383,7 @@ static int ExecuteEntry(entry *entries, int pos)
|
|||
case EW_PLUGINCOMMANDPREP:
|
||||
// parms[0] = dll name
|
||||
|
||||
if (!*plugins_temp_dir) lstrcpy(plugins_temp_dir,g_usrvars[0]);
|
||||
if (!*plugins_temp_dir) mystrcpy(plugins_temp_dir,g_usrvars[0]);
|
||||
return 0;
|
||||
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ void doRMDir(char *buf, int recurse)
|
|||
{
|
||||
if (recurse && is_valid_instpath(buf))
|
||||
{
|
||||
int i=lstrlen(buf);
|
||||
int i=mystrlen(buf);
|
||||
HANDLE h;
|
||||
WIN32_FIND_DATA fd;
|
||||
lstrcat(buf,"\\*.*");
|
||||
|
@ -51,7 +51,7 @@ void doRMDir(char *buf, int recurse)
|
|||
if (fd.cFileName[0] != '.' ||
|
||||
(fd.cFileName[1] != '.' && fd.cFileName[1]))
|
||||
{
|
||||
lstrcpy(buf+i+1,fd.cFileName);
|
||||
mystrcpy(buf+i+1,fd.cFileName);
|
||||
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) doRMDir(buf,recurse);
|
||||
else
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ void addtrailingslash(char *str)
|
|||
|
||||
char lastchar(const char *str)
|
||||
{
|
||||
return *CharPrev(str,str+lstrlen(str));
|
||||
return *CharPrev(str,str+mystrlen(str));
|
||||
}
|
||||
|
||||
void trimslashtoend(char *buf)
|
||||
|
@ -92,7 +92,7 @@ void trimslashtoend(char *buf)
|
|||
|
||||
char *scanendslash(const char *str)
|
||||
{
|
||||
char *s=CharPrev(str,str+lstrlen(str));
|
||||
char *s=CharPrev(str,str+mystrlen(str));
|
||||
if (!*str) return (char*)str-1;
|
||||
for (;;)
|
||||
{
|
||||
|
@ -145,8 +145,8 @@ int is_valid_instpath(char *s)
|
|||
|
||||
static char *findinmem(char *a, char *b, int len_of_a)
|
||||
{
|
||||
if (len_of_a<0) len_of_a=lstrlen(a);
|
||||
len_of_a -= lstrlen(b);
|
||||
if (len_of_a<0) len_of_a=mystrlen(a);
|
||||
len_of_a -= mystrlen(b);
|
||||
while (*a && len_of_a >= 0)
|
||||
{
|
||||
char *t=a,*u=b;
|
||||
|
@ -235,7 +235,7 @@ BOOL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
|
|||
LPSTR pszRenameSecInFile = findinmem(pszWinInit, szRenameSec,-1);
|
||||
if (pszRenameSecInFile == NULL)
|
||||
{
|
||||
lstrcpy(pszWinInit+dwFileSize, szRenameSec);
|
||||
mystrcpy(pszWinInit+dwFileSize, szRenameSec);
|
||||
dwFileSize += 10;
|
||||
dwRenameLinePos = dwFileSize;
|
||||
do_write++;
|
||||
|
@ -369,6 +369,7 @@ int GetLangString(langid_t id)
|
|||
}
|
||||
|
||||
void myitoa(char *s, int d) { wsprintf(s,"%d",d); }
|
||||
|
||||
int myatoi(char *s)
|
||||
{
|
||||
unsigned int v=0;
|
||||
|
@ -414,6 +415,19 @@ int myatoi(char *s)
|
|||
return (int)v;
|
||||
}
|
||||
|
||||
// Straight copies of selected shell functions. Calling local functions
|
||||
// requires less code than DLL functions. For the savings to outweigh the cost
|
||||
// of a new function there should be about a couple of dozen or so calls.
|
||||
char *mystrcpy(char *out, const char *in)
|
||||
{
|
||||
return lstrcpy(out, in);
|
||||
}
|
||||
|
||||
int mystrlen(const char *in)
|
||||
{
|
||||
return lstrlen(in);
|
||||
}
|
||||
|
||||
|
||||
int process_string_fromtab_toint(int offs)
|
||||
{
|
||||
|
@ -468,13 +482,13 @@ void process_string(char *out, const char *in)
|
|||
case VAR_CODES_START + 22: // INSTDIR
|
||||
case VAR_CODES_START + 23: // OUTDIR
|
||||
case VAR_CODES_START + 24: // EXEDIR
|
||||
lstrcpy(out, g_usrvars[nVarIdx - (VAR_CODES_START + 1)]);
|
||||
mystrcpy(out, g_usrvars[nVarIdx - (VAR_CODES_START + 1)]);
|
||||
break;
|
||||
|
||||
case VAR_CODES_START + 25: // PROGRAMFILES
|
||||
myRegGetStr(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion", "ProgramFilesDir", out);
|
||||
if (!*out)
|
||||
lstrcpy(out, "C:\\Program Files");
|
||||
mystrcpy(out, "C:\\Program Files");
|
||||
break;
|
||||
|
||||
case VAR_CODES_START + 26: // SMPROGRAMS
|
||||
|
@ -516,7 +530,7 @@ void process_string(char *out, const char *in)
|
|||
|
||||
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||
case VAR_CODES_START + 35: // PLUGINSDIR
|
||||
lstrcpy(out, plugins_temp_dir);
|
||||
mystrcpy(out, plugins_temp_dir);
|
||||
break;
|
||||
|
||||
#if VAR_CODES_START + 35 >= 255
|
||||
|
@ -558,7 +572,7 @@ void log_write(int close)
|
|||
{
|
||||
if (g_log_file[0] && fp==INVALID_HANDLE_VALUE)
|
||||
{
|
||||
fp = CreateFile(g_log_file,GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,0,NULL);
|
||||
fp = myOpenFile(g_log_file,GENERIC_WRITE,OPEN_ALWAYS);
|
||||
if (fp!=INVALID_HANDLE_VALUE)
|
||||
SetFilePointer(fp,0,NULL,FILE_END);
|
||||
}
|
||||
|
@ -566,7 +580,7 @@ void log_write(int close)
|
|||
{
|
||||
DWORD d;
|
||||
lstrcat(log_text,"\r\n");
|
||||
WriteFile(fp,log_text,lstrlen(log_text),&d,NULL);
|
||||
WriteFile(fp,log_text,mystrlen(log_text),&d,NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ int process_string_fromtab_toint(int offs);
|
|||
void myRegGetStr(HKEY root, const char *sub, const char *name, char *out);
|
||||
int myatoi(char *s);
|
||||
void myitoa(char *s, int d);
|
||||
char *mystrcpy(char *out, const char *in);
|
||||
int mystrlen(const char *in);
|
||||
|
||||
#ifdef NSIS_CONFIG_LOG
|
||||
extern char log_text[NSIS_MAX_STRLEN*4];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue