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
86140e3f
Commit
86140e3f
authored
Mar 08, 2007
by
Jason Edmeades
Committed by
Alexandre Julliard
Mar 08, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd.exe: setlocal and endlocal should preserve drive and directory.
parent
d1317f55
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
builtins.c
programs/cmd/builtins.c
+22
-2
wcmd.h
programs/cmd/wcmd.h
+4
-1
No files found.
programs/cmd/builtins.c
View file @
86140e3f
...
...
@@ -893,6 +893,7 @@ static WCHAR *WCMD_dupenv( const WCHAR *env )
void
WCMD_setlocal
(
const
char
*
s
)
{
WCHAR
*
env
;
struct
env_stack
*
env_copy
;
char
cwd
[
MAX_PATH
];
/* DISABLEEXTENSIONS ignored */
...
...
@@ -910,11 +911,16 @@ void WCMD_setlocal (const char *s) {
{
env_copy
->
next
=
saved_environment
;
saved_environment
=
env_copy
;
/* Save the current drive letter */
GetCurrentDirectory
(
MAX_PATH
,
cwd
);
env_copy
->
cwd
=
cwd
[
0
];
}
else
LocalFree
(
env_copy
);
FreeEnvironmentStringsW
(
env
);
}
/*****************************************************************************
...
...
@@ -935,6 +941,8 @@ static inline WCHAR *WCMD_strchrW(WCHAR *str, WCHAR ch)
* WCMD_endlocal
*
* endlocal pops the environment off a stack
* Note: When searching for '=', search from char position 1, to handle
* special internal environment variables =C:, =D: etc
*/
void
WCMD_endlocal
(
void
)
{
WCHAR
*
env
,
*
old
,
*
p
;
...
...
@@ -954,7 +962,7 @@ void WCMD_endlocal (void) {
len
=
0
;
while
(
old
[
len
])
{
n
=
lstrlenW
(
&
old
[
len
])
+
1
;
p
=
WCMD_strchrW
(
&
old
[
len
],
'='
);
p
=
WCMD_strchrW
(
&
old
[
len
]
+
1
,
'='
);
if
(
p
)
{
*
p
++
=
0
;
...
...
@@ -970,7 +978,7 @@ void WCMD_endlocal (void) {
len
=
0
;
while
(
env
[
len
])
{
n
=
lstrlenW
(
&
env
[
len
])
+
1
;
p
=
WCMD_strchrW
(
&
env
[
len
],
'='
);
p
=
WCMD_strchrW
(
&
env
[
len
]
+
1
,
'='
);
if
(
p
)
{
*
p
++
=
0
;
...
...
@@ -978,6 +986,18 @@ void WCMD_endlocal (void) {
}
len
+=
n
;
}
/* Restore current drive letter */
if
(
IsCharAlpha
(
temp
->
cwd
))
{
char
envvar
[
4
];
char
cwd
[
MAX_PATH
];
sprintf
(
envvar
,
"=%c:"
,
temp
->
cwd
);
if
(
GetEnvironmentVariable
(
envvar
,
cwd
,
MAX_PATH
))
{
WINE_TRACE
(
"Resetting cwd to %s
\n
"
,
cwd
);
SetCurrentDirectory
(
cwd
);
}
}
LocalFree
(
env
);
LocalFree
(
temp
);
}
...
...
programs/cmd/wcmd.h
View file @
86140e3f
...
...
@@ -101,7 +101,10 @@ typedef struct {
struct
env_stack
{
struct
env_stack
*
next
;
int
stackdepth
;
/* Only used for pushd and popd */
union
{
int
stackdepth
;
/* Only used for pushd and popd */
char
cwd
;
/* Only used for set/endlocal */
};
WCHAR
*
strings
;
};
...
...
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