[PATCH 2 5/7] programs/cmd: handle white space only lines within ( ) block
Eric Pouech
eric.pouech at gmail.com
Wed Feb 2 11:38:54 CST 2022
Wine-bugs: https://bugs.winehq.org/show_bug.cgi?id=51599
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
---
programs/cmd/tests/interactive_builtins.cmd | 5 +++++
programs/cmd/tests/interactive_builtins.cmd.exp | 7 +++++++
programs/cmd/wcmdmain.c | 8 ++++++--
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/tests/interactive_builtins.cmd b/programs/cmd/tests/interactive_builtins.cmd
index f5ab45d7bb1..1a06c29d103 100644
--- a/programs/cmd/tests/interactive_builtins.cmd
+++ b/programs/cmd/tests/interactive_builtins.cmd
@@ -28,5 +28,10 @@ if exist c:\windows (
@if exist c:\windows (
@echo bar
)
+echo --------- testing syntax errors
+if exist c:\windows (
+ echo bar
+
+)
echo --------- done
exit 0
diff --git a/programs/cmd/tests/interactive_builtins.cmd.exp b/programs/cmd/tests/interactive_builtins.cmd.exp
index 4280ec186c9..331e9b54b38 100644
--- a/programs/cmd/tests/interactive_builtins.cmd.exp
+++ b/programs/cmd/tests/interactive_builtins.cmd.exp
@@ -48,6 +48,13 @@ bar
@more@ @echo bar
@more@)
bar
+echo --------- testing syntax errors
+--------- testing syntax errors
+if exist c:\windows (
+ at more@ echo bar
+ at more@
+ at more@)
+bar
echo --------- done
--------- done
exit 0
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 286dc6b9ff0..bfd72953639 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -1840,6 +1840,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
BOOL lastWasCaret = FALSE;
BOOL ignoreBracket = FALSE; /* Some expressions after if (set) require */
/* handling brackets as a normal character */
+ BOOL atEOF = FALSE;
int lineCurDepth; /* Bracket depth when line was read in */
BOOL resetAtEndOfLine = FALSE; /* Do we need to reset curdepth at EOL */
@@ -2297,8 +2298,8 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
/* If we have reached the end of the string, see if bracketing or
final caret is outstanding */
- if (*curPos == 0x00 && (curDepth > 0 || lastWasCaret) &&
- readFrom != INVALID_HANDLE_VALUE) {
+ while (*curPos == 0x00 && (curDepth > 0 || lastWasCaret) &&
+ readFrom != INVALID_HANDLE_VALUE && !atEOF) {
WCHAR *extraData;
WINE_TRACE("Need to read more data as outstanding brackets or carets\n");
@@ -2313,7 +2314,10 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
WINE_TRACE("Read more input\n");
if (!context) WCMD_output_asis( WCMD_LoadMessage(WCMD_MOREPROMPT));
if (!WCMD_fgets(extraData, MAXSTRING, readFrom))
+ {
+ atEOF = TRUE;
break;
+ }
/* echo input stream if naturally not echoed */
if (!context && !optionalcmd && GetFileType(readFrom) != FILE_TYPE_CHAR)
More information about the wine-devel
mailing list