From b8c9de400fe263c9aec91565d08f2f5c5baa280e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Tue, 11 May 2004 20:44:30 +0000 Subject: [PATCH] Fix command line handling (mostly double-quoting stuff) svn path=/trunk/; revision=9355 --- reactos/lib/kernel32/process/create.c | 5 +++-- reactos/lib/msvcrt/misc/dllmain.c | 10 +++++----- reactos/subsys/system/cmd/cmd.c | 25 ++++++++++++------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/reactos/lib/kernel32/process/create.c b/reactos/lib/kernel32/process/create.c index 05ebbd9d6b7..ff8158564a5 100644 --- a/reactos/lib/kernel32/process/create.c +++ b/reactos/lib/kernel32/process/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.82 2004/05/01 18:09:53 tamlin Exp $ +/* $Id: create.c,v 1.83 2004/05/11 20:44:29 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -871,6 +871,7 @@ CreateProcessW { return FALSE; } + DPRINT("TidyCmdLine '%S'\n", TidyCmdLine); if (lpApplicationName != NULL && lpApplicationName[0] != 0) { @@ -977,7 +978,7 @@ CreateProcessW * Process the application name and command line */ RtlInitUnicodeString(&ImagePathName_U, ImagePathName); - RtlInitUnicodeString(&CommandLine_U, lpCommandLine); + RtlInitUnicodeString(&CommandLine_U, TidyCmdLine); DPRINT("ImagePathName_U %S\n", ImagePathName_U.Buffer); DPRINT("CommandLine_U %S\n", CommandLine_U.Buffer); diff --git a/reactos/lib/msvcrt/misc/dllmain.c b/reactos/lib/msvcrt/misc/dllmain.c index 630fbed904d..e9c159890f8 100644 --- a/reactos/lib/msvcrt/misc/dllmain.c +++ b/reactos/lib/msvcrt/misc/dllmain.c @@ -1,4 +1,4 @@ -/* $Id: dllmain.c,v 1.20 2004/01/31 13:29:19 navaraf Exp $ +/* $Id: dllmain.c,v 1.21 2004/05/11 20:44:30 gvg Exp $ * * dllmain.c * @@ -14,9 +14,9 @@ * DISCLAMED. This includes but is not limited to warrenties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.20 $ - * $Author: navaraf $ - * $Date: 2004/01/31 13:29:19 $ + * $Revision: 1.21 $ + * $Author: gvg $ + * $Date: 2004/05/11 20:44:30 $ * */ @@ -90,7 +90,7 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved) if (!CreateThreadData()) return FALSE; - _acmdln = (char *)GetCommandLineA(); + _acmdln = strdup(GetCommandLineA()); /* FIXME: This crashes all applications */ if (BlockEnvToEnviron() < 0) diff --git a/reactos/subsys/system/cmd/cmd.c b/reactos/subsys/system/cmd/cmd.c index 2b04cef9ccc..78131f812fc 100644 --- a/reactos/subsys/system/cmd/cmd.c +++ b/reactos/subsys/system/cmd/cmd.c @@ -1,4 +1,4 @@ -/* $Id: cmd.c,v 1.12 2004/04/30 16:52:41 navaraf Exp $ +/* $Id: cmd.c,v 1.13 2004/05/11 20:44:30 gvg Exp $ * * CMD.C - command-line interface. * @@ -296,7 +296,7 @@ static BOOL IsConsoleProcess(HANDLE Process) */ static VOID -Execute (LPTSTR first, LPTSTR rest) +Execute (LPTSTR full, LPTSTR first, LPTSTR rest) { TCHAR szFullName[MAX_PATH]; #ifndef __REACTOS__ @@ -352,17 +352,13 @@ Execute (LPTSTR first, LPTSTR rest) else { /* exec the program */ - TCHAR szFullCmdLine [CMDLINE_LENGTH]; PROCESS_INFORMATION prci; STARTUPINFO stui; #ifdef _DEBUG - DebugPrintf (_T("[EXEC: %s %s]\n"), szFullName, rest); + DebugPrintf (_T("[EXEC: %s %s]\n"), full, rest); #endif /* build command line for CreateProcess() */ - _tcscpy (szFullCmdLine, first); - _tcscat (szFullCmdLine, _T(" ")); - _tcscat (szFullCmdLine, rest); /* fill startup info */ memset (&stui, 0, sizeof (STARTUPINFO)); @@ -373,9 +369,9 @@ Execute (LPTSTR first, LPTSTR rest) // return console to standard mode SetConsoleMode (GetStdHandle(STD_INPUT_HANDLE), ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT ); - + if (CreateProcess (szFullName, - szFullCmdLine, + full, NULL, NULL, FALSE, @@ -433,7 +429,7 @@ DoCommand (LPTSTR line) TCHAR com[CMDLINE_LENGTH]; /* the first word in the command */ LPTSTR cp = com; LPTSTR cstart; - LPTSTR rest = line; /* pointer to the rest of the command line */ + LPTSTR rest; /* pointer to the rest of the command line */ INT cl; LPCOMMAND cmdptr; @@ -442,8 +438,9 @@ DoCommand (LPTSTR line) #endif /* DEBUG */ /* Skip over initial white space */ - while (_istspace (*rest)) - rest++; + while (_istspace (*line)) + line++; + rest = line; cstart = rest; @@ -458,6 +455,8 @@ DoCommand (LPTSTR line) while(*rest != _T('\0') && *rest != _T('"')) *cp++ = _totlower (*rest++); + if (*rest == _T('"')) + rest++; } else { @@ -486,7 +485,7 @@ DoCommand (LPTSTR line) /* If end of table execute ext cmd */ if (cmdptr->name == NULL) { - Execute (com, rest); + Execute (line, com, rest); break; }