cmd: fixing an issue with extra whitespaces after cd parameter

Nowres Rafid nowres.rafed at gmail.com
Thu Aug 11 08:51:38 CDT 2011


---
 programs/cmd/builtins.c              |    8 ++++++-
 programs/cmd/tests/test_builtins.cmd |   39 ++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 09c166f..1de1987 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2101,15 +2101,21 @@ void WCMD_setshow_default (WCHAR *command) {
     WCMD_output (cwd);
   }
   else {
+    pos = string;
     /* Remove any double quotes, which may be in the
        middle, eg. cd "C:\Program Files"\Microsoft is ok */
-    pos = string;
     while (*command) {
       if (*command != '"') *pos++ = *command;
       command++;
     }
     *pos = 0x00;
 
+    /* Remove any whitespace at the end of command
+    This was because "cd .. " wasn't working */
+    pos--;
+    while ( *pos == ' ' || *pos == '\t' )
+        *pos-- = 0x00;
+
     /* Search for appropriate directory */
     WINE_TRACE("Looking for directory '%s'\n", wine_dbgstr_w(string));
     hff = FindFirstFileW(string, &fd);
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index a83e568..b152787 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -36,6 +36,45 @@ echo :word
 echo word at space@
 echo word at space@@space@
 
+
+echo ------------ Testing 'cd' --------------
+mkdir test
+cd
+cd test
+cd
+cd ..
+cd
+cd test
+cd
+cd ..
+cd
+cd test
+cd
+cd ..
+cd test
+cd ..
+cd .
+cd .
+cd test >nul
+cd .. >nul
+cd testii
+mkdir test2
+cd test2
+mkdir test21
+cd test21
+cd ..\..
+cd test2
+mkdir test22
+cd test22
+cd ..\test21
+cd ..
+rd test21
+rd test22
+cd ..
+rd test
+rd test2
+
+
 echo ------------ Testing redirection operators --------------
 mkdir foobar & cd foobar
 echo ...stdout redirection
-- 
1.7.4.1


--=-r7qFC8rvFlRwUa/w8aBl--




More information about the wine-patches mailing list