Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e8d8df3c
Commit
e8d8df3c
authored
Nov 11, 2011
by
Frédéric Delanoy
Committed by
Alexandre Julliard
Nov 15, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Trim whitespace in echo on/off.
parent
3acc2068
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
11 deletions
+47
-11
builtins.c
programs/cmd/builtins.c
+43
-11
test_builtins.cmd
programs/cmd/tests/test_builtins.cmd
+2
-0
test_builtins.cmd.exp
programs/cmd/tests/test_builtins.cmd.exp
+2
-0
No files found.
programs/cmd/builtins.c
View file @
e8d8df3c
...
...
@@ -854,6 +854,35 @@ BOOL WCMD_delete (WCHAR *command) {
return
foundAny
;
}
/*
* WCMD_strtrim
*
* Returns a trimmed version of s with all leading and trailing whitespace removed
* Pre: s non NULL
*
*/
static
WCHAR
*
WCMD_strtrim
(
const
WCHAR
*
s
)
{
DWORD
len
=
strlenW
(
s
);
const
WCHAR
*
start
=
s
;
WCHAR
*
result
;
if
(
!
(
result
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
len
+
1
)
*
sizeof
(
WCHAR
))))
return
NULL
;
while
(
isspaceW
(
*
start
))
start
++
;
if
(
*
start
)
{
const
WCHAR
*
end
=
s
+
len
-
1
;
while
(
end
>
start
&&
isspaceW
(
*
end
))
end
--
;
memcpy
(
result
,
start
,
(
end
-
start
+
2
)
*
sizeof
(
WCHAR
));
result
[
end
-
start
+
1
]
=
'\0'
;
}
else
{
result
[
0
]
=
'\0'
;
}
return
result
;
}
/****************************************************************************
* WCMD_echo
*
...
...
@@ -861,33 +890,36 @@ BOOL WCMD_delete (WCHAR *command) {
* in DOS (try typing "ECHO ON AGAIN" for an example).
*/
void
WCMD_echo
(
const
WCHAR
*
command
)
{
void
WCMD_echo
(
const
WCHAR
*
command
)
{
int
count
;
const
WCHAR
*
origcommand
=
command
;
WCHAR
*
trimmed
;
if
(
command
[
0
]
==
' '
||
command
[
0
]
==
'\t'
||
command
[
0
]
==
'.'
||
command
[
0
]
==
':'
||
command
[
0
]
==
';'
)
command
++
;
count
=
strlenW
(
command
);
trimmed
=
WCMD_strtrim
(
command
);
if
(
!
trimmed
)
return
;
count
=
strlenW
(
trimmed
);
if
(
count
==
0
&&
origcommand
[
0
]
!=
'.'
&&
origcommand
[
0
]
!=
':'
&&
origcommand
[
0
]
!=
';'
)
{
if
(
echo_mode
)
WCMD_output
(
WCMD_LoadMessage
(
WCMD_ECHOPROMPT
),
onW
);
else
WCMD_output
(
WCMD_LoadMessage
(
WCMD_ECHOPROMPT
),
offW
);
return
;
}
if
(
lstrcmpiW
(
command
,
onW
)
==
0
)
{
if
(
lstrcmpiW
(
trimmed
,
onW
)
==
0
)
echo_mode
=
TRUE
;
return
;
}
if
(
lstrcmpiW
(
command
,
offW
)
==
0
)
{
else
if
(
lstrcmpiW
(
trimmed
,
offW
)
==
0
)
echo_mode
=
FALSE
;
return
;
else
{
WCMD_output_asis
(
command
);
WCMD_output
(
newline
);
}
WCMD_output_asis
(
command
);
WCMD_output
(
newline
);
HeapFree
(
GetProcessHeap
(),
0
,
trimmed
);
}
/**************************************************************************
...
...
programs/cmd/tests/test_builtins.cmd
View file @
e8d8df3c
...
...
@@ -26,8 +26,10 @@ echo@tab@word@tab@@space@
echo @tab@word
echo @tab@word
echo@tab@@tab@word
echo @tab@ on @space@
@echo off
echo off@tab@@space@
echo ------------ Testing 'echo' [OFF] --------------
echo word
echo 'singlequotedword'
...
...
programs/cmd/tests/test_builtins.cmd.exp
View file @
e8d8df3c
...
...
@@ -74,6 +74,8 @@ word
@pwd@>echo@tab@@tab@word@space@
@tab@word
@pwd@>echo @tab@ on @space@@space@
------------ Testing 'echo' [OFF] --------------
word
'singlequotedword'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment