Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
56a33a8c
Commit
56a33a8c
authored
Jun 03, 2013
by
Jason Edmeades
Committed by
Alexandre Julliard
Jun 05, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: set "var=value" ignores trailing characters.
parent
1648340d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
8 deletions
+47
-8
builtins.c
programs/cmd/builtins.c
+15
-4
test_builtins.cmd
programs/cmd/tests/test_builtins.cmd
+18
-0
test_builtins.cmd.exp
programs/cmd/tests/test_builtins.cmd.exp
+7
-0
wcmd.h
programs/cmd/wcmd.h
+1
-1
wcmdmain.c
programs/cmd/wcmdmain.c
+6
-3
No files found.
programs/cmd/builtins.c
View file @
56a33a8c
...
...
@@ -4038,8 +4038,13 @@ void WCMD_setshow_env (WCHAR *s) {
s
+=
2
;
while
(
*
s
&&
(
*
s
==
' '
||
*
s
==
'\t'
))
s
++
;
if
(
*
s
==
'\"'
)
WCMD_strip_quotes
(
s
);
/* set /P "var=value"jim ignores anything after the last quote */
if
(
*
s
==
'\"'
)
{
WCHAR
*
lastquote
;
lastquote
=
WCMD_strip_quotes
(
s
);
if
(
lastquote
)
*
lastquote
=
0x00
;
WINE_TRACE
(
"set: Stripped command line '%s'
\n
"
,
wine_dbgstr_w
(
s
));
}
/* If no parameter, or no '=' sign, return an error */
if
(
!
(
*
s
)
||
((
p
=
strchrW
(
s
,
'='
))
==
NULL
))
{
...
...
@@ -4104,8 +4109,14 @@ void WCMD_setshow_env (WCHAR *s) {
}
else
{
DWORD
gle
;
if
(
*
s
==
'\"'
)
WCMD_strip_quotes
(
s
);
/* set "var=value"jim ignores anything after the last quote */
if
(
*
s
==
'\"'
)
{
WCHAR
*
lastquote
;
lastquote
=
WCMD_strip_quotes
(
s
);
if
(
lastquote
)
*
lastquote
=
0x00
;
WINE_TRACE
(
"set: Stripped command line '%s'
\n
"
,
wine_dbgstr_w
(
s
));
}
p
=
strchrW
(
s
,
'='
);
if
(
p
==
NULL
)
{
env
=
GetEnvironmentStringsW
();
...
...
programs/cmd/tests/test_builtins.cmd
View file @
56a33a8c
...
...
@@ -286,6 +286,24 @@ set WINE_FOO=foo@space@
echo '%WINE_FOO%'
set WINE_FOO=foo@tab@
echo '%WINE_FOO%'
rem Space symbol must appear in `var`
set WINE_FOO=value@space@
echo '%WINE_FOO%'
rem Space symbol must NOT appear in `var`
set "WINE_FOO=value"@space@
echo '%WINE_FOO%'
rem Mixed examples:
set WINE_FOO=jim fred
echo '%WINE_FOO%'
set WINE_FOO="jim" fred
echo '%WINE_FOO%'
set "WINE_FOO=jim fred"
echo '%WINE_FOO%'
set "WINE_FOO=jim" fred
echo '%WINE_FOO%'
rem Only the final quote ends the string
set "WINE_FOO=apple"banana"grape"orange
echo '%WINE_FOO%'
set WINE_FOO=
echo ------------ Testing variable expansion ------------
...
...
programs/cmd/tests/test_builtins.cmd.exp
View file @
56a33a8c
...
...
@@ -251,6 +251,13 @@ foo
''
'foo@space@'
'foo@tab@'
'value@space@'
'value'
'jim fred'
'"jim" fred'
'jim fred'
'jim'
'apple"banana"grape'
------------ Testing variable expansion ------------
~dp0 should be directory containing batch file
@pwd@\
...
...
programs/cmd/wcmd.h
View file @
56a33a8c
...
...
@@ -115,7 +115,7 @@ BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr);
void
WCMD_HandleTildaModifiers
(
WCHAR
**
start
,
BOOL
atExecute
);
void
WCMD_splitpath
(
const
WCHAR
*
path
,
WCHAR
*
drv
,
WCHAR
*
dir
,
WCHAR
*
name
,
WCHAR
*
ext
);
void
WCMD_strip_quotes
(
WCHAR
*
cmd
);
WCHAR
*
WCMD_strip_quotes
(
WCHAR
*
cmd
);
WCHAR
*
WCMD_LoadMessage
(
UINT
id
);
void
WCMD_strsubstW
(
WCHAR
*
start
,
const
WCHAR
*
next
,
const
WCHAR
*
insert
,
int
len
);
BOOL
WCMD_ReadFile
(
const
HANDLE
hIn
,
WCHAR
*
intoBuf
,
const
DWORD
maxChars
,
LPDWORD
charsRead
);
...
...
programs/cmd/wcmdmain.c
View file @
56a33a8c
...
...
@@ -496,20 +496,23 @@ BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr) {
/*************************************************************************
* WCMD_strip_quotes
*
* Remove first and last quote WCHARacters, preserving all other text
* Remove first and last quote WCHARacters, preserving all other text
* Returns the location of the final quote
*/
void
WCMD_strip_quotes
(
WCHAR
*
cmd
)
{
WCHAR
*
src
=
cmd
+
1
,
*
dest
=
cmd
,
*
lastq
=
NULL
;
WCHAR
*
WCMD_strip_quotes
(
WCHAR
*
cmd
)
{
WCHAR
*
src
=
cmd
+
1
,
*
dest
=
cmd
,
*
lastq
=
NULL
,
*
lastquote
;
while
((
*
dest
=*
src
)
!=
'\0'
)
{
if
(
*
src
==
'\"'
)
lastq
=
dest
;
dest
++
,
src
++
;
}
lastquote
=
lastq
;
if
(
lastq
)
{
dest
=
lastq
++
;
while
((
*
dest
++=*
lastq
++
)
!=
0
)
;
}
return
lastquote
;
}
...
...
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