mirror of
https://github.com/reactos/reactos.git
synced 2024-10-23 22:40:47 +00:00
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:
parent
c7ed95cb55
commit
846c750785
|
@ -29,12 +29,12 @@ INT cmd_label (LPTSTR cmd, LPTSTR param)
|
||||||
TCHAR szLabel[80];
|
TCHAR szLabel[80];
|
||||||
TCHAR szOldLabel[80];
|
TCHAR szOldLabel[80];
|
||||||
DWORD dwSerialNr;
|
DWORD dwSerialNr;
|
||||||
LPTSTR *arg;
|
|
||||||
INT args;
|
|
||||||
|
|
||||||
/* set empty label string */
|
/* set empty label string */
|
||||||
szLabel[0] = _T('\0');
|
szLabel[0] = _T('\0');
|
||||||
|
|
||||||
|
nErrorLevel = 0;
|
||||||
|
|
||||||
/* print help */
|
/* print help */
|
||||||
if (!_tcsncmp (param, _T("/?"), 2))
|
if (!_tcsncmp (param, _T("/?"), 2))
|
||||||
{
|
{
|
||||||
|
@ -42,49 +42,28 @@ INT cmd_label (LPTSTR cmd, LPTSTR param)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nErrorLevel = 0;
|
|
||||||
|
|
||||||
/* get parameters */
|
/* get parameters */
|
||||||
arg = split (param, &args, FALSE);
|
if (param[0] != _T('\0') && param[1] == _T(':'))
|
||||||
|
|
||||||
if (args > 2)
|
|
||||||
{
|
{
|
||||||
/* too many parameters */
|
szRootPath[0] = toupper(*param);
|
||||||
error_too_many_parameters (arg[args - 1]);
|
param += 2;
|
||||||
freep (arg);
|
while (_istspace(*param))
|
||||||
nErrorLevel = 1;
|
param++;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (args == 0)
|
|
||||||
{
|
{
|
||||||
/* get label of current drive */
|
/* get label of current drive */
|
||||||
TCHAR szCurPath[MAX_PATH];
|
TCHAR szCurPath[MAX_PATH];
|
||||||
GetCurrentDirectory (MAX_PATH, szCurPath);
|
GetCurrentDirectory (MAX_PATH, szCurPath);
|
||||||
szRootPath[0] = szCurPath[0];
|
szRootPath[0] = szCurPath[0];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
_tcsncpy (szLabel, param, 12);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check root path */
|
/* check root path */
|
||||||
if (!IsValidPathName (szRootPath))
|
if (!IsValidPathName (szRootPath))
|
||||||
{
|
{
|
||||||
error_invalid_drive ();
|
error_invalid_drive ();
|
||||||
freep (arg);
|
|
||||||
nErrorLevel = 1;
|
nErrorLevel = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +89,6 @@ INT cmd_label (LPTSTR cmd, LPTSTR param)
|
||||||
|
|
||||||
if (szLabel[0] == _T('\0'))
|
if (szLabel[0] == _T('\0'))
|
||||||
{
|
{
|
||||||
LoadString(CMD_ModuleHandle, STRING_LABEL_HELP5, szMsg, RC_STRING_MAX_SIZE);
|
|
||||||
ConOutResPuts(STRING_LABEL_HELP5);
|
ConOutResPuts(STRING_LABEL_HELP5);
|
||||||
|
|
||||||
ConInString(szLabel, 80);
|
ConInString(szLabel, 80);
|
||||||
|
@ -118,8 +96,6 @@ INT cmd_label (LPTSTR cmd, LPTSTR param)
|
||||||
|
|
||||||
SetVolumeLabel(szRootPath, szLabel);
|
SetVolumeLabel(szRootPath, szLabel);
|
||||||
|
|
||||||
freep(arg);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue