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)

svn path=/trunk/; revision=34566
This commit is contained in:
Jeffrey Morlan 2008-07-17 16:46:09 +00:00
parent c7ed95cb55
commit 846c750785

View file

@ -29,12 +29,12 @@ INT cmd_label (LPTSTR cmd, LPTSTR param)
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 @@ INT cmd_label (LPTSTR cmd, LPTSTR param)
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 @@ INT cmd_label (LPTSTR cmd, LPTSTR param)
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 @@ INT cmd_label (LPTSTR cmd, LPTSTR param)
SetVolumeLabel(szRootPath, szLabel);
freep(arg);
return 0;
}