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
e3e2a5c0
Commit
e3e2a5c0
authored
Jan 11, 2008
by
Francois Gouget
Committed by
Alexandre Julliard
Jan 11, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add more ExpandEnvironmentStringsA() tests.
Document the observed ExpandEnvironmentStrings() behavior.
parent
d9a06b23
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
1 deletion
+66
-1
environ.c
dlls/kernel32/environ.c
+18
-1
environ.c
dlls/kernel32/tests/environ.c
+48
-0
No files found.
dlls/kernel32/environ.c
View file @
e3e2a5c0
...
...
@@ -305,6 +305,8 @@ BOOL WINAPI SetEnvironmentVariableW( LPCWSTR name, LPCWSTR value )
/***********************************************************************
* ExpandEnvironmentStringsA (KERNEL32.@)
*
* See ExpandEnvironmentStringsW.
*
* Note: overlapping buffers are not supported; this is how it should be.
* FIXME: return value is wrong for MBCS
*/
...
...
@@ -334,6 +336,21 @@ DWORD WINAPI ExpandEnvironmentStringsA( LPCSTR src, LPSTR dst, DWORD count )
/***********************************************************************
* ExpandEnvironmentStringsW (KERNEL32.@)
*
* Replaces references to environment variables of the form '%EnvVar%'
* by their value. If the environment variable does not exist, then the
* reference is left as is.
*
* PARAMS
* src [I] The string to be expanded.
* dst [O] The buffer in which to put the expanded string.
* len [I] The buffer size, in characters.
*
* RETURNS
* The number of characters copied into the buffer. If the buffer is
* too small, then the required buffer size, in characters including the
* trailing '\0', is returned.
* If the function fails for some other reason, then it returns 0.
*/
DWORD
WINAPI
ExpandEnvironmentStringsW
(
LPCWSTR
src
,
LPWSTR
dst
,
DWORD
len
)
{
...
...
@@ -346,7 +363,7 @@ DWORD WINAPI ExpandEnvironmentStringsW( LPCWSTR src, LPWSTR dst, DWORD len )
RtlInitUnicodeString
(
&
us_src
,
src
);
/* make sure we don't overflow maximum UNICODE_STRING size */
/* make sure we don't overflow
the
maximum UNICODE_STRING size */
if
(
len
>
0x7fff
)
len
=
0x7fff
;
...
...
dlls/kernel32/tests/environ.c
View file @
e3e2a5c0
...
...
@@ -217,9 +217,55 @@ static void test_GetSetEnvironmentVariableW(void)
static
void
test_ExpandEnvironmentStringsA
(
void
)
{
const
char
*
value
=
"Long long value"
;
const
char
*
not_an_env_var
=
"%NotAnEnvVar%"
;
char
buf
[
256
],
buf1
[
256
],
buf2
[
0x8000
];
DWORD
ret_size
,
ret_size1
;
SetEnvironmentVariableA
(
"EnvVar"
,
value
);
ret_size
=
ExpandEnvironmentStringsA
(
NULL
,
buf1
,
sizeof
(
buf1
));
ok
(
ret_size
==
1
||
ret_size
==
0
/* Win9x */
,
"ExpandEnvironmentStrings returned %d
\n
"
,
ret_size
);
/* Try to get the required buffer size 'the natural way' */
strcpy
(
buf
,
"%EnvVar%"
);
ret_size
=
ExpandEnvironmentStringsA
(
buf
,
NULL
,
0
);
/* v5.1.2600.2945 (XP SP2) returns len + 2 here! */
ok
(
ret_size
==
strlen
(
value
)
+
1
||
ret_size
==
strlen
(
value
)
+
2
||
ret_size
==
0
/* Win95 */
,
"ExpandEnvironmentStrings returned %d instead of %d
\n
"
,
ret_size
,
strlen
(
value
)
+
1
);
if
(
ret_size
==
strlen
(
value
)
+
2
)
trace
(
"ExpandEnvironmentStrings is buggy: it returned len + 2
\n
"
);
/* Again, side-stepping the Win95 bug */
ret_size
=
ExpandEnvironmentStringsA
(
buf
,
buf1
,
0
);
/* v5.1.2600.2945 (XP SP2) returns len + 2 here! */
ok
(
ret_size
==
strlen
(
value
)
+
1
||
ret_size
==
strlen
(
value
)
+
2
,
"ExpandEnvironmentStrings returned %d instead of %d
\n
"
,
ret_size
,
strlen
(
value
)
+
1
);
/* Try with a buffer that's too small */
ret_size
=
ExpandEnvironmentStringsA
(
buf
,
buf1
,
12
);
/* v5.1.2600.2945 (XP SP2) returns len + 2 here! */
ok
(
ret_size
==
strlen
(
value
)
+
1
||
ret_size
==
strlen
(
value
)
+
2
,
"ExpandEnvironmentStrings returned %d instead of %d
\n
"
,
ret_size
,
strlen
(
value
)
+
1
);
/* Try with a buffer of just the right size */
/* v5.1.2600.2945 (XP SP2) needs and returns len + 2 here! */
ret_size
=
ExpandEnvironmentStringsA
(
buf
,
buf1
,
ret_size
);
ok
(
ret_size
==
strlen
(
value
)
+
1
||
ret_size
==
strlen
(
value
)
+
2
,
"ExpandEnvironmentStrings returned %d instead of %d
\n
"
,
ret_size
,
strlen
(
value
)
+
1
);
ok
(
!
strcmp
(
buf1
,
value
),
"ExpandEnvironmentStrings returned [%s]
\n
"
,
buf1
);
/* Try with an unset environment variable */
strcpy
(
buf
,
not_an_env_var
);
ret_size
=
ExpandEnvironmentStringsA
(
buf
,
buf1
,
sizeof
(
buf1
));
ok
(
ret_size
==
strlen
(
not_an_env_var
)
+
1
,
"ExpandEnvironmentStrings returned %d instead of %d
\n
"
,
ret_size
,
strlen
(
value
)
+
1
);
ok
(
!
strcmp
(
buf1
,
not_an_env_var
),
"ExpandEnvironmentStrings returned [%s]
\n
"
,
buf1
);
/* test a large destination size */
strcpy
(
buf
,
"12345"
);
ret_size
=
ExpandEnvironmentStringsA
(
buf
,
buf2
,
sizeof
(
buf2
));
...
...
@@ -231,6 +277,8 @@ static void test_ExpandEnvironmentStringsA(void)
if
(
ERROR_ENVVAR_NOT_FOUND
==
GetLastError
())
return
;
ok
(
!
strcmp
(
buf
,
buf1
),
"ExpandEnvironmentStrings failed %s vs %s. ret_size = %d
\n
"
,
buf
,
buf1
,
ret_size
);
SetEnvironmentVariableA
(
"EnvVar"
,
NULL
);
}
static
BOOL
(
WINAPI
*
pGetComputerNameExA
)(
COMPUTER_NAME_FORMAT
,
LPSTR
,
LPDWORD
);
...
...
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