mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:23:01 +00:00
handle call :Label
fix goto :Label svn path=/trunk/; revision=32070
This commit is contained in:
parent
97b5e11eba
commit
76569bc213
4 changed files with 45 additions and 26 deletions
|
@ -273,6 +273,8 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
|
|||
bc->bEcho = bEcho; /* Preserve echo across batch calls */
|
||||
bc->shiftlevel = 0;
|
||||
bc->bCmdBlock = -1;
|
||||
bc->lCallPosition = 0;
|
||||
bc->lCallPositionHigh = 0;
|
||||
|
||||
bc->ffind = NULL;
|
||||
bc->forvar = _T('\0');
|
||||
|
|
|
@ -24,6 +24,8 @@ typedef struct tagBATCHCONTEXT
|
|||
TCHAR forvar;
|
||||
INT bCmdBlock;
|
||||
BOOL bExecuteBlock[MAX_PATH];
|
||||
LONG lCallPosition; /* store position where to return to after Call :Label */
|
||||
LONG lCallPositionHigh;
|
||||
} BATCH_CONTEXT, *LPBATCH_CONTEXT;
|
||||
|
||||
|
||||
|
|
|
@ -53,6 +53,13 @@ INT cmd_call (LPTSTR cmd, LPTSTR param)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (*param == _T(':') && (bc))
|
||||
{
|
||||
bc->lCallPosition = SetFilePointer(bc->hBatchFile, 0, &bc->lCallPositionHigh, FILE_CURRENT);
|
||||
cmd_goto(_T("goto"), param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nErrorLevel = 0;
|
||||
|
||||
n = (LPBATCH_CONTEXT)cmd_alloc (sizeof (BATCH_CONTEXT));
|
||||
|
|
|
@ -40,7 +40,7 @@ INT cmd_goto (LPTSTR cmd, LPTSTR param)
|
|||
{
|
||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||
LPTSTR tmp;
|
||||
LONG lNewPosHigh;
|
||||
LONG lNewPosHigh = 0;
|
||||
|
||||
#ifdef _DEBUG
|
||||
DebugPrintf (_T("cmd_goto (\'%s\', \'%s\'\n"), cmd, param);
|
||||
|
@ -77,7 +77,15 @@ INT cmd_goto (LPTSTR cmd, LPTSTR param)
|
|||
/* jump to end of the file */
|
||||
if ( _tcsicmp( param, _T(":eof"))==0)
|
||||
{
|
||||
/* when lCallPosition != 0 we have to return to the caller */
|
||||
if (bc->lCallPosition == 0)
|
||||
SetFilePointer (bc->hBatchFile, 0, &lNewPosHigh, FILE_END);
|
||||
else
|
||||
{
|
||||
SetFilePointer (bc->hBatchFile, (LONG)bc->lCallPosition, &bc->lCallPositionHigh, FILE_BEGIN);
|
||||
bc->lCallPosition = 0;
|
||||
bc->lCallPositionHigh = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -92,7 +100,6 @@ INT cmd_goto (LPTSTR cmd, LPTSTR param)
|
|||
/* Strip out any trailing spaces or control chars */
|
||||
tmp = textline + _tcslen (textline) - 1;
|
||||
|
||||
|
||||
while (_istcntrl (*tmp) || _istspace (*tmp) || (*tmp == _T(':')))
|
||||
tmp--;
|
||||
*(tmp + 1) = _T('\0');
|
||||
|
@ -113,8 +120,9 @@ INT cmd_goto (LPTSTR cmd, LPTSTR param)
|
|||
}
|
||||
|
||||
/* use whole label name */
|
||||
if ((*tmp == _T(':')) && (_tcsicmp (++tmp, param) == 0))
|
||||
if ((*tmp == _T(':')) && ((_tcsicmp (++tmp, param) == 0) || (_tcsicmp (tmp, ++param) == 0)))
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
LoadString(CMD_ModuleHandle, STRING_GOTO_ERROR2, szMsg, RC_STRING_MAX_SIZE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue