mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 01:25:56 +00:00
- RtlSetEnvironmentVariable: To delete a variable, it is necessary to pass a NULL pointer as the value; passing an empty string should create an empty variable. Remove Value->Length > 0 check.
- SetEnvironmentVariable(A|W): When given a NULL value, pass NULL to RtlSetEnvironmentVariable. - cmd_set: When given an empty value, pass NULL to SetEnvironmentVariable. svn path=/trunk/; revision=35672
This commit is contained in:
parent
a9431cc596
commit
fc46305c63
3 changed files with 35 additions and 16 deletions
|
@ -154,7 +154,7 @@ INT cmd_set (LPTSTR param)
|
||||||
}
|
}
|
||||||
|
|
||||||
*p++ = _T('\0');
|
*p++ = _T('\0');
|
||||||
if (!SetEnvironmentVariable(param, p))
|
if (!SetEnvironmentVariable(param, *p ? p : NULL))
|
||||||
{
|
{
|
||||||
nErrorLevel = 1;
|
nErrorLevel = 1;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -193,18 +193,27 @@ SetEnvironmentVariableA (
|
||||||
&VarName,
|
&VarName,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
|
||||||
RtlInitAnsiString (&VarValue,
|
if (lpValue)
|
||||||
(LPSTR)lpValue);
|
{
|
||||||
RtlAnsiStringToUnicodeString (&VarValueU,
|
RtlInitAnsiString (&VarValue,
|
||||||
&VarValue,
|
(LPSTR)lpValue);
|
||||||
TRUE);
|
RtlAnsiStringToUnicodeString (&VarValueU,
|
||||||
|
&VarValue,
|
||||||
|
TRUE);
|
||||||
|
|
||||||
Status = RtlSetEnvironmentVariable (NULL,
|
Status = RtlSetEnvironmentVariable (NULL,
|
||||||
&VarNameU,
|
&VarNameU,
|
||||||
&VarValueU);
|
&VarValueU);
|
||||||
|
|
||||||
|
RtlFreeUnicodeString (&VarValueU);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = RtlSetEnvironmentVariable (NULL,
|
||||||
|
&VarNameU,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
RtlFreeUnicodeString (&VarNameU);
|
RtlFreeUnicodeString (&VarNameU);
|
||||||
RtlFreeUnicodeString (&VarValueU);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -235,12 +244,22 @@ SetEnvironmentVariableW (
|
||||||
RtlInitUnicodeString (&VarName,
|
RtlInitUnicodeString (&VarName,
|
||||||
lpName);
|
lpName);
|
||||||
|
|
||||||
RtlInitUnicodeString (&VarValue,
|
if (lpValue)
|
||||||
lpValue);
|
{
|
||||||
|
RtlInitUnicodeString (&VarValue,
|
||||||
|
lpValue);
|
||||||
|
|
||||||
|
Status = RtlSetEnvironmentVariable (NULL,
|
||||||
|
&VarName,
|
||||||
|
&VarValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = RtlSetEnvironmentVariable (NULL,
|
||||||
|
&VarName,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
Status = RtlSetEnvironmentVariable (NULL,
|
|
||||||
&VarName,
|
|
||||||
&VarValue);
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus (Status);
|
SetLastErrorByStatus (Status);
|
||||||
|
|
|
@ -355,7 +355,7 @@ RtlSetEnvironmentVariable(PWSTR *Environment,
|
||||||
}
|
}
|
||||||
|
|
||||||
found:
|
found:
|
||||||
if (Value != NULL && Value->Length > 0)
|
if (Value != NULL)
|
||||||
{
|
{
|
||||||
hole_len = tail - hole;
|
hole_len = tail - hole;
|
||||||
/* calculate new environment size */
|
/* calculate new environment size */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue