From 3d7194ee59e0178902daa800ca5bbc7ebb3fcc29 Mon Sep 17 00:00:00 2001 From: pabs3 Date: Fri, 2 Mar 2007 04:35:35 +0000 Subject: [PATCH] fixed bug #1661503: inconsistency between Win32/Linux makensis command line options git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4961 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/Makensisw/utils.cpp | 2 +- Source/Platform.h | 2 ++ Source/makenssi.cpp | 28 +++++++++------------------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/Contrib/Makensisw/utils.cpp b/Contrib/Makensisw/utils.cpp index 4c8a0581..7505f31a 100644 --- a/Contrib/Makensisw/utils.cpp +++ b/Contrib/Makensisw/utils.cpp @@ -280,7 +280,7 @@ void CompileNSISScript() { } s = (char *)GlobalAlloc(GPTR, lstrlen(g_sdata.script)+lstrlen(symbols)+lstrlen(compressor)+sizeof(EXENAME)+sizeof(" /NOTIFYHWND ")+20); - wsprintf(s,"%s %s%s /NOTIFYHWND %d %s",EXENAME,compressor,symbols,g_sdata.hwnd,g_sdata.script); + wsprintf(s,"%s %s%s /NOTIFYHWND %d -- %s",EXENAME,compressor,symbols,g_sdata.hwnd,g_sdata.script); GlobalFree(symbols); if (g_sdata.script_alloced) GlobalFree(g_sdata.script); g_sdata.script_alloced = true; diff --git a/Source/Platform.h b/Source/Platform.h index 665c2e4d..9eca9d06 100644 --- a/Source/Platform.h +++ b/Source/Platform.h @@ -116,11 +116,13 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG; # define PLATFORM_PATH_SEPARATOR_C '\\' # define OPT_STR "/" # define OPT_C '/' +# define IS_OPT(a) (a[0]==OPT_C||a[0]=='-') #else # define PLATFORM_PATH_SEPARATOR_STR "/" # define PLATFORM_PATH_SEPARATOR_C '/' # define OPT_STR "-" # define OPT_C '-' +# define IS_OPT(a) (a[0]==OPT_C) #endif // attributes diff --git a/Source/makenssi.cpp b/Source/makenssi.cpp index ac7866de..7feaacb7 100644 --- a/Source/makenssi.cpp +++ b/Source/makenssi.cpp @@ -140,7 +140,11 @@ static void print_usage() " " OPT_STR "Ddefine[=value] defines the symbol \"define\" for the script [to value]\n" " " OPT_STR "Xscriptcmd executes scriptcmd in script (i.e. \"" OPT_STR "XOutFile poop.exe\")\n" " parameters are processed by order (" OPT_STR "Ddef ins.nsi != ins.nsi " OPT_STR "Ddef)\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" +#ifdef _WIN32 + " you can also use - as an option character: -PAUSE as well as /PAUSE\n" +#endif + " you can use a double-dash to end options processing: makensis -- -ins.nsi\n"); fflush(g_output); } @@ -251,9 +255,7 @@ int main(int argc, char **argv) FILE *fp; int tmpargpos=1; int no_logo=0; -#ifndef _WIN32 int in_files=0; -#endif try { @@ -266,13 +268,13 @@ int main(int argc, char **argv) return 1; } - if (argc > 1 && !stricmp(argv[1], OPT_STR "VERSION")) + if (argc > 1 && IS_OPT(argv[1]) && !stricmp(&argv[1][1],"VERSION")) { fprintf(g_output,NSIS_VERSION); fflush(g_output); return 0; } - if (argc > 1 && argv[1][0]==OPT_C && (argv[1][1]=='v' || argv[1][1]=='V')) + if (argc > 1 && IS_OPT(argv[1]) && (argv[1][1]=='v' || argv[1][1]=='V')) { tmpargpos++; if (argv[1][2] <= '2' && argv[1][2] >= '0') @@ -283,7 +285,7 @@ int main(int argc, char **argv) if (!no_logo) { - if (argc > tmpargpos && argv[tmpargpos][0]==OPT_C && (argv[tmpargpos][1]=='o' || argv[tmpargpos][1]=='O') && argv[tmpargpos][2]) + if (argc > tmpargpos && IS_OPT(argv[tmpargpos]) && (argv[tmpargpos][1]=='o' || argv[tmpargpos][1]=='O') && argv[tmpargpos][2]) { g_output=fopen(argv[tmpargpos]+2,"w"); if (!g_output) @@ -301,13 +303,9 @@ int main(int argc, char **argv) if (!g_output) g_output=stdout; while (argpos < argc) { -#ifndef _WIN32 if (!strcmp(argv[argpos], "--")) in_files=1; - else if (argv[argpos][0] == OPT_C && strcmp(argv[argpos], "-") && !in_files) -#else - if (argv[argpos][0] == OPT_C && strcmp(argv[argpos], "-")) -#endif + else if (IS_OPT(argv[argpos]) && strcmp(argv[argpos], "-") && !in_files) { if ((argv[argpos][1]=='D' || argv[argpos][1]=='d') && argv[argpos][2]) { @@ -427,11 +425,7 @@ int main(int argc, char **argv) else { files_processed++; -#ifndef _WIN32 if (!strcmp(argv[argpos],"-") && !in_files) -#else - if (!strcmp(argv[argpos],"-")) -#endif g_dopause=0; if (!g_noconfig) { @@ -466,11 +460,7 @@ int main(int argc, char **argv) { char sfile[1024]; -#ifndef _WIN32 if (!strcmp(argv[argpos],"-") && !in_files) -#else - if (!strcmp(argv[argpos],"-")) -#endif { fp=stdin; strcpy(sfile,"stdin");