mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
fix a bug in 'if exsist', it was only reading to the first space for the file name, ignoring quotes and there fore searching for bad file names.
svn path=/trunk/; revision=17880
This commit is contained in:
parent
0e07f15c6a
commit
dadab98225
1 changed files with 25 additions and 4 deletions
|
@ -69,15 +69,36 @@ INT cmd_if (LPTSTR cmd, LPTSTR param)
|
||||||
param++;
|
param++;
|
||||||
|
|
||||||
pp = param;
|
pp = param;
|
||||||
while (*pp && !_istspace (*pp))
|
|
||||||
|
INT i;
|
||||||
|
BOOL bInside = FALSE;
|
||||||
|
/* find the whole path to the file */
|
||||||
|
for(i = 0; i < _tcslen(param); i++)
|
||||||
|
{
|
||||||
|
if(param[i] == _T('\"'))
|
||||||
|
bInside = !bInside;
|
||||||
|
if((param[i] == _T(' ')) && !bInside)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
pp++;
|
pp++;
|
||||||
|
}
|
||||||
|
*pp++ = _T('\0');
|
||||||
|
i = 0;
|
||||||
|
/* remove quotes */
|
||||||
|
while(i < _tcslen(param))
|
||||||
|
{
|
||||||
|
if(param[i] == _T('\"'))
|
||||||
|
memmove(¶m[i],¶m[i + 1], _tcslen(¶m[i]) * sizeof(TCHAR));
|
||||||
|
else
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
if (*pp)
|
if (*pp)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA f;
|
WIN32_FIND_DATA f;
|
||||||
HANDLE hFind;
|
HANDLE hFind;
|
||||||
|
|
||||||
*pp++ = _T('\0');
|
|
||||||
hFind = FindFirstFile (param, &f);
|
hFind = FindFirstFile (param, &f);
|
||||||
x_flag ^= (hFind == INVALID_HANDLE_VALUE) ? 0 : X_EXEC;
|
x_flag ^= (hFind == INVALID_HANDLE_VALUE) ? 0 : X_EXEC;
|
||||||
if (hFind != INVALID_HANDLE_VALUE)
|
if (hFind != INVALID_HANDLE_VALUE)
|
||||||
|
|
Loading…
Reference in a new issue