mirror of
https://github.com/reactos/reactos.git
synced 2025-07-08 06:37:52 +00:00
Revert last patch.
svn path=/trunk/; revision=3186
This commit is contained in:
parent
8fc03ec0f6
commit
5e114ab271
1 changed files with 135 additions and 177 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: env.c,v 1.14 2002/07/05 17:23:05 ekohl Exp $
|
/* $Id: env.c,v 1.15 2002/07/06 17:38:06 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -123,7 +123,7 @@ RtlExpandEnvironmentStrings_U(PWSTR Environment,
|
||||||
int dst_max;
|
int dst_max;
|
||||||
int tail;
|
int tail;
|
||||||
|
|
||||||
DPRINT ("RtlExpandEnvironmentStrings_U %p %wZ %p %p\n",
|
DPRINT("RtlExpandEnvironmentStrings_U %p %wZ %p %p\n",
|
||||||
Environment, Source, Destination, Length);
|
Environment, Source, Destination, Length);
|
||||||
|
|
||||||
src_len = Source->Length / sizeof(WCHAR);
|
src_len = Source->Length / sizeof(WCHAR);
|
||||||
|
@ -180,14 +180,15 @@ copy:
|
||||||
dst_max--;
|
dst_max--;
|
||||||
src_len--;
|
src_len--;
|
||||||
}
|
}
|
||||||
|
|
||||||
Destination->Length = (d - Destination->Buffer) * sizeof(WCHAR);
|
Destination->Length = (d - Destination->Buffer) * sizeof(WCHAR);
|
||||||
if (Length != NULL)
|
if (Length != NULL)
|
||||||
*Length = Destination->Length;
|
*Length = Destination->Length;
|
||||||
if (dst_max)
|
if (dst_max)
|
||||||
Destination->Buffer[Destination->Length / sizeof(WCHAR)] = 0;
|
Destination->Buffer[Destination->Length / sizeof(WCHAR)] = 0;
|
||||||
|
|
||||||
DPRINT ("Destination %wZ\n", Destination);
|
DPRINT("Destination %wZ\n", Destination);
|
||||||
return Status;
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,7 +219,7 @@ RtlSetEnvironmentVariable(PWSTR *Environment,
|
||||||
PUNICODE_STRING Value)
|
PUNICODE_STRING Value)
|
||||||
{
|
{
|
||||||
MEMORY_BASIC_INFORMATION mbi;
|
MEMORY_BASIC_INFORMATION mbi;
|
||||||
UNICODE_STRING var, ExpandedValue;
|
UNICODE_STRING var;
|
||||||
int hole_len, new_len, env_len = 0;
|
int hole_len, new_len, env_len = 0;
|
||||||
WCHAR *new_env = 0, *env_end = 0, *wcs, *env, *val = 0, *tail = 0, *hole = 0;
|
WCHAR *new_env = 0, *env_end = 0, *wcs, *env, *val = 0, *tail = 0, *hole = 0;
|
||||||
PWSTR head = NULL;
|
PWSTR head = NULL;
|
||||||
|
@ -283,45 +284,11 @@ RtlSetEnvironmentVariable(PWSTR *Environment,
|
||||||
}
|
}
|
||||||
|
|
||||||
found:
|
found:
|
||||||
/* Perform inline replacement if Value references existing vars */
|
if (Value->Length > 0)
|
||||||
/* ex: SET PATH=C:\MinGW\Bin;%PATH% */
|
|
||||||
|
|
||||||
ExpandedValue.MaximumLength = (env_len + Value->Length) * 2 * sizeof(WCHAR);
|
|
||||||
ExpandedValue.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
||||||
0,
|
|
||||||
ExpandedValue.MaximumLength + 1);
|
|
||||||
if (ExpandedValue.Buffer == NULL)
|
|
||||||
{
|
|
||||||
if (Environment == NULL)
|
|
||||||
{
|
|
||||||
RtlReleasePebLock();
|
|
||||||
}
|
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
|
||||||
}
|
|
||||||
ExpandedValue.Length = 0;
|
|
||||||
ExpandedValue.Buffer[0] = (WCHAR)'\0';
|
|
||||||
|
|
||||||
Status = RtlExpandEnvironmentStrings_U(env,
|
|
||||||
Value,
|
|
||||||
&ExpandedValue,
|
|
||||||
NULL);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
RtlFreeHeap(RtlGetProcessHeap(),
|
|
||||||
0,
|
|
||||||
ExpandedValue.Buffer);
|
|
||||||
if (Environment == NULL)
|
|
||||||
{
|
|
||||||
RtlReleasePebLock();
|
|
||||||
}
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ExpandedValue.Length > 0)
|
|
||||||
{
|
{
|
||||||
hole_len = tail - hole;
|
hole_len = tail - hole;
|
||||||
/* calculate new environment size */
|
/* calculate new environment size */
|
||||||
new_size = ExpandedValue.Length + sizeof(WCHAR);
|
new_size = Value->Length + sizeof(WCHAR);
|
||||||
/* adding new variable */
|
/* adding new variable */
|
||||||
if (f)
|
if (f)
|
||||||
new_size += Name->Length + sizeof(WCHAR);
|
new_size += Name->Length + sizeof(WCHAR);
|
||||||
|
@ -345,9 +312,6 @@ found:
|
||||||
NULL);
|
NULL);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
RtlFreeHeap(RtlGetProcessHeap(),
|
|
||||||
0,
|
|
||||||
ExpandedValue.Buffer);
|
|
||||||
if (Environment == NULL)
|
if (Environment == NULL)
|
||||||
{
|
{
|
||||||
RtlReleasePebLock();
|
RtlReleasePebLock();
|
||||||
|
@ -367,9 +331,6 @@ found:
|
||||||
PAGE_READWRITE);
|
PAGE_READWRITE);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
RtlFreeHeap(RtlGetProcessHeap(),
|
|
||||||
0,
|
|
||||||
ExpandedValue.Buffer);
|
|
||||||
if (Environment == NULL)
|
if (Environment == NULL)
|
||||||
{
|
{
|
||||||
RtlReleasePebLock();
|
RtlReleasePebLock();
|
||||||
|
@ -428,9 +389,9 @@ found:
|
||||||
|
|
||||||
/* copy value */
|
/* copy value */
|
||||||
memmove(hole,
|
memmove(hole,
|
||||||
ExpandedValue.Buffer,
|
Value->Buffer,
|
||||||
ExpandedValue.Length);
|
Value->Length);
|
||||||
hole += ExpandedValue.Length / sizeof(WCHAR);
|
hole += Value->Length / sizeof(WCHAR);
|
||||||
*hole = 0;
|
*hole = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -448,9 +409,6 @@ found:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlFreeHeap(RtlGetProcessHeap(),
|
|
||||||
0,
|
|
||||||
ExpandedValue.Buffer);
|
|
||||||
if (Environment == NULL)
|
if (Environment == NULL)
|
||||||
{
|
{
|
||||||
RtlReleasePebLock();
|
RtlReleasePebLock();
|
||||||
|
@ -483,7 +441,7 @@ RtlQueryEnvironmentVariable_U(PWSTR Environment,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Environment == NULL)
|
if (Environment == NULL)
|
||||||
return STATUS_VARIABLE_NOT_FOUND;
|
return(STATUS_VARIABLE_NOT_FOUND);
|
||||||
|
|
||||||
Value->Length = 0;
|
Value->Length = 0;
|
||||||
if (SysEnvUsed == TRUE)
|
if (SysEnvUsed == TRUE)
|
||||||
|
@ -503,12 +461,12 @@ RtlQueryEnvironmentVariable_U(PWSTR Environment,
|
||||||
;
|
;
|
||||||
|
|
||||||
if (varlen == len &&
|
if (varlen == len &&
|
||||||
!_wcsnicmp (var, Name->Buffer, len))
|
!_wcsnicmp(var, Name->Buffer, len))
|
||||||
{
|
{
|
||||||
Value->Length = (wcs - val) * sizeof(WCHAR);
|
Value->Length = (wcs - val) * sizeof(WCHAR);
|
||||||
if (Value->Length < Value->MaximumLength)
|
if (Value->Length < Value->MaximumLength)
|
||||||
{
|
{
|
||||||
wcscpy (Value->Buffer, val);
|
wcscpy(Value->Buffer, val);
|
||||||
DPRINT("Value %S\n", val);
|
DPRINT("Value %S\n", val);
|
||||||
DPRINT("Return STATUS_SUCCESS\n");
|
DPRINT("Return STATUS_SUCCESS\n");
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
@ -520,19 +478,19 @@ RtlQueryEnvironmentVariable_U(PWSTR Environment,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SysEnvUsed == TRUE)
|
if (SysEnvUsed == TRUE)
|
||||||
RtlReleasePebLock ();
|
RtlReleasePebLock();
|
||||||
|
|
||||||
return Status;
|
return(Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wcs++;
|
wcs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SysEnvUsed == TRUE)
|
if (SysEnvUsed == TRUE)
|
||||||
RtlReleasePebLock ();
|
RtlReleasePebLock();
|
||||||
|
|
||||||
DPRINT("Return STATUS_VARIABLE_NOT_FOUND\n");
|
DPRINT("Return STATUS_VARIABLE_NOT_FOUND\n");
|
||||||
return STATUS_VARIABLE_NOT_FOUND;
|
return(STATUS_VARIABLE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue