From: Piotr Caban piotr@codeweavers.com
--- programs/xcopy/tests/xcopy.c | 5 +++++ programs/xcopy/xcopy.c | 19 ++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/programs/xcopy/tests/xcopy.c b/programs/xcopy/tests/xcopy.c index fa3d5328a1b..2745ead97a5 100644 --- a/programs/xcopy/tests/xcopy.c +++ b/programs/xcopy/tests/xcopy.c @@ -106,6 +106,11 @@ 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 == 4, "xcopy /D/S/"E" test failed rc=%lu\n", rc); + ok(GetFileAttributesA("xcopytest2") == INVALID_FILE_ATTRIBUTES, + "xcopy copied empty directory incorrectly\n"); }
static void test_keep_attributes(void) diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c index 202ce903407..072d44728a3 100644 --- a/programs/xcopy/xcopy.c +++ b/programs/xcopy/xcopy.c @@ -684,18 +684,17 @@ static int find_end_of_word(const WCHAR *word, WCHAR **end) }
/* Remove all double quotes from a word */ -static void strip_quotes(WCHAR *word, WCHAR **end) +static void strip_quotes(WCHAR *word) { - WCHAR *rp, *wp; - for (rp = word, wp = word; *rp != '\0'; rp++) { - if (*rp == '"') + WCHAR *wp; + for (wp = word; *word != '\0'; word++) { + if (*word == '"') continue; - if (wp < rp) - *wp = *rp; + if (wp < word) + *wp = *word; wp++; } *wp = '\0'; - *end = wp; }
static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, @@ -716,18 +715,16 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource,
while (*word) { - WCHAR first; if ((rc = find_end_of_word(word, &end)) != RC_OK) exit(rc);
next = skip_whitespace(end); - first = word[0]; *end = '\0'; - strip_quotes(word, &end); WINE_TRACE("Processing Arg: '%s'\n", wine_dbgstr_w(word));
/* First non-switch parameter is source, second is destination */ - if (first != '/') { + if (word[0] != '/') { + strip_quotes(word); if (suppliedsource[0] == 0x00) { lstrcpyW(suppliedsource, word); } else if (supplieddestination[0] == 0x00) {