fix if command to work more like expected. seta_test.cmd gets much further now.

fixed some msvc6 warnings while I was in here

svn path=/trunk/; revision=17927
This commit is contained in:
Royce Mitchell III 2005-09-19 05:42:01 +00:00
parent 636cb4e66c
commit 07070d0d52

View file

@ -52,8 +52,15 @@ INT cmd_if (LPTSTR cmd, LPTSTR param)
return 0;
}
/* First check if param string begins with word 'not' */
if (!_tcsnicmp (param, _T("not"), 3) && _istspace (*(param + 3)))
/* First check if param string begins with '!' or 'not' */
if ( param[0] == _T('!') )
{
x_flag = X_EXEC; /* Remember '!' */
++param; /* Step over '!' */
while (_istspace (*param)) /* And subsequent spaces */
param++;
}
else if (!_tcsnicmp (param, _T("not"), 3) && _istspace (*(param + 3)))
{
x_flag = X_EXEC; /* Remember 'NOT' */
param += 3; /* Step over 'NOT' */
@ -64,14 +71,15 @@ INT cmd_if (LPTSTR cmd, LPTSTR param)
/* Check for 'exist' form */
if (!_tcsnicmp (param, _T("exist"), 5) && _istspace (*(param + 5)))
{
UINT i;
BOOL bInside = FALSE;
param += 5;
while (_istspace (*param))
param++;
pp = param;
INT i;
BOOL bInside = FALSE;
/* find the whole path to the file */
for(i = 0; i < _tcslen(param); i++)
{
@ -155,39 +163,35 @@ INT cmd_if (LPTSTR cmd, LPTSTR param)
x_flag |= X_EMPTY; /* Syntax error if comd empty */
}
else if (NULL == (pp = _tcsstr (param, _T("=="))))
{
/* Check that '==' is present, syntax error if not */
error_syntax (NULL);
return 1;
}
else
{
/* Change first '='to space to terminate comparison loop */
*pp = _T(' '); /* Need a space to terminate comparison loop */
pp += 2; /* over '==' */
BOOL bInQuote = FALSE;
INT p1len;
pp = param;
while ( *pp && ( bInQuote || *pp != _T('=') ) )
{
if ( *pp == _T('\"') )
bInQuote = !bInQuote;
++pp;
}
p1len = pp-param;
/* check for "==" */
if ( *pp++ != _T('=') || *pp++ != _T('=') )
{
error_syntax ( NULL );
return 1;
}
while (_istspace (*pp)) /* Skip subsequent spaces */
pp++;
_tcscat (pp, _T(" ")); /* Add one space to ensure comparison ends */
while (*param == *pp) /* Comparison loop */
{
if (_istspace (*param)) /* Terminates on space */
break;
param++, pp++;
}
if (x_flag ^= (*param != *pp) ? 0 : X_EXEC)
{
while (*pp && !_istspace (*pp)) /* Find first space, */
pp++;
/* are the two sides equal, and does the second end in the same place? */
if ( !_tcsncmp(param,pp,p1len) && _tcschr(_T(" ("),pp[p1len]) )
x_flag ^= X_EXEC;
pp += p1len;
if ( x_flag )
x_flag |= X_EMPTY;
}
}
if (x_flag & X_EMPTY)
{