From d4c1149b1456547876dff831e446a7837505d809 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Fri, 6 Jun 2003 21:05:58 +0000 Subject: [PATCH] - Do not interpret spaces within a quoted string as break marker. svn path=/trunk/; revision=4857 --- reactos/lib/msvcrt/misc/getargs.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/reactos/lib/msvcrt/misc/getargs.c b/reactos/lib/msvcrt/misc/getargs.c index 9ce3a2ca0e6..f3cd35da956 100644 --- a/reactos/lib/msvcrt/misc/getargs.c +++ b/reactos/lib/msvcrt/misc/getargs.c @@ -89,15 +89,33 @@ int expand(char* name, int flag) int __getmainargs(int* argc, char*** argv, char*** env, int flag) { - int i, afterlastspace; + int i, afterlastspace, ignorespace, len; /* missing threading init */ i = 0; afterlastspace = 0; + ignorespace = 0; + len = strlen(_acmdln); while (_acmdln[i]) { - if (_acmdln[i] == ' ') { + if (_acmdln[i] == '"') { + if (_acmdln[i + 1] == '"') { + memmove(_acmdln + i, _acmdln + i + 1, len - i); + len--; + } else { + if(ignorespace) { + ignorespace = 0; + } else { + ignorespace = 1; + } + memmove(_acmdln + i, _acmdln + i + 1, len - i); + len--; + continue; + } + } + + if (_acmdln[i] == ' ' && !ignorespace) { expand(strndup(_acmdln + afterlastspace, i - afterlastspace), flag); i++; while (_acmdln[i]==' ')