From ebd110bc6a1993a13e55f63947643619141addfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Gouget?= Date: Thu, 15 Aug 2002 23:21:03 +0000 Subject: [PATCH] Fix command-line parsing for Winelib applications. --- tools/winebuild/spec32.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 70527425b60..d008f08530d 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -629,8 +629,18 @@ void BuildSpec32File( FILE *outfile ) " extern char **__wine_main_argv;\n" " STARTUPINFOA info;\n" " char *cmdline = GetCommandLineA();\n" - " while (*cmdline && *cmdline != ' ') cmdline++;\n" - " if (*cmdline) cmdline++;\n" + " int bcount=0, in_quotes=0;\n" + " while (*cmdline) {\n" + " if ((*cmdline=='\\t' || *cmdline==' ') && !in_quotes) break;\n" + " else if (*cmdline=='\\\\') bcount++;\n" + " else if (*cmdline=='\\\"') {\n" + " if ((bcount & 1)==0) in_quotes=!in_quotes;\n" + " bcount=0;\n" + " }\n" + " else bcount=0;\n" + " cmdline++;\n" + " }\n" + " while (*cmdline=='\\t' || *cmdline==' ') cmdline++;\n" " GetStartupInfoA( &info );\n" " if (!(info.dwFlags & 1)) info.wShowWindow = 1;\n" " _ARGC = __wine_main_argc;\n" @@ -666,8 +676,18 @@ void BuildSpec32File( FILE *outfile ) " extern WCHAR **__wine_main_wargv;\n" " STARTUPINFOA info;\n" " char *cmdline = GetCommandLineA();\n" - " while (*cmdline && *cmdline != ' ') cmdline++;\n" - " if (*cmdline) cmdline++;\n" + " int bcount=0, in_quotes=0;\n" + " while (*cmdline) {\n" + " if ((*cmdline=='\\t' || *cmdline==' ') && !in_quotes) break;\n" + " else if (*cmdline=='\\\\') bcount++;\n" + " else if (*cmdline=='\\\"') {\n" + " if ((bcount & 1)==0) in_quotes=!in_quotes;\n" + " bcount=0;\n" + " }\n" + " else bcount=0;\n" + " cmdline++;\n" + " }\n" + " while (*cmdline=='\\t' || *cmdline==' ') cmdline++;\n" " GetStartupInfoA( &info );\n" " if (!(info.dwFlags & 1)) info.wShowWindow = 1;\n" " _ARGC = __wine_main_argc;\n"