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
7f60584a
Commit
7f60584a
authored
Mar 30, 2024
by
Eric Pouech
Committed by
Alexandre Julliard
Apr 01, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Fix substring expansion for 'magic' variables.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=56498
Signed-off-by:
Eric Pouech
<
epouech@codeweavers.com
>
parent
b868d823
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
20 deletions
+14
-20
test_builtins.cmd.exp
programs/cmd/tests/test_builtins.cmd.exp
+1
-1
wcmdmain.c
programs/cmd/wcmdmain.c
+13
-19
No files found.
programs/cmd/tests/test_builtins.cmd.exp
View file @
7f60584a
...
...
@@ -533,7 +533,7 @@ e@or_broken@qwerty
''@or_broken@'qwerty'
r@or_broken@qwerty
ty
@todo_wine@
mmydir
mmydir
------------ Testing variable substitution ------------
--- in FOR variables
"A B"
...
...
programs/cmd/wcmdmain.c
View file @
7f60584a
...
...
@@ -614,25 +614,19 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
/* Handle DATE, TIME, ERRORLEVEL and CD replacements allowing */
/* override if existing env var called that name */
if
(
WCMD_is_magic_envvar
(
thisVar
,
L"ERRORLEVEL"
))
{
wsprintfW
(
thisVarContents
,
L"%d"
,
errorlevel
);
len
=
lstrlenW
(
thisVarContents
);
len
=
wsprintfW
(
thisVarContents
,
L"%d"
,
errorlevel
);
}
else
if
(
WCMD_is_magic_envvar
(
thisVar
,
L"DATE"
))
{
GetDateFormatW
(
LOCALE_USER_DEFAULT
,
DATE_SHORTDATE
,
NULL
,
NULL
,
thisVarContents
,
MAXSTRING
);
len
=
lstrlenW
(
thisVarContents
);
len
=
GetDateFormatW
(
LOCALE_USER_DEFAULT
,
DATE_SHORTDATE
,
NULL
,
NULL
,
thisVarContents
,
ARRAY_SIZE
(
thisVarContents
));
}
else
if
(
WCMD_is_magic_envvar
(
thisVar
,
L"TIME"
))
{
GetTimeFormatW
(
LOCALE_USER_DEFAULT
,
TIME_NOSECONDS
,
NULL
,
NULL
,
thisVarContents
,
MAXSTRING
);
len
=
lstrlenW
(
thisVarContents
);
len
=
GetTimeFormatW
(
LOCALE_USER_DEFAULT
,
TIME_NOSECONDS
,
NULL
,
NULL
,
thisVarContents
,
ARRAY_SIZE
(
thisVarContents
));
}
else
if
(
WCMD_is_magic_envvar
(
thisVar
,
L"CD"
))
{
GetCurrentDirectoryW
(
MAXSTRING
,
thisVarContents
);
len
=
lstrlenW
(
thisVarContents
);
len
=
GetCurrentDirectoryW
(
ARRAY_SIZE
(
thisVarContents
),
thisVarContents
);
}
else
if
(
WCMD_is_magic_envvar
(
thisVar
,
L"RANDOM"
))
{
wsprintfW
(
thisVarContents
,
L"%d"
,
rand
()
%
32768
);
len
=
lstrlenW
(
thisVarContents
);
len
=
wsprintfW
(
thisVarContents
,
L"%d"
,
rand
()
%
32768
);
}
else
{
len
=
ExpandEnvironmentStringsW
(
thisVar
,
thisVarContents
,
ARRAY_SIZE
(
thisVarContents
));
if
((
len
=
ExpandEnvironmentStringsW
(
thisVar
,
thisVarContents
,
ARRAY_SIZE
(
thisVarContents
))))
len
--
;
}
if
(
len
==
0
)
...
...
@@ -704,9 +698,9 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
/* Check bounds */
if
(
substrposition
>=
0
)
{
startCopy
=
&
thisVarContents
[
min
(
substrposition
,
len
)];
startCopy
=
&
thisVarContents
[
min
(
substrposition
,
len
-
1
)];
}
else
{
startCopy
=
&
thisVarContents
[
max
(
0
,
len
+
substrposition
-
1
)];
startCopy
=
&
thisVarContents
[
max
(
0
,
len
+
substrposition
)];
}
if
(
commapos
==
NULL
)
{
...
...
@@ -714,12 +708,12 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
WCMD_strsubstW
(
start
,
endOfVar
+
1
,
startCopy
,
-
1
);
}
else
if
(
substrlength
<
0
)
{
int
copybytes
=
(
len
+
substrlength
-
1
)
-
(
startCopy
-
thisVarContents
);
if
(
copybytes
>
len
)
copybytes
=
len
;
int
copybytes
=
len
+
substrlength
-
(
startCopy
-
thisVarContents
);
if
(
copybytes
>
=
len
)
copybytes
=
len
-
1
;
else
if
(
copybytes
<
0
)
copybytes
=
0
;
WCMD_strsubstW
(
start
,
endOfVar
+
1
,
startCopy
,
copybytes
);
}
else
{
substrlength
=
min
(
substrlength
,
len
-
(
startCopy
-
thisVarContents
+
1
));
substrlength
=
min
(
substrlength
,
len
-
(
startCopy
-
thisVarContents
));
WCMD_strsubstW
(
start
,
endOfVar
+
1
,
startCopy
,
substrlength
);
}
...
...
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