/NOCD instead of /CD

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1704 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-11-14 20:03:07 +00:00
parent 1f9aee2b38
commit be7192efb7
6 changed files with 449 additions and 443 deletions

View file

@ -37,6 +37,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmd
my_memset(&g_resize,0,sizeof(NRESIZEDATA)); my_memset(&g_resize,0,sizeof(NRESIZEDATA));
my_memset(&g_find,0,sizeof(NFINDREPLACE)); my_memset(&g_find,0,sizeof(NFINDREPLACE));
g_sdata.hInstance=GetModuleHandle(0); g_sdata.hInstance=GetModuleHandle(0);
g_sdata.script_alloced=false;
g_sdata.script=GetCommandLine(); g_sdata.script=GetCommandLine();
JNL::open_socketlib(); JNL::open_socketlib();
if (*g_sdata.script=='"') { g_sdata.script++; while (*g_sdata.script && *g_sdata.script++!='"' ); } if (*g_sdata.script=='"') { g_sdata.script++; while (*g_sdata.script && *g_sdata.script++!='"' ); }
@ -65,6 +66,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmd
} }
} }
JNL::close_socketlib(); JNL::close_socketlib();
if (g_sdata.script_alloced) GlobalFree(g_sdata.script);
ExitProcess(msg.wParam); ExitProcess(msg.wParam);
return msg.wParam; return msg.wParam;
} }
@ -132,8 +134,9 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
if (num==1) { if (num==1) {
DragQueryFile((HDROP)wParam,0,szTmp,MAX_PATH); DragQueryFile((HDROP)wParam,0,szTmp,MAX_PATH);
if (lstrlen(szTmp)>0) { if (lstrlen(szTmp)>0) {
g_sdata.script_alloced = true;
g_sdata.script = (char *)GlobalAlloc(GPTR,sizeof(szTmp)+7); g_sdata.script = (char *)GlobalAlloc(GPTR,sizeof(szTmp)+7);
wsprintf(g_sdata.script,"/CD \"%s\"",szTmp); wsprintf(g_sdata.script,"\"%s\"",szTmp);
ResetObjects(); ResetObjects();
CompileNSISScript(); CompileNSISScript();
} }
@ -247,7 +250,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
{ {
if (!g_sdata.thread) { if (!g_sdata.thread) {
OPENFILENAME l={sizeof(l),}; OPENFILENAME l={sizeof(l),};
char buf[MAX_STRING]; char buf[MAX_PATH];
l.hwndOwner = hwndDlg; l.hwndOwner = hwndDlg;
l.lpstrFilter = "NSIS Script (*.nsi)\0*.nsi\0All Files (*.*)\0*.*\0"; l.lpstrFilter = "NSIS Script (*.nsi)\0*.nsi\0All Files (*.*)\0*.*\0";
l.lpstrFile = buf; l.lpstrFile = buf;
@ -259,8 +262,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST; l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
lstrcpy(buf,""); lstrcpy(buf,"");
if (GetOpenFileName(&l)) { if (GetOpenFileName(&l)) {
g_sdata.script = (char *)GlobalAlloc(GPTR,sizeof(buf)+7); g_sdata.script = (char *)GlobalAlloc(GPTR,lstrlen(buf)+3);
wsprintf(g_sdata.script,"/CD \"%s\"",buf); wsprintf(g_sdata.script,"\"%s\"",buf);
ResetObjects(); ResetObjects();
CompileNSISScript(); CompileNSISScript();
} }

View file

@ -70,6 +70,7 @@ void CompileNSISScript();
DWORD CALLBACK UpdateThread(LPVOID v); DWORD CALLBACK UpdateThread(LPVOID v);
typedef struct NSISScriptData { typedef struct NSISScriptData {
bool script_alloced;
char *script; char *script;
char *output_exe; char *output_exe;
char *input_script; char *input_script;

View file

@ -165,8 +165,10 @@ void CompileNSISScript() {
} }
if (!g_sdata.appended) { if (!g_sdata.appended) {
if (s) GlobalFree(s); if (s) GlobalFree(s);
s = (char *)GlobalAlloc(GPTR, lstrlen(g_sdata.script)+lstrlen(EXENAME)+2); s = (char *)GlobalAlloc(GPTR, lstrlen(g_sdata.script)+sizeof(EXENAME)+2);
wsprintf(s,"%s %s",EXENAME,g_sdata.script); wsprintf(s,"%s %s",EXENAME,g_sdata.script);
if (g_sdata.script_alloced) GlobalFree(g_sdata.script);
g_sdata.script_alloced = true;
g_sdata.script = s; g_sdata.script = s;
g_sdata.appended = TRUE; g_sdata.appended = TRUE;
} }

View file

@ -22,7 +22,7 @@ If you want to use MakeNSIS on the command line, the syntax of the makensis comm
\b /HDRINFO prints out information on what options Makensis was compiled with. \b /HDRINFO prints out information on what options Makensis was compiled with.
\b /CD tells the compiler to switch to the directory of the script it is currently compiling. \b /NOCD disabled the current directory change to that of the .nsi file
\b Using the /D switch one or more times will add to symbols to the globally defined list (See !define). \b Using the /D switch one or more times will add to symbols to the globally defined list (See !define).

View file

@ -111,9 +111,9 @@ Section "NSI Development Shell Extensions" SecExtention
WriteRegStr HKCR "NSISFile\DefaultIcon" "" $INSTDIR\makensisw.exe,1 WriteRegStr HKCR "NSISFile\DefaultIcon" "" $INSTDIR\makensisw.exe,1
WriteRegStr HKCR "NSISFile\shell\open\command" "" 'notepad.exe "%1"' WriteRegStr HKCR "NSISFile\shell\open\command" "" 'notepad.exe "%1"'
WriteRegStr HKCR "NSISFile\shell\compile" "" "Compile NSI" WriteRegStr HKCR "NSISFile\shell\compile" "" "Compile NSI"
WriteRegStr HKCR "NSISFile\shell\compile\command" "" '"$INSTDIR\makensisw.exe" /CD "%1"' WriteRegStr HKCR "NSISFile\shell\compile\command" "" '"$INSTDIR\makensisw.exe" "%1"'
WriteRegStr HKCR "NSISFile\shell\compile-bz2" "" "Compile NSI (with bz2)" WriteRegStr HKCR "NSISFile\shell\compile-bz2" "" "Compile NSI (with bz2)"
WriteRegStr HKCR "NSISFile\shell\compile-bz2\command" "" '"$INSTDIR\makensisw.exe" /CD /X"SetCompressor bzip2" "%1"' WriteRegStr HKCR "NSISFile\shell\compile-bz2\command" "" '"$INSTDIR\makensisw.exe" /X"SetCompressor bzip2" "%1"'
SectionEnd SectionEnd
Section "Start Menu + Desktop Shortcuts" SecIcons Section "Start Menu + Desktop Shortcuts" SecIcons

View file

@ -69,7 +69,7 @@ static void sigint(int sig)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
CEXEBuild build; CEXEBuild build;
int do_cd=0; int do_cd=1;
int outputtried=0; int outputtried=0;
int argpos=1; int argpos=1;
int nousage=0; int nousage=0;
@ -163,7 +163,7 @@ int main(int argc, char **argv)
outputtried=1; outputtried=1;
} }
} }
else if (!stricmp(argv[argpos],"/CD")) do_cd=1; else if (!stricmp(argv[argpos],"/NOCD")) do_cd=0;
else if (argv[argpos][0] == '/' && (argv[argpos][1] == 'V' || argv[argpos][1] == 'v') && else if (argv[argpos][0] == '/' && (argv[argpos][1] == 'V' || argv[argpos][1] == 'v') &&
argv[argpos][2] >= '0' && argv[argpos][2] <= '4' && !argv[argpos][3]) argv[argpos][2] >= '0' && argv[argpos][2] <= '4' && !argv[argpos][3])
{ {
@ -316,7 +316,7 @@ int main(int argc, char **argv)
{ {
if (build.display_errors) if (build.display_errors)
{ {
fprintf(g_output,"Error changing directory to \"%s\" (/CD specified)\n",dirbuf); fprintf(g_output,"Error changing directory to \"%s\"\n",dirbuf);
fflush(g_output); fflush(g_output);
} }
return 1; return 1;
@ -371,7 +371,7 @@ int main(int argc, char **argv)
" /Ofile specifies a text file to log compiler output (default is stdout)\n" " /Ofile specifies a text file to log compiler output (default is stdout)\n"
" /PAUSE pauses after execution\n" " /PAUSE pauses after execution\n"
" /NOCONFIG disables inclusion of <path to makensis.exe>\\nsisconf.nsh\n" " /NOCONFIG disables inclusion of <path to makensis.exe>\\nsisconf.nsh\n"
" /CD makes makensis change the current directory to that of the .nsi file\n" " /NOCD disabled the current directory change to that of the .nsi file\n"
" /Ddefine[=value] defines the symbol \"define\" for the script [to value]\n" " /Ddefine[=value] defines the symbol \"define\" for the script [to value]\n"
" /Xscriptcmd executes scriptcmd in script (i.e. \"/XOutFile poop.exe\")\n" " /Xscriptcmd executes scriptcmd in script (i.e. \"/XOutFile poop.exe\")\n"
" for script file name, you can use - to read from the standard input\n"); " for script file name, you can use - to read from the standard input\n");