[ros-diffs] [jmorlan] 34566: Fix argument parsing for label command. It should not split the arguments by spaces; on Windows you can do 'label c:x y z' and it will set the label to X Y Z. (Bug 3530 #2)

jmorlan at svn.reactos.org jmorlan at svn.reactos.org
Thu Jul 17 18:46:09 CEST 2008


Author: jmorlan
Date: Thu Jul 17 11:46:09 2008
New Revision: 34566

URL: http://svn.reactos.org/svn/reactos?rev=34566&view=rev
Log:
Fix argument parsing for label command. It should not split the arguments by spaces; on Windows you can do 'label c:x y z' and it will set the label to X Y Z. (Bug 3530 #2)

Modified:
    trunk/reactos/base/shell/cmd/label.c

Modified: trunk/reactos/base/shell/cmd/label.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/label.c?rev=34566&r1=34565&r2=34566&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/label.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/label.c [iso-8859-1] Thu Jul 17 11:46:09 2008
@@ -29,11 +29,11 @@
 	TCHAR  szLabel[80];
 	TCHAR  szOldLabel[80];
 	DWORD  dwSerialNr;
-	LPTSTR *arg;
-	INT    args;
 
 	/* set empty label string */
 	szLabel[0] = _T('\0');
+
+	nErrorLevel = 0;
 
 	/* print help */
 	if (!_tcsncmp (param, _T("/?"), 2))
@@ -42,55 +42,34 @@
 		return 0;
 	}
 
-  nErrorLevel = 0;
-
 	/* get parameters */
-	arg = split (param, &args, FALSE);
-
-	if (args > 2)
+	if (param[0] != _T('\0') && param[1] == _T(':'))
 	{
-		/* too many parameters */
-		error_too_many_parameters (arg[args - 1]);
-		freep (arg);
-    nErrorLevel = 1;
-		return 1;
+		szRootPath[0] = toupper(*param);
+		param += 2;
+		while (_istspace(*param))
+			param++;
 	}
-
-	if (args == 0)
+	else
 	{
 		/* get label of current drive */
 		TCHAR szCurPath[MAX_PATH];
 		GetCurrentDirectory (MAX_PATH, szCurPath);
 		szRootPath[0] = szCurPath[0];
 	}
-	else
-	{
-		if ((_tcslen (arg[0]) >= 2) && (arg[0][1] == _T(':')))
-		{
-			szRootPath[0] = toupper (*arg[0]);
-			if (args == 2)
-				_tcsncpy (szLabel, arg[1], 12);
-		}
-		else
-		{
-			TCHAR szCurPath[MAX_PATH];
-			GetCurrentDirectory (MAX_PATH, szCurPath);
-			szRootPath[0] = szCurPath[0];
-			_tcsncpy (szLabel, arg[0], 12);
-		}
-	}
+
+	_tcsncpy (szLabel, param, 12);
 
 	/* check root path */
 	if (!IsValidPathName (szRootPath))
 	{
 		error_invalid_drive ();
-		freep (arg);
-    nErrorLevel = 1;
+		nErrorLevel = 1;
 		return 1;
 	}
 
 	GetVolumeInformation(szRootPath, szOldLabel, 80, &dwSerialNr,
-			      NULL, NULL, NULL, 0);
+	                     NULL, NULL, NULL, 0);
 
 	/* print drive info */
 	if (szOldLabel[0] != _T('\0'))
@@ -110,7 +89,6 @@
 
 	if (szLabel[0] == _T('\0'))
 	{
-		LoadString(CMD_ModuleHandle, STRING_LABEL_HELP5, szMsg, RC_STRING_MAX_SIZE);
 		ConOutResPuts(STRING_LABEL_HELP5);
 
 		ConInString(szLabel, 80);
@@ -118,8 +96,6 @@
 
 	SetVolumeLabel(szRootPath, szLabel);
 
-	freep(arg);
-
 	return 0;
 }
 



More information about the Ros-diffs mailing list