cmd: Add a space at the end of the first echo'ed batch line [try3]
Alexandre Goujon
ale.goujon at gmail.com
Fri Oct 8 11:14:26 CDT 2010
---
programs/cmd/tests/batch.c | 8 ++++++
programs/cmd/tests/test_builtins.cmd | 20 +++++++++++++-
programs/cmd/tests/test_builtins.cmd.exp | 40 ++++++++++++++++++++++++++++-
programs/cmd/wcmdmain.c | 3 ++
4 files changed, 67 insertions(+), 4 deletions(-)
diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c
index cc8c020..d2ada9c 100644
--- a/programs/cmd/tests/batch.c
+++ b/programs/cmd/tests/batch.c
@@ -113,6 +113,7 @@ static const char *compare_line(const char *out_line, const char *out_end, const
static const char pwd_cmd[] = {'@','p','w','d','@'};
static const char todo_space_cmd[] = {'@','t','o','d','o','_','s','p','a','c','e','@'};
+ static const char space_cmd[] = {'@','s','p','a','c','e','@'};
static const char or_broken_cmd[] = {'@','o','r','_','b','r','o','k','e','n','@'};
while(exp_ptr < exp_end) {
@@ -135,6 +136,13 @@ static const char *compare_line(const char *out_line, const char *out_end, const
if(out_ptr < out_end && *out_ptr == ' ')
out_ptr++;
continue;
+ }else if(exp_ptr+sizeof(space_cmd) <= exp_end
+ && !memcmp(exp_ptr, space_cmd, sizeof(space_cmd))) {
+ exp_ptr += sizeof(space_cmd);
+ ok(*out_ptr == ' ', "expected space\n");
+ if(out_ptr < out_end && *out_ptr == ' ')
+ out_ptr++;
+ continue;
}else if(exp_ptr+sizeof(or_broken_cmd) <= exp_end
&& !memcmp(exp_ptr, or_broken_cmd, sizeof(or_broken_cmd))) {
exp_ptr = exp_end;
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index d9f5cf7..59f30fb 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -1,7 +1,21 @@
echo Tests for cmd's builtin commands
- at echo off
-echo ------------ Testing 'echo' --------------
+ at echo on
+echo ------------ Testing 'echo' [ON] --------------
+echo word
+echo 'singlequotedword'
+echo "doublequotedword"
+ at echo at-echoed-word
+echo "/?"
+echo.
+echo .
+echo.word
+echo .word
+echo word
+echo word
+
+ at echo off
+echo ------------ Testing 'echo' [OFF] --------------
echo word
echo 'singlequotedword'
echo "doublequotedword"
@@ -11,6 +25,8 @@ echo.
echo .
echo.word
echo .word
+echo word
+echo word
echo ------------ Testing 'set' --------------
echo set "FOO=bar" should not include the quotes in the variable value
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 8942cb3..dee2c5b 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -1,7 +1,41 @@
- at pwd@>echo Tests for cmd's builtin commands at todo_space@
+ at pwd@>echo Tests for cmd's builtin commands at space@
Tests for cmd's builtin commands
------------- Testing 'echo' --------------
+
+ at pwd@>echo ------------ Testing 'echo' [ON] -------------- at space@
+------------ Testing 'echo' [ON] --------------
+
+ at pwd@>echo word at space@
+word
+
+ at pwd@>echo 'singlequotedword'@space@
+'singlequotedword'
+
+ at pwd@>echo "doublequotedword"@space@
+"doublequotedword"
+at-echoed-word
+
+ at pwd@>echo "/?"@space@
+"/?"
+
+ at pwd@>echo.
+
+
+ at pwd@>echo . at space@
+.
+
+ at pwd@>echo.word
+word
+
+ at pwd@>echo .word at space@
+.word
+
+ at pwd@>echo word at space@@space@
+word at space@
+
+ at pwd@>echo word at space@@space@@space@
+word at space@@space@
+------------ Testing 'echo' [OFF] --------------
word
'singlequotedword'
"doublequotedword"
@@ -11,6 +45,8 @@ at-echoed-word
.
word
.word
+word at space@
+word at space@@space@
------------ Testing 'set' --------------
set "FOO=bar" should not include the quotes in the variable value
bar
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index b50512e..85f78b8 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -1779,8 +1779,11 @@ WCHAR *WCMD_ReadAndParseLine(WCHAR *optionalcmd, CMD_LIST **output, HANDLE readF
if (context) handleExpansion(extraSpace, FALSE, NULL, NULL);
/* Show prompt before batch line IF echo is on and in batch program */
if (context && echo_mode && extraSpace[0] && (extraSpace[0] != '@')) {
+ const WCHAR spc[]={' ','\0'};
WCMD_show_prompt();
WCMD_output_asis(extraSpace);
+ /* I don't know why Windows puts a space here but it does */
+ WCMD_output_asis(spc);
WCMD_output_asis(newline);
}
--
1.7.0.4
More information about the wine-patches
mailing list