Make IF /? work again

svn path=/trunk/; revision=38481
This commit is contained in:
Jeffrey Morlan 2008-12-30 23:55:50 +00:00
parent 85084975fe
commit 00fd22c6ba
3 changed files with 23 additions and 14 deletions

View file

@ -120,7 +120,7 @@ COMMAND cmds[] =
{_T("history"), 0, CommandHistory}, {_T("history"), 0, CommandHistory},
#endif #endif
// {_T("if"), 0, cmd_if}, {_T("if"), 0, cmd_if},
#ifdef INCLUDE_CMD_LABEL #ifdef INCLUDE_CMD_LABEL
{_T("label"), 0, cmd_label}, {_T("label"), 0, cmd_label},

View file

@ -49,13 +49,8 @@ static INT GenericCmp(INT (*StringCmp)(LPCTSTR, LPCTSTR),
return StringCmp(Left, Right); return StringCmp(Left, Right);
} }
BOOL ExecuteIf(PARSED_COMMAND *Cmd) INT cmd_if (LPTSTR param)
{ {
INT result = FALSE; /* when set cause 'then' clause to be executed */
LPTSTR param;
#if 0
/* FIXME: need to handle IF /?; will require special parsing */
TRACE ("cmd_if: (\'%s\')\n", debugstr_aw(param)); TRACE ("cmd_if: (\'%s\')\n", debugstr_aw(param));
if (!_tcsncmp (param, _T("/?"), 2)) if (!_tcsncmp (param, _T("/?"), 2))
@ -63,7 +58,15 @@ BOOL ExecuteIf(PARSED_COMMAND *Cmd)
ConOutResPaging(TRUE,STRING_IF_HELP1); ConOutResPaging(TRUE,STRING_IF_HELP1);
return 0; return 0;
} }
#endif
error_syntax(param);
return 1;
}
BOOL ExecuteIf(PARSED_COMMAND *Cmd)
{
INT result = FALSE; /* when set cause 'then' clause to be executed */
LPTSTR param;
if (Cmd->If.Operator == IF_CMDEXTVERSION) if (Cmd->If.Operator == IF_CMDEXTVERSION)
{ {

View file

@ -332,7 +332,7 @@ static PARSED_COMMAND *ParseIf(void)
memset(Cmd, 0, sizeof(PARSED_COMMAND)); memset(Cmd, 0, sizeof(PARSED_COMMAND));
Cmd->Type = C_IF; Cmd->Type = C_IF;
int Type = ParseToken(0, STANDARD_SEPS); int Type = CurrentTokenType;
if (_tcsicmp(CurrentToken, _T("/I")) == 0) if (_tcsicmp(CurrentToken, _T("/I")) == 0)
{ {
Cmd->If.Flags |= IFFLAG_IGNORECASE; Cmd->If.Flags |= IFFLAG_IGNORECASE;
@ -488,13 +488,19 @@ static PARSED_COMMAND *ParseCommandPart(void)
/* Check for special forms */ /* Check for special forms */
if (_tcsicmp(ParsedLine, _T("if")) == 0) if (_tcsicmp(ParsedLine, _T("if")) == 0)
{ {
if (RedirList) ParseToken(0, STANDARD_SEPS);
/* Do special parsing only if it's not followed by /? */
if (_tcscmp(CurrentToken, _T("/?")) != 0)
{ {
ParseError(); if (RedirList)
FreeRedirection(RedirList); {
return NULL; ParseError();
FreeRedirection(RedirList);
return NULL;
}
return ParseIf();
} }
return ParseIf(); Pos = _stpcpy(Pos, _T(" /?"));
} }
/* Now get the tail */ /* Now get the tail */