Thomas Faller : cmd: Don't print an empty line if no command was executed.
Alexandre Julliard
julliard at winehq.org
Mon Sep 3 16:26:10 CDT 2018
Module: wine
Branch: master
Commit: 731d7b30dd6c1224a79afc530cd07342d9b26365
URL: https://source.winehq.org/git/wine.git/?a=commit;h=731d7b30dd6c1224a79afc530cd07342d9b26365
Author: Thomas Faller <tfaller1 at gmx.de>
Date: Sun Sep 2 00:11:23 2018 +0200
cmd: Don't print an empty line if no command was executed.
Signed-off-by: Thomas Faller <tfaller1 at gmx.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
programs/cmd/wcmdmain.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 7a7ee16..cceb588 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -335,7 +335,7 @@ void WCMD_print_error (void) {
*
*/
-static void WCMD_show_prompt (void) {
+static void WCMD_show_prompt (BOOL newLine) {
int status;
WCHAR out_string[MAX_PATH], curdir[MAX_PATH], prompt_string[MAX_PATH];
@@ -350,8 +350,10 @@ static void WCMD_show_prompt (void) {
}
p = prompt_string;
q = out_string;
- *q++ = '\r';
- *q++ = '\n';
+ if (newLine) {
+ *q++ = '\r';
+ *q++ = '\n';
+ }
*q = '\0';
while (*p != '\0') {
if (*p != '$') {
@@ -1886,7 +1888,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
const DWORD len = ARRAY_SIZE(echoDot);
DWORD curr_size = strlenW(curPos);
DWORD min_len = (curr_size < len ? curr_size : len);
- WCMD_show_prompt();
+ WCMD_show_prompt(TRUE);
WCMD_output_asis(curPos);
/* I don't know why Windows puts a space here but it does */
/* Except for lines starting with 'echo.', 'echo:' or 'echo/'. Ask MS why */
@@ -2395,6 +2397,7 @@ int wmain (int argc, WCHAR *argvW[])
WCHAR *argPos = NULL;
WCHAR string[1024];
WCHAR envvar[4];
+ BOOL promptNewLine = TRUE;
BOOL opt_q;
int opt_t = 0;
static const WCHAR offW[] = {'O','F','F','\0'};
@@ -2749,11 +2752,12 @@ int wmain (int argc, WCHAR *argvW[])
/* Read until EOF (which for std input is never, but if redirect
in place, may occur */
- if (echo_mode) WCMD_show_prompt();
+ if (echo_mode) WCMD_show_prompt(promptNewLine);
if (!WCMD_ReadAndParseLine(NULL, &toExecute, GetStdHandle(STD_INPUT_HANDLE)))
break;
WCMD_process_commands(toExecute, FALSE, FALSE);
WCMD_free_commands(toExecute);
+ promptNewLine = !!toExecute;
toExecute = NULL;
}
return 0;
More information about the wine-cvs
mailing list