mirror of
https://github.com/reactos/reactos.git
synced 2026-05-24 16:20:07 +08:00
[CMD] GOTO: The command should search labels from its position down to the end, then loop back to the beginning of the batch and down to the original position.
This commit is contained in:
@@ -36,6 +36,8 @@
|
||||
INT cmd_goto(LPTSTR param)
|
||||
{
|
||||
LPTSTR tmp, tmp2;
|
||||
DWORD dwCurrPos;
|
||||
BOOL bRetry;
|
||||
|
||||
TRACE("cmd_goto(\'%s\')\n", debugstr_aw(param));
|
||||
|
||||
@@ -74,14 +76,23 @@ INT cmd_goto(LPTSTR param)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* jump to begin of the file */
|
||||
bc->mempos=0;
|
||||
/*
|
||||
* Search the next label starting our position, until the end of the file.
|
||||
* If none has been found, restart at the beginning of the file, and continue
|
||||
* until reaching back our old current position.
|
||||
*/
|
||||
bRetry = FALSE;
|
||||
dwCurrPos = bc->mempos;
|
||||
|
||||
retry:
|
||||
while (BatchGetString(textline, ARRAYSIZE(textline)))
|
||||
{
|
||||
INT pos;
|
||||
INT_PTR size;
|
||||
|
||||
if (bRetry && (bc->mempos >= dwCurrPos))
|
||||
break;
|
||||
|
||||
/* Strip out any trailing spaces or control chars */
|
||||
tmp = textline + _tcslen(textline) - 1;
|
||||
while (tmp > textline && (_istcntrl(*tmp) || _istspace(*tmp) || (*tmp == _T(':'))))
|
||||
@@ -112,6 +123,12 @@ INT cmd_goto(LPTSTR param)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (!bRetry && (bc->mempos >= bc->memsize))
|
||||
{
|
||||
bRetry = TRUE;
|
||||
bc->mempos = 0;
|
||||
goto retry;
|
||||
}
|
||||
|
||||
ConErrResPrintf(STRING_GOTO_ERROR2, param);
|
||||
ExitBatch();
|
||||
|
||||
Reference in New Issue
Block a user