mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 14:42:11 +00:00
[CMD] Fixes for Batch error execution control flow.
CORE-13713 CORE-13736 - In case execution of all batch contexts is stopped (by selecting "All" at the Ctrl-C/Ctrl-Break prompt), notify as well the CheckCtrlBreak() signal handler once there are no more batch contexts (this in effect resets the internal 'bLeaveAll' static flag in CheckCtrlBreak). This is an adaptation of the fix present in FreeCOM 1.5, first described in https://gcfl.net/FreeDOS/command.com/bugs074g.html . - Introduce a ParseErrorEx() helper that sets the 'bParseError' flag and displays a customized syntax-error message, only for the first syntax error encountered. Implement ParseError() around the *Ex function. - In batch mode, echo the original pre-parsed batch file line if a parse error has been encountered. - When running a compound command - including IF, FOR, command blocks -, and that control flow is modified by any CALL/GOTO/EXIT command, detect this while running the compound command so as to stop it and go back to the main batch execution loop, that will then set up the actual new command to run. - In GOTO, do not process any more parts of a compound command only when we have found a valid label.
This commit is contained in:
parent
7f8792e005
commit
6eb1cae348
9 changed files with 119 additions and 33 deletions
|
@ -60,9 +60,9 @@ enum
|
|||
/* Scratch buffer for temporary command substitutions / expansions */
|
||||
static TCHAR TempBuf[CMDLINE_LENGTH];
|
||||
|
||||
static BOOL bParseError;
|
||||
/*static*/ BOOL bParseError;
|
||||
static BOOL bLineContinuations;
|
||||
static TCHAR ParseLine[CMDLINE_LENGTH];
|
||||
/*static*/ TCHAR ParseLine[CMDLINE_LENGTH];
|
||||
static TCHAR *ParsePos;
|
||||
static TCHAR CurChar;
|
||||
|
||||
|
@ -108,10 +108,17 @@ restart:
|
|||
return (CurChar = Char);
|
||||
}
|
||||
|
||||
void ParseErrorEx(LPTSTR s)
|
||||
{
|
||||
/* Only display the first error we encounter */
|
||||
if (!bParseError)
|
||||
error_syntax(s);
|
||||
bParseError = TRUE;
|
||||
}
|
||||
|
||||
static void ParseError(void)
|
||||
{
|
||||
error_syntax(CurrentTokenType != TOK_END ? CurrentToken : NULL);
|
||||
bParseError = TRUE;
|
||||
ParseErrorEx(CurrentTokenType != TOK_END ? CurrentToken : NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue