- Ignore special characters in a REM line.

- Make the \n-printing in batch files with ECHO on more consistant with how Windows does it.

svn path=/trunk/; revision=39890
This commit is contained in:
Jeffrey Morlan 2009-03-06 17:27:42 +00:00
parent 58e2d39f21
commit 79c11338fa
2 changed files with 15 additions and 9 deletions

View file

@ -285,6 +285,7 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd
/* Echo batch file line */ /* Echo batch file line */
if (bEcho && Cmd->Type != C_QUIET) if (bEcho && Cmd->Type != C_QUIET)
{ {
ConOutChar(_T('\n'));
PrintPrompt(); PrintPrompt();
EchoCommand(Cmd); EchoCommand(Cmd);
ConOutChar(_T('\n')); ConOutChar(_T('\n'));
@ -292,15 +293,9 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd
bc->current = Cmd; bc->current = Cmd;
ExecuteCommand(Cmd); ExecuteCommand(Cmd);
if (bEcho && !bIgnoreEcho && Cmd->Type != C_QUIET)
ConOutChar(_T('\n'));
FreeCommand(Cmd); FreeCommand(Cmd);
bIgnoreEcho = FALSE;
} }
/* Don't print a newline for this command */
bIgnoreEcho = TRUE;
TRACE ("Batch: returns TRUE\n"); TRACE ("Batch: returns TRUE\n");
return TRUE; return TRUE;

View file

@ -522,12 +522,22 @@ error:
return NULL; return NULL;
} }
/* Parse a REM command */
static PARSED_COMMAND *ParseRem(void)
{
/* Just ignore the rest of the line */
while (CurChar && CurChar != _T('\n'))
ParseChar();
return NULL;
}
static PARSED_COMMAND *ParseCommandPart(void) static PARSED_COMMAND *ParseCommandPart(void)
{ {
TCHAR ParsedLine[CMDLINE_LENGTH]; TCHAR ParsedLine[CMDLINE_LENGTH];
TCHAR *Pos; TCHAR *Pos;
DWORD TailOffset; DWORD TailOffset;
PARSED_COMMAND *Cmd; PARSED_COMMAND *Cmd;
PARSED_COMMAND *(*Func)(void);
REDIRECTION *RedirList = NULL; REDIRECTION *RedirList = NULL;
int Type; int Type;
@ -595,8 +605,9 @@ static PARSED_COMMAND *ParseCommandPart(void)
TailOffset = Pos - ParsedLine; TailOffset = Pos - ParsedLine;
/* Check for special forms */ /* Check for special forms */
if (_tcsicmp(ParsedLine, _T("for")) == 0 || if ((Func = ParseFor, _tcsicmp(ParsedLine, _T("for")) == 0) ||
_tcsicmp(ParsedLine, _T("if")) == 0) (Func = ParseIf, _tcsicmp(ParsedLine, _T("if")) == 0) ||
(Func = ParseRem, _tcsicmp(ParsedLine, _T("rem")) == 0))
{ {
ParseToken(0, STANDARD_SEPS); ParseToken(0, STANDARD_SEPS);
/* Do special parsing only if it's not followed by /? */ /* Do special parsing only if it's not followed by /? */
@ -608,7 +619,7 @@ static PARSED_COMMAND *ParseCommandPart(void)
FreeRedirection(RedirList); FreeRedirection(RedirList);
return NULL; return NULL;
} }
return _totlower(*ParsedLine) == _T('f') ? ParseFor() : ParseIf(); return Func();
} }
Pos = _stpcpy(Pos, _T(" /?")); Pos = _stpcpy(Pos, _T(" /?"));
} }