Index: reactos/base/shell/cmd/batch.c =================================================================== --- reactos/base/shell/cmd/batch.c (revision 76032) +++ reactos/base/shell/cmd/batch.c (working copy) @@ -206,6 +206,8 @@ */ void BatchFile2Mem(HANDLE hBatchFile) { + INT i, Level = 0; + TRACE ("BatchFile2Mem ()\n"); bc->memsize = GetFileSize(hBatchFile, NULL); @@ -219,6 +221,53 @@ ReadFile(hBatchFile, (LPVOID)bc->mem, bc->memsize, &bc->memsize, NULL); bc->mem[bc->memsize]='\0'; /* end this, so you can dump it as a string */ bc->memfree=TRUE; /* this one needs to be freed */ + + /* Handle Open and Closed Parenthesis by Doug Lyons */ + /* See: https://ss64.com/nt/syntax-brackets.html */ + /* This looks for " in (" to take out the \r & \n */ + /* which follows within the parenthesis until ")" */ + for (i = 0; i < (strlen(bc->mem)); i++) + { + switch (bc->mem[i]) + { + case ' ': + if((Level == 0) || (Level == 3)) + Level++; + if(Level ==2) + Level = 0; + break; + case 'i': + case 'I': + if(Level == 1) + Level = 2; + else if (Level != 5) + Level = 0; + break; + case 'n': + case 'N': + if(Level == 2) + Level = 3; + else if (Level != 5) + Level = 0; + break; + case '(': + if(Level == 4) + Level = 5; + else + Level = 0; + break; + case ')': + if(Level > 0) + Level = 0; + break; + default: + if(Level > 0 && Level < 5) + Level = 0; + } +// printf("Level is %d and Char is %c(0x%x).\n", Level, bc->mem[i], bc->mem[i]); + if(Level > 4) /* if we are inside parenthesis then blank \r and \n */ + if(bc->mem[i] == '\r' || bc->mem[i] == '\n') bc->mem[i] = ' '; + } } else {