Author: cwittich
Date: Thu Jan 31 18:11:25 2008
New Revision: 32065
URL:
http://svn.reactos.org/svn/reactos?rev=32065&view=rev
Log:
allow nested (...) blocks (but still no support for else)
Modified:
trunk/reactos/base/shell/cmd/batch.c
trunk/reactos/base/shell/cmd/batch.h
trunk/reactos/base/shell/cmd/if.c
Modified: trunk/reactos/base/shell/cmd/batch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/batch.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/batch.c (original)
+++ trunk/reactos/base/shell/cmd/batch.c Thu Jan 31 18:11:25 2008
@@ -272,8 +272,8 @@
SetFilePointer (bc->hBatchFile, 0, NULL, FILE_BEGIN);
bc->bEcho = bEcho; /* Preserve echo across batch calls */
bc->shiftlevel = 0;
- bc->bCmdBlock = FALSE;
-
+ bc->bCmdBlock = -1;
+
bc->ffind = NULL;
bc->forvar = _T('\0');
bc->forproto = NULL;
@@ -454,15 +454,25 @@
*++ip = _T('\0');
/* cmd block over multiple lines (..) */
- if (bc->bCmdBlock)
+ if (bc->bCmdBlock >= 0)
{
if (*first == _T(')'))
{
- bc->bCmdBlock = FALSE;
+ bc->bCmdBlock--;
continue;
}
- if (!bc->bExecuteBlock)
- continue;
+ if ((bc->bCmdBlock >= 0) && (bc->bCmdBlock < MAX_PATH))
+ if (!bc->bExecuteBlock[bc->bCmdBlock])
+ {
+ /* increase the bCmdBlock count when there is another conditon which opens a new
bracket */
+ if ((_tcsncicmp (first, _T("if"), 2) == 0) && _tcschr(first,
_T('(')))
+ {
+ bc->bCmdBlock++;
+ if ((bc->bCmdBlock > 0) && (bc->bCmdBlock < MAX_PATH))
+ bc->bExecuteBlock[bc->bCmdBlock] = bc->bExecuteBlock[bc->bCmdBlock -
1];
+ }
+ continue;
+ }
}
/* ignore labels and empty lines */
Modified: trunk/reactos/base/shell/cmd/batch.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/batch.h?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/batch.h (original)
+++ trunk/reactos/base/shell/cmd/batch.h Thu Jan 31 18:11:25 2008
@@ -6,7 +6,6 @@
#ifndef _BATCH_H_INCLUDED_
#define _BATCH_H_INCLUDED_
-
typedef struct tagBATCHCONTEXT
{
@@ -23,8 +22,8 @@
TCHAR Out[MAX_PATH];
TCHAR Err[MAX_PATH];
TCHAR forvar;
- BOOL bCmdBlock;
- BOOL bExecuteBlock;
+ INT bCmdBlock;
+ BOOL bExecuteBlock[MAX_PATH];
} BATCH_CONTEXT, *LPBATCH_CONTEXT;
Modified: trunk/reactos/base/shell/cmd/if.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/if.c?rev=32…
==============================================================================
--- trunk/reactos/base/shell/cmd/if.c (original)
+++ trunk/reactos/base/shell/cmd/if.c Thu Jan 31 18:11:25 2008
@@ -188,8 +188,13 @@
{
if (bc)
{
- bc->bCmdBlock = TRUE;
- bc->bExecuteBlock = x_flag & X_EXEC;
+ pp++;
+ bc->bCmdBlock++;
+ if ((bc->bCmdBlock >= 0) && (bc->bCmdBlock < MAX_PATH))
+ bc->bExecuteBlock[bc->bCmdBlock] = x_flag & X_EXEC;
+ /* commands are in the next lines */
+ if (*pp == _T('\0'))
+ return 0;
}
}