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
54ba046a
Commit
54ba046a
authored
Feb 26, 2007
by
Jason Edmeades
Committed by
Alexandre Julliard
Feb 27, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd.exe: Allow special named env vars to be modified.
parent
b5186e17
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
64 deletions
+53
-64
wcmdmain.c
programs/cmd/wcmdmain.c
+53
-64
No files found.
programs/cmd/wcmdmain.c
View file @
54ba046a
...
...
@@ -304,7 +304,6 @@ int main (int argc, char *argv[])
void
WCMD_process_command
(
char
*
command
)
{
char
*
cmd
,
*
p
,
*
s
,
*
t
;
char
temp
[
MAXSTRING
];
int
status
,
i
;
DWORD
count
,
creationDisposition
;
HANDLE
h
;
...
...
@@ -322,12 +321,8 @@ void WCMD_process_command (char *command)
/* Additionally: */
/* Expand the DATE, TIME, CD, RANDOM and ERRORLEVEL special */
/* names allowing environment variable overrides */
/* FIXME: Winnt would replace %1%fred%1 with first parm, then */
/* contents of fred, then the digit 1. Would need to remove */
/* ExpandEnvStrings to achieve this */
/* NOTE: To support the %PATH:xxx% syntax, also need to do */
/* manual expansion of environment variables here */
/* NOTE: To support the %PATH:xxx% syntax, also perform */
/* manual expansion of environment variables here */
p
=
new_cmd
;
while
((
p
=
strchr
(
p
,
'%'
)))
{
...
...
@@ -356,61 +351,6 @@ void WCMD_process_command (char *command)
strcat
(
p
,
s
);
free
(
s
);
/* Handle DATE, TIME, ERRORLEVEL and CD replacements allowing */
/* override if existing env var called that name */
}
else
if
((
CompareString
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
(
p
+
1
),
11
,
"ERRORLEVEL%"
,
-
1
)
==
2
)
&&
(
GetEnvironmentVariable
(
"ERRORLEVEL"
,
temp
,
1
)
==
0
)
&&
(
GetLastError
()
==
ERROR_ENVVAR_NOT_FOUND
))
{
sprintf
(
temp
,
"%d"
,
errorlevel
);
s
=
strdup
(
p
+
12
);
strcpy
(
p
,
temp
);
strcat
(
p
,
s
);
}
else
if
((
CompareString
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
(
p
+
1
),
5
,
"DATE%"
,
-
1
)
==
2
)
&&
(
GetEnvironmentVariable
(
"DATE"
,
temp
,
1
)
==
0
)
&&
(
GetLastError
()
==
ERROR_ENVVAR_NOT_FOUND
))
{
GetDateFormat
(
LOCALE_USER_DEFAULT
,
DATE_SHORTDATE
,
NULL
,
NULL
,
temp
,
MAXSTRING
);
s
=
strdup
(
p
+
6
);
strcpy
(
p
,
temp
);
strcat
(
p
,
s
);
}
else
if
((
CompareString
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
(
p
+
1
),
5
,
"TIME%"
,
-
1
)
==
2
)
&&
(
GetEnvironmentVariable
(
"TIME"
,
temp
,
1
)
==
0
)
&&
(
GetLastError
()
==
ERROR_ENVVAR_NOT_FOUND
))
{
GetTimeFormat
(
LOCALE_USER_DEFAULT
,
TIME_NOSECONDS
,
NULL
,
NULL
,
temp
,
MAXSTRING
);
s
=
strdup
(
p
+
6
);
strcpy
(
p
,
temp
);
strcat
(
p
,
s
);
}
else
if
((
CompareString
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
(
p
+
1
),
3
,
"CD%"
,
-
1
)
==
2
)
&&
(
GetEnvironmentVariable
(
"CD"
,
temp
,
1
)
==
0
)
&&
(
GetLastError
()
==
ERROR_ENVVAR_NOT_FOUND
))
{
GetCurrentDirectory
(
MAXSTRING
,
temp
);
s
=
strdup
(
p
+
4
);
strcpy
(
p
,
temp
);
strcat
(
p
,
s
);
}
else
if
((
CompareString
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
(
p
+
1
),
7
,
"RANDOM%"
,
-
1
)
==
2
)
&&
(
GetEnvironmentVariable
(
"RANDOM"
,
temp
,
1
)
==
0
)
&&
(
GetLastError
()
==
ERROR_ENVVAR_NOT_FOUND
))
{
sprintf
(
temp
,
"%d"
,
rand
()
%
32768
);
s
=
strdup
(
p
+
8
);
strcpy
(
p
,
temp
);
strcat
(
p
,
s
);
}
else
{
p
=
WCMD_expand_envvar
(
p
);
}
...
...
@@ -1156,8 +1096,57 @@ static char *WCMD_expand_envvar(char *start) {
}
/* Expand to contents, if unchanged, return */
len
=
ExpandEnvironmentStrings
(
thisVar
,
thisVarContents
,
sizeof
(
thisVarContents
));
/* Handle DATE, TIME, ERRORLEVEL and CD replacements allowing */
/* override if existing env var called that name */
if
((
CompareString
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
thisVar
,
12
,
"%ERRORLEVEL%"
,
-
1
)
==
2
)
&&
(
GetEnvironmentVariable
(
"ERRORLEVEL"
,
thisVarContents
,
1
)
==
0
)
&&
(
GetLastError
()
==
ERROR_ENVVAR_NOT_FOUND
))
{
sprintf
(
thisVarContents
,
"%d"
,
errorlevel
);
len
=
strlen
(
thisVarContents
);
}
else
if
((
CompareString
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
thisVar
,
6
,
"%DATE%"
,
-
1
)
==
2
)
&&
(
GetEnvironmentVariable
(
"DATE"
,
thisVarContents
,
1
)
==
0
)
&&
(
GetLastError
()
==
ERROR_ENVVAR_NOT_FOUND
))
{
GetDateFormat
(
LOCALE_USER_DEFAULT
,
DATE_SHORTDATE
,
NULL
,
NULL
,
thisVarContents
,
MAXSTRING
);
len
=
strlen
(
thisVarContents
);
}
else
if
((
CompareString
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
thisVar
,
6
,
"%TIME%"
,
-
1
)
==
2
)
&&
(
GetEnvironmentVariable
(
"TIME"
,
thisVarContents
,
1
)
==
0
)
&&
(
GetLastError
()
==
ERROR_ENVVAR_NOT_FOUND
))
{
GetTimeFormat
(
LOCALE_USER_DEFAULT
,
TIME_NOSECONDS
,
NULL
,
NULL
,
thisVarContents
,
MAXSTRING
);
len
=
strlen
(
thisVarContents
);
}
else
if
((
CompareString
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
thisVar
,
4
,
"%CD%"
,
-
1
)
==
2
)
&&
(
GetEnvironmentVariable
(
"CD"
,
thisVarContents
,
1
)
==
0
)
&&
(
GetLastError
()
==
ERROR_ENVVAR_NOT_FOUND
))
{
GetCurrentDirectory
(
MAXSTRING
,
thisVarContents
);
len
=
strlen
(
thisVarContents
);
}
else
if
((
CompareString
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
thisVar
,
8
,
"%RANDOM%"
,
-
1
)
==
2
)
&&
(
GetEnvironmentVariable
(
"RANDOM"
,
thisVarContents
,
1
)
==
0
)
&&
(
GetLastError
()
==
ERROR_ENVVAR_NOT_FOUND
))
{
sprintf
(
thisVarContents
,
"%d"
,
rand
()
%
32768
);
len
=
strlen
(
thisVarContents
);
}
else
{
len
=
ExpandEnvironmentStrings
(
thisVar
,
thisVarContents
,
sizeof
(
thisVarContents
));
}
if
(
len
==
0
)
return
endOfVar
+
1
;
...
...
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