Author: jmorlan
Date: Tue Dec 30 17:55:50 2008
New Revision: 38481
URL:
http://svn.reactos.org/svn/reactos?rev=38481&view=rev
Log:
Make IF /? work again
Modified:
trunk/reactos/base/shell/cmd/cmdtable.c
trunk/reactos/base/shell/cmd/if.c
trunk/reactos/base/shell/cmd/parser.c
Modified: trunk/reactos/base/shell/cmd/cmdtable.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmdtable.c?…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmdtable.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/cmdtable.c [iso-8859-1] Tue Dec 30 17:55:50 2008
@@ -120,7 +120,7 @@
{_T("history"), 0, CommandHistory},
#endif
-// {_T("if"), 0, cmd_if},
+ {_T("if"), 0, cmd_if},
#ifdef INCLUDE_CMD_LABEL
{_T("label"), 0, cmd_label},
Modified: trunk/reactos/base/shell/cmd/if.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/if.c?rev=38…
==============================================================================
--- trunk/reactos/base/shell/cmd/if.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/if.c [iso-8859-1] Tue Dec 30 17:55:50 2008
@@ -49,13 +49,8 @@
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));
if (!_tcsncmp (param, _T("/?"), 2))
@@ -63,7 +58,15 @@
ConOutResPaging(TRUE,STRING_IF_HELP1);
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)
{
Modified: trunk/reactos/base/shell/cmd/parser.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/parser.c?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/parser.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/parser.c [iso-8859-1] Tue Dec 30 17:55:50 2008
@@ -332,7 +332,7 @@
memset(Cmd, 0, sizeof(PARSED_COMMAND));
Cmd->Type = C_IF;
- int Type = ParseToken(0, STANDARD_SEPS);
+ int Type = CurrentTokenType;
if (_tcsicmp(CurrentToken, _T("/I")) == 0)
{
Cmd->If.Flags |= IFFLAG_IGNORECASE;
@@ -488,13 +488,19 @@
/* Check for special forms */
if (_tcsicmp(ParsedLine, _T("if")) == 0)
{
- if (RedirList)
- {
- ParseError();
- FreeRedirection(RedirList);
- return NULL;
- }
- return ParseIf();
+ ParseToken(0, STANDARD_SEPS);
+ /* Do special parsing only if it's not followed by /? */
+ if (_tcscmp(CurrentToken, _T("/?")) != 0)
+ {
+ if (RedirList)
+ {
+ ParseError();
+ FreeRedirection(RedirList);
+ return NULL;
+ }
+ return ParseIf();
+ }
+ Pos = _stpcpy(Pos, _T(" /?"));
}
/* Now get the tail */