[CMD]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 14 Apr 2012 21:35:58 +0000 (21:35 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 14 Apr 2012 21:35:58 +0000 (21:35 +0000)
Handle the + character only optionally as a token seperator, so that other commands like rename are not affected.

svn path=/trunk/; revision=56349

16 files changed:
reactos/base/shell/cmd/attrib.c
reactos/base/shell/cmd/chcp.c
reactos/base/shell/cmd/choice.c
reactos/base/shell/cmd/cmd.h
reactos/base/shell/cmd/copy.c
reactos/base/shell/cmd/date.c
reactos/base/shell/cmd/del.c
reactos/base/shell/cmd/free.c
reactos/base/shell/cmd/internal.c
reactos/base/shell/cmd/misc.c
reactos/base/shell/cmd/mklink.c
reactos/base/shell/cmd/ren.c
reactos/base/shell/cmd/replace.c
reactos/base/shell/cmd/time.c
reactos/base/shell/cmd/timer.c
reactos/base/shell/cmd/type.c

index 2778ba5..8b619d0 100644 (file)
@@ -213,7 +213,7 @@ INT CommandAttrib (LPTSTR param)
   nErrorLevel = 0;
 
        /* build parameter array */
-       arg = split (param, &argc, FALSE);
+       arg = split (param, &argc, FALSE, FALSE);
 
        /* check for options */
        for (i = 0; i < argc; i++)
index b834f23..92ddb8e 100644 (file)
@@ -33,7 +33,7 @@ INT CommandChcp (LPTSTR param)
        nErrorLevel = 0;
 
        /* get parameters */
-       arg = split (param, &args, FALSE);
+       arg = split (param, &args, FALSE, FALSE);
 
        if (args == 0)
        {
index 6b2c490..3503e7d 100644 (file)
@@ -150,7 +150,7 @@ CommandChoice (LPTSTR param)
        }
 
        /* build parameter array */
-       arg = split (param, &argc, FALSE);
+       arg = split (param, &argc, FALSE, FALSE);
 
        /* evaluate arguments */
        if (argc > 0)
index 9344ac9..25df588 100644 (file)
@@ -332,7 +332,7 @@ BOOL SetRootPath(TCHAR *oldpath,TCHAR *InPath);
 TCHAR  cgetchar (VOID);
 BOOL   CheckCtrlBreak (INT);
 BOOL add_entry (LPINT ac, LPTSTR **arg, LPCTSTR entry);
-LPTSTR *split (LPTSTR, LPINT, BOOL);
+LPTSTR *split (LPTSTR, LPINT, BOOL, BOOL);
 LPTSTR *splitspace (LPTSTR, LPINT);
 VOID   freep (LPTSTR *);
 LPTSTR _stpcpy (LPTSTR, LPCTSTR);
index 6f975f1..9037f64 100644 (file)
@@ -438,7 +438,7 @@ INT cmd_copy(LPTSTR param)
 
 
     /* Split the user input into array */
-    arg = split(param, &argc, FALSE);
+    arg = split(param, &argc, FALSE, TRUE);
     nFiles = argc;
 
     /* Read switches and count files */
index 8c09387..05548c4 100644 (file)
@@ -193,7 +193,7 @@ INT cmd_date (LPTSTR param)
   nErrorLevel = 0;
 
        /* build parameter array */
-       arg = split (param, &argc, FALSE);
+       arg = split (param, &argc, FALSE, FALSE);
 
        /* check for options */
        for (i = 0; i < argc; i++)
index bd26200..e19cf77 100644 (file)
@@ -275,7 +275,7 @@ DeleteFiles(LPTSTR FileName, DWORD* dwFlags, DWORD dwAttrFlags)
                 }
                 while (FindNextFile (hFile, &f));
                                FindClose (hFile);
-        } 
+        }
                else error_sfile_not_found(szFullPath);
         return dwFiles;
 }
@@ -385,7 +385,7 @@ INT CommandDelete (LPTSTR param)
 
        nErrorLevel = 0;
 
-       arg = split (param, &args, FALSE);
+       arg = split (param, &args, FALSE, FALSE);
 
        if (args == 0)
        {
index b266ee4..9bf8a43 100644 (file)
@@ -106,7 +106,7 @@ INT CommandFree (LPTSTR param)
        else
                szParam = param;
 
-       arg = split (szParam, &argc, FALSE);
+       arg = split (szParam, &argc, FALSE, FALSE);
 
        for (i = 0; i < argc; i++)
                PrintDiskInfo (arg[i]);
index fcfcde1..73e91d4 100644 (file)
@@ -321,7 +321,7 @@ INT cmd_mkdir (LPTSTR param)
                return 0;
        }
 
-       p = split (param, &argc, FALSE);
+       p = split (param, &argc, FALSE, FALSE);
        if (argc == 0)
        {
                ConErrResPuts(STRING_ERROR_REQ_PARAM_MISSING);
@@ -411,7 +411,7 @@ INT cmd_rmdir (LPTSTR param)
                return 0;
        }
 
-       arg = split (param, &args, FALSE);
+       arg = split (param, &args, FALSE, FALSE);
        dirCount = 0;
 
        /* check for options anywhere in command line */
index 4b28d7a..abff748 100644 (file)
@@ -275,7 +275,7 @@ static BOOL expand (LPINT ac, LPTSTR **arg, LPCTSTR pattern)
  *         are spaces and slashes ('/').
  */
 
-LPTSTR *split (LPTSTR s, LPINT args, BOOL expand_wildcards)
+LPTSTR *split (LPTSTR s, LPINT args, BOOL expand_wildcards, BOOL handle_plus)
 {
        LPTSTR *arg;
        LPTSTR start;
@@ -315,7 +315,7 @@ LPTSTR *split (LPTSTR s, LPINT args, BOOL expand_wildcards)
                 /* check for separators */
                 if (_istspace(*s) ||
                     (*s == _T('/')) ||
-                    (*s == _T('+')))
+                    (handle_plus && (*s == _T('+'))))
                 {
                     /* Make length at least one character */
                     if (s == start) s++;
index 6cffe78..f2752ad 100644 (file)
@@ -132,7 +132,7 @@ cmd_mklink(LPTSTR param)
                return 0;
        }
 
-       arg = split(param, &argc, FALSE);
+       arg = split(param, &argc, FALSE, FALSE);
        for (i = 0; i < argc; i++)
        {
                if (arg[i][0] == _T('/'))
index 7281760..0042423 100644 (file)
@@ -3,7 +3,7 @@
  *
  *
  *  History:
- *    
+ *
  *
  *    27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
  *        added config.h include
  *    30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
  *        Remove all hardcode string to En.rc
  *       25-Nov-2008 (Victor Martinez) <vicmarcal@hotmail.com> Patch dedicated to Myrjala because her comprenhension and love :D
- *               Fixing following Bugs: 
+ *               Fixing following Bugs:
  *                -Wrong behavior with wildcards when Source and Destiny are Paths(FIXED).
  *                        -Wrong general behavior (MSDN:"Rename cant move files between subdirectories")(FIXED)
  *                        -Wrong behavior when renaming without path in destiny:(i.e) "ren C:\text\as.txt list.txt" it moves as.txt and then rename it(FIXED)
  *                             (MSDN: If there is a Path in Source and no Path in Destiny, then Destiny Path is Source Path,because never Ren has to be used to move.)
  *                        -Implemented checkings if SourcePath and DestinyPath are differents.
- *          
+ *
  */
 
 #include <precomp.h>
@@ -59,13 +59,13 @@ INT cmd_rename (LPTSTR param)
   DWORD dwFiles = 0; /* number of renamedd files */
   INT i;
 
+
   LPTSTR srcPattern = NULL; /* Source Argument*/
   TCHAR srcPath[MAX_PATH]; /*Source Path Directories*/
   LPTSTR srcFILE = NULL;  /*Contains the files name(s)*/
-  TCHAR srcFinal[MAX_PATH]; 
-  
+  TCHAR srcFinal[MAX_PATH];
+
+
   LPTSTR dstPattern = NULL; /*Destiny Argument*/
   TCHAR dstPath[MAX_PATH]; /*Source Path Directories*/
   LPTSTR dstFILE = NULL; /*Contains the files name(s)*/
@@ -75,12 +75,12 @@ INT cmd_rename (LPTSTR param)
 
   BOOL bDstWildcard = FALSE;
   BOOL bPath = FALSE;
-  
-  
-  
-  
+
+
+
+
+
+
   LPTSTR p,q,r;
 
   HANDLE hFile;
@@ -88,8 +88,8 @@ INT cmd_rename (LPTSTR param)
  /*If the PARAM=/? then show the help*/
   if (!_tcsncmp(param, _T("/?"), 2))
   {
-         
-       
+
+
     ConOutResPaging(TRUE,STRING_REN_HELP1);
     return 0;
   }
@@ -97,8 +97,8 @@ INT cmd_rename (LPTSTR param)
   nErrorLevel = 0;
 
   /* Split the argument list.Args will be saved in arg vector*/
-  arg = split(param, &args, FALSE);
-       
+  arg = split(param, &args, FALSE, FALSE);
+
   if (args < 2)
     {
       if (!(dwFlags & REN_ERROR))
@@ -124,7 +124,7 @@ INT cmd_rename (LPTSTR param)
                                                 case _T('N'):
                                                dwFlags |= REN_NOTHING;
                                                 break;
-                       
+
                                                case _T('P'):
                                                dwFlags |= REN_PROMPT;
                                                break;
@@ -158,8 +158,8 @@ INT cmd_rename (LPTSTR param)
                freep(arg);
                return 1;
     }
-  
-  
+
+
   /* Get destination pattern and source pattern*/
   for (i = 0; i < args; i++)
     {
@@ -167,16 +167,16 @@ INT cmd_rename (LPTSTR param)
                continue;
       dstPattern = arg[i]; //we save the Last argument as dstPattern
          srcPattern = arg[i-1];
-         
+
     }
-  
-  
+
+
+
+
 
   if (_tcschr(srcPattern, _T('\\')))  //Checking if the Source (srcPattern) is a Path to the file
-       {       
-               
+       {
+
                bPath= TRUE;
 
         //Splitting srcPath and srcFile.
@@ -190,11 +190,11 @@ INT cmd_rename (LPTSTR param)
                        if(!_tcschr(srcFILE, _T('\\'))) break;
                        }
                _tcsncpy(srcPath,srcPattern,_tcslen(srcPattern)-_tcslen(srcFILE));
-               
-       
-                       
+
+
+
                if(_tcschr(dstPattern, _T('\\'))) //Checking if the Destiny (dstPattern)is also a Path.And splitting dstPattern in dstPath and srcPath.
-                       {  
+                       {
                                dstFILE = _tcschr(dstPattern, _T('\\'));
                                nSlash=0;
                                while(_tcschr(dstFILE, _T('\\')))
@@ -204,53 +204,53 @@ INT cmd_rename (LPTSTR param)
                                                if(!_tcschr(dstFILE, _T('\\'))) break;
                                                }
                                _tcsncpy(dstPath,dstPattern,_tcslen(dstPattern)-_tcslen(dstFILE));
-                               
+
                                if((_tcslen(dstPath)!=_tcslen(srcPath))||(_tcsncmp(srcPath,dstPath,_tcslen(srcPath))!=0)) //If it has a Path,then MUST be equal than srcPath
                                                {
                                                error_syntax(dstPath);
                                                freep(arg);
                                                return 1;
                                                }
-                       }else   { //If Destiny hasnt a Path,then (MSDN says) srcPath is its Path. 
-                                       
+                       }else   { //If Destiny hasnt a Path,then (MSDN says) srcPath is its Path.
+
                                        _tcscpy(dstPath,srcPath);
-                                       
+
                                        dstFILE=dstPattern;
-                                       
+
                                        }
 
-               
-       
+
+
        }
-  
+
   if (!_tcschr(srcPattern, _T('\\'))) //If srcPattern isnt a Path but a  name:
-  { 
+  {
        srcFILE=srcPattern;
        if(_tcschr(dstPattern, _T('\\')))
-                               {               
+                               {
                                                error_syntax(dstPattern);
-                                               
+
                                                freep(arg);
                                                return 1;
                                }else dstFILE=dstPattern;
   }
+
  //Checking Wildcards.
   if (_tcschr(dstFILE, _T('*')) || _tcschr(dstFILE, _T('?')))
                bDstWildcard = TRUE;
-  
-  
-  
+
+
+
   TRACE("\n\nSourcePattern: %s SourcePath: %s SourceFile: %s", debugstr_aw(srcPattern),debugstr_aw(srcPath),debugstr_aw(srcFILE));
   TRACE("\n\nDestinationPattern: %s Destination Path:%s Destination File: %s\n", debugstr_aw(dstPattern),debugstr_aw(dstPath),debugstr_aw(dstFILE));
+
       hFile = FindFirstFile(srcPattern, &f);
-         
+
       if (hFile == INVALID_HANDLE_VALUE)
                {
                 if (!(dwFlags & REN_ERROR))
                                error_file_not_found();
-                               
+
                }
       do
                {
@@ -271,7 +271,7 @@ INT cmd_rename (LPTSTR param)
                        continue;
 
                 TRACE("Found source name: %s\n", debugstr_aw(f.cFileName));
-         /* So here we have splitted the dstFILE and we have find a f.cFileName(thanks to srcPattern) 
+         /* So here we have splitted the dstFILE and we have find a f.cFileName(thanks to srcPattern)
           * Now we have to use the mask (dstFILE) (which can have Wildcards) with f.cFileName to find destination file name(dstLast) */
                 p = f.cFileName;
                 q = dstFILE;
@@ -310,37 +310,37 @@ INT cmd_rename (LPTSTR param)
                *r = 0;
                //Well we have splitted the Paths,so now we have to paste them again(if needed),thanks bPath.
                if(     bPath == TRUE)
-                       {       
-                               
+                       {
+
                                _tcscpy(srcFinal,srcPath);
-                               
+
                                _tcscat(srcFinal,f.cFileName);
-                                
+
                                _tcscpy(dstFinal,dstPath);
                                _tcscat(dstFinal,dstLast);
-                                
-                                                               
+
+
                }else{
                                _tcscpy(srcFinal,f.cFileName);
                                _tcscpy(dstFinal,dstLast);
 
                                }
-               
+
 
 
                TRACE("DestinationPath: %s\n", debugstr_aw(dstFinal));
-               
-               
+
+
                if (!(dwFlags & REN_QUIET) && !(dwFlags & REN_TOTAL))
-         
+
                         ConOutPrintf(_T("%s -> %s\n"),srcFinal , dstFinal);
 
          /* Rename the file */
                 if (!(dwFlags & REN_NOTHING))
-                {       
-                               
-                               
-             
+                {
+
+
+
                                if (MoveFile(srcFinal, dstFinal))
                        {
                        dwFiles++;
@@ -354,12 +354,12 @@ INT cmd_rename (LPTSTR param)
                                }
                 }
          }
-          
+
       while (FindNextFile(hFile, &f));
 //Closing and Printing errors.
-       
+
       FindClose(hFile);
-   
+
 
   if (!(dwFlags & REN_QUIET))
   {
@@ -368,9 +368,9 @@ INT cmd_rename (LPTSTR param)
     else
       ConOutResPrintf(STRING_REN_HELP3, dwFiles);
   }
+
   freep(arg);
-  
+
   return 0;
 }
 
index 29495cc..01bc2ac 100644 (file)
@@ -376,7 +376,7 @@ INT cmd_replace (LPTSTR param)
        }
 
        /* Divide the argument in to an array of c-strings */
-       arg = split (param, &argc, FALSE);
+       arg = split (param, &argc, FALSE, FALSE);
        nFiles = argc;
 
        /* Read options */
index 0e608d5..78ff91d 100644 (file)
@@ -145,7 +145,7 @@ INT cmd_time (LPTSTR param)
   nErrorLevel = 0;
 
        /* build parameter array */
-       arg = split (param, &argc, FALSE);
+       arg = split (param, &argc, FALSE, FALSE);
 
        /* check for options */
        for (i = 0; i < argc; i++)
index f053777..588e429 100644 (file)
@@ -100,7 +100,7 @@ INT CommandTimer (LPTSTR param)
 
        nErrorLevel = 0;
 
-       p = split (param, &argc, FALSE);
+       p = split (param, &argc, FALSE, FALSE);
 
        //read options
        for (i = 0; i < argc; i++)
index 86f1f41..60a1720 100644 (file)
@@ -56,7 +56,7 @@ INT cmd_type (LPTSTR param)
                return 1;
        }
 
-       argv = split (param, &argc, TRUE);
+       argv = split (param, &argc, TRUE, FALSE);
 
        for(i = 0; i < argc; i++)
        {