https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8340574fe3f4883dc6c389fadda2b61052f78d35

commit 8340574fe3f4883dc6c389fadda2b61052f78d35
Author: Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Fri Nov 17 00:56:35 2017 +0100

    [CMD] Fix support for newlines in the emulated parenthesed set block of the 
"for" command.
    CORE-7998
---
 base/shell/cmd/parser.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/base/shell/cmd/parser.c b/base/shell/cmd/parser.c
index 426c1ab11a..821ef78d71 100644
--- a/base/shell/cmd/parser.c
+++ b/base/shell/cmd/parser.c
@@ -55,7 +55,7 @@ static TCHAR CurrentToken[CMDLINE_LENGTH];
 static int CurrentTokenType;
 static int InsideBlock;
 
-static TCHAR ParseChar()
+static TCHAR ParseChar(void)
 {
     TCHAR Char;
 
@@ -69,7 +69,9 @@ restart:
      * even separate tokens.
      */
     do
+    {
         Char = *ParsePos++;
+    }
     while (Char == _T('\r'));
 
     if (!Char)
@@ -91,7 +93,7 @@ restart:
     return CurChar = Char;
 }
 
-static void ParseError()
+static void ParseError(void)
 {
     error_syntax(CurrentTokenType != TOK_END ? CurrentToken : NULL);
     bParseError = TRUE;
@@ -317,6 +319,7 @@ static PARSED_COMMAND *ParseBlock(REDIRECTION *RedirList)
 
         if (CurrentTokenType == TOK_END_BLOCK)
             break;
+
         /* Skip past the \n */
         ParseChar();
     }
@@ -502,6 +505,13 @@ static PARSED_COMMAND *ParseFor(void)
         if (Type == TOK_END_BLOCK)
             break;
 
+        if (Type == TOK_END)
+        {
+            /* Skip past the \n */
+            ParseChar();
+            continue;
+        }
+
         if (Type != TOK_NORMAL)
             goto error;
 

Reply via email to