From: Piotr Caban piotr@codeweavers.com
--- programs/xcopy/tests/xcopy.c | 6 ++++++ programs/xcopy/xcopy.c | 22 ++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/programs/xcopy/tests/xcopy.c b/programs/xcopy/tests/xcopy.c index fa3d5328a1b..2fe39d789a0 100644 --- a/programs/xcopy/tests/xcopy.c +++ b/programs/xcopy/tests/xcopy.c @@ -106,6 +106,12 @@ static void test_parms_syntax(void) ok(GetFileAttributesA("xcopytest2") != INVALID_FILE_ATTRIBUTES, "xcopy failed to copy empty directory\n"); RemoveDirectoryA("xcopytest2"); + + rc = runcmd("xcopy xcopytest xcopytest2\/D/S/E"); + ok(rc == 0, "xcopy test failed rc=%lu\n", rc); + ok(GetFileAttributesA("xcopytest2") != INVALID_FILE_ATTRIBUTES, + "xcopy failed to copy empty directory\n"); + RemoveDirectoryA("xcopytest2"); }
static void test_keep_attributes(void) diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c index 1d003007c0b..67d95b1f130 100644 --- a/programs/xcopy/xcopy.c +++ b/programs/xcopy/xcopy.c @@ -664,20 +664,16 @@ static inline BOOL is_digit(WCHAR c) Example: 'XCOPY "c:\DIR A" "c:DIR B"' is OK. */ static int find_end_of_word(const WCHAR *word, WCHAR **end) { - BOOL in_quotes = FALSE; const WCHAR *ptr = word; - for (;;) { - for (; *ptr != '\0' && *ptr != '"' && - (in_quotes || !is_whitespace(*ptr)); ptr++); + + if (*ptr == '/') ptr++; + while (*ptr && !is_whitespace(*ptr) && *ptr != '/') { if (*ptr == '"') { - in_quotes = !in_quotes; - ptr++; + while (*ptr && *ptr != '"') ptr++; + /* Odd number of double quotes is illegal for XCOPY */ + if (!*ptr) return RC_INITERROR; } - /* Odd number of double quotes is illegal for XCOPY */ - if (in_quotes && *ptr == '\0') - return RC_INITERROR; - if (*ptr == '\0' || (!in_quotes && is_whitespace(*ptr))) - break; + ptr++; } *end = (WCHAR*)ptr; return RC_OK; @@ -702,7 +698,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, WCHAR *supplieddestination, DWORD *pflags) { DWORD flags = *pflags; - WCHAR *cmdline, *word, *end, *next; + WCHAR *cmdline, *word, *end, *next, wch; int rc = RC_INITERROR;
cmdline = _wcsdup(GetCommandLineW()); @@ -721,6 +717,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, goto out;
next = skip_whitespace(end); + wch = *next; first = word[0]; *end = '\0'; strip_quotes(word, &end); @@ -870,6 +867,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, } } word = next; + *next = wch; }
/* Default the destination if not supplied */