[ros-diffs] [tkreuzer] 56349: [CMD] Handle the + character only optionally as a token seperator, so that other commands like rename are not affected.

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Sat Apr 14 21:35:59 UTC 2012


Author: tkreuzer
Date: Sat Apr 14 21:35:58 2012
New Revision: 56349

URL: http://svn.reactos.org/svn/reactos?rev=56349&view=rev
Log:
[CMD]
Handle the + character only optionally as a token seperator, so that other commands like rename are not affected.

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

Modified: trunk/reactos/base/shell/cmd/attrib.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/attrib.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/attrib.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/attrib.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -213,7 +213,7 @@
   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++)

Modified: trunk/reactos/base/shell/cmd/chcp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/chcp.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/chcp.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/chcp.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -33,7 +33,7 @@
 	nErrorLevel = 0;
 
 	/* get parameters */
-	arg = split (param, &args, FALSE);
+	arg = split (param, &args, FALSE, FALSE);
 
 	if (args == 0)
 	{

Modified: trunk/reactos/base/shell/cmd/choice.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/choice.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/choice.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/choice.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -150,7 +150,7 @@
 	}
 
 	/* build parameter array */
-	arg = split (param, &argc, FALSE);
+	arg = split (param, &argc, FALSE, FALSE);
 
 	/* evaluate arguments */
 	if (argc > 0)

Modified: trunk/reactos/base/shell/cmd/cmd.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.h?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/cmd.h [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/cmd.h [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -332,7 +332,7 @@
 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);

Modified: trunk/reactos/base/shell/cmd/copy.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/copy.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/copy.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/copy.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -438,7 +438,7 @@
 
 
     /* Split the user input into array */
-    arg = split(param, &argc, FALSE);
+    arg = split(param, &argc, FALSE, TRUE);
     nFiles = argc;
 
     /* Read switches and count files */

Modified: trunk/reactos/base/shell/cmd/date.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/date.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/date.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/date.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -193,7 +193,7 @@
   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++)

Modified: trunk/reactos/base/shell/cmd/del.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/del.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/del.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/del.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -275,7 +275,7 @@
                 }
                 while (FindNextFile (hFile, &f));
 				FindClose (hFile);
-        } 
+        }
 		else error_sfile_not_found(szFullPath);
         return dwFiles;
 }
@@ -385,7 +385,7 @@
 
 	nErrorLevel = 0;
 
-	arg = split (param, &args, FALSE);
+	arg = split (param, &args, FALSE, FALSE);
 
 	if (args == 0)
 	{

Modified: trunk/reactos/base/shell/cmd/free.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/free.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/free.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/free.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -106,7 +106,7 @@
 	else
 		szParam = param;
 
-	arg = split (szParam, &argc, FALSE);
+	arg = split (szParam, &argc, FALSE, FALSE);
 
 	for (i = 0; i < argc; i++)
 		PrintDiskInfo (arg[i]);

Modified: trunk/reactos/base/shell/cmd/internal.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/internal.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/internal.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/internal.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -321,7 +321,7 @@
 		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 @@
 		return 0;
 	}
 
-	arg = split (param, &args, FALSE);
+	arg = split (param, &args, FALSE, FALSE);
 	dirCount = 0;
 
 	/* check for options anywhere in command line */

Modified: trunk/reactos/base/shell/cmd/misc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/misc.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/misc.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/misc.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -275,7 +275,7 @@
  *         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 @@
                 /* check for separators */
                 if (_istspace(*s) ||
                     (*s == _T('/')) ||
-                    (*s == _T('+')))
+                    (handle_plus && (*s == _T('+'))))
                 {
                     /* Make length at least one character */
                     if (s == start) s++;

Modified: trunk/reactos/base/shell/cmd/mklink.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/mklink.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/mklink.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/mklink.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -132,7 +132,7 @@
 		return 0;
 	}
 
-	arg = split(param, &argc, FALSE);
+	arg = split(param, &argc, FALSE, FALSE);
 	for (i = 0; i < argc; i++)
 	{
 		if (arg[i][0] == _T('/'))

Modified: trunk/reactos/base/shell/cmd/ren.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/ren.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/ren.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/ren.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -3,7 +3,7 @@
  *
  *
  *  History:
- *    
+ *
  *
  *    27-Jul-1998 (John P Price <linux-guru at gcfl.net>)
  *        added config.h include
@@ -20,13 +20,13 @@
  *    30-Apr-2005 (Magnus Olsen) <magnus at greatlord.com>)
  *        Remove all hardcode string to En.rc
  *	  25-Nov-2008 (Victor Martinez) <vicmarcal at 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 @@
   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 @@
 
   BOOL bDstWildcard = FALSE;
   BOOL bPath = FALSE;
-  
- 
-  
- 
-  
-  
+
+
+
+
+
+
   LPTSTR p,q,r;
 
   HANDLE hFile;
@@ -88,8 +88,8 @@
  /*If the PARAM=/? then show the help*/
   if (!_tcsncmp(param, _T("/?"), 2))
   {
-	  
-	
+
+
     ConOutResPaging(TRUE,STRING_REN_HELP1);
     return 0;
   }
@@ -97,8 +97,8 @@
   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 @@
 						 case _T('N'):
 						dwFlags |= REN_NOTHING;
 						 break;
-			
+
 						case _T('P'):
 						dwFlags |= REN_PROMPT;
 						break;
@@ -158,8 +158,8 @@
 		freep(arg);
 		return 1;
     }
-  
-  
+
+
   /* Get destination pattern and source pattern*/
   for (i = 0; i < args; i++)
     {
@@ -167,16 +167,16 @@
 		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 @@
 			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 @@
 						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 @@
 			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 @@
 		*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 @@
 				}
 		 }
 	  }
-	   
+
       while (FindNextFile(hFile, &f));
 //Closing and Printing errors.
-	
+
       FindClose(hFile);
-   
+
 
   if (!(dwFlags & REN_QUIET))
   {
@@ -368,9 +368,9 @@
     else
       ConOutResPrintf(STRING_REN_HELP3, dwFiles);
   }
- 
+
   freep(arg);
-  
+
   return 0;
 }
 

Modified: trunk/reactos/base/shell/cmd/replace.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/replace.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/replace.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/replace.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -376,7 +376,7 @@
 	}
 
 	/* 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 */

Modified: trunk/reactos/base/shell/cmd/time.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/time.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/time.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/time.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -145,7 +145,7 @@
   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++)

Modified: trunk/reactos/base/shell/cmd/timer.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/timer.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/timer.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/timer.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -100,7 +100,7 @@
 
 	nErrorLevel = 0;
 
-	p = split (param, &argc, FALSE);
+	p = split (param, &argc, FALSE, FALSE);
 
 	//read options
 	for (i = 0; i < argc; i++)

Modified: trunk/reactos/base/shell/cmd/type.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/type.c?rev=56349&r1=56348&r2=56349&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/type.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/type.c [iso-8859-1] Sat Apr 14 21:35:58 2012
@@ -56,7 +56,7 @@
 		return 1;
 	}
 
-	argv = split (param, &argc, TRUE);
+	argv = split (param, &argc, TRUE, FALSE);
 
 	for(i = 0; i < argc; i++)
 	{




More information about the Ros-diffs mailing list