mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 01:42:30 +00:00
allow nested (...) blocks (but still no support for else)
svn path=/trunk/; revision=32065
This commit is contained in:
parent
4a894bb597
commit
8f8faff777
|
@ -272,8 +272,8 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
|
|||
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 @@ LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
|
|||
*++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 */
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#ifndef _BATCH_H_INCLUDED_
|
||||
#define _BATCH_H_INCLUDED_
|
||||
|
||||
|
||||
typedef struct tagBATCHCONTEXT
|
||||
{
|
||||
struct tagBATCHCONTEXT *prev;
|
||||
|
@ -23,8 +22,8 @@ typedef struct tagBATCHCONTEXT
|
|||
TCHAR Out[MAX_PATH];
|
||||
TCHAR Err[MAX_PATH];
|
||||
TCHAR forvar;
|
||||
BOOL bCmdBlock;
|
||||
BOOL bExecuteBlock;
|
||||
INT bCmdBlock;
|
||||
BOOL bExecuteBlock[MAX_PATH];
|
||||
} BATCH_CONTEXT, *LPBATCH_CONTEXT;
|
||||
|
||||
|
||||
|
|
|
@ -188,8 +188,13 @@ INT cmd_if (LPTSTR cmd, LPTSTR param)
|
|||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue