Revert last patch.

svn path=/trunk/; revision=3186
This commit is contained in:
Eric Kohl 2002-07-06 17:38:06 +00:00
parent 8fc03ec0f6
commit 5e114ab271

View file

@ -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
* PROJECT: ReactOS system libraries
@ -123,7 +123,7 @@ RtlExpandEnvironmentStrings_U(PWSTR Environment,
int dst_max;
int tail;
DPRINT ("RtlExpandEnvironmentStrings_U %p %wZ %p %p\n",
DPRINT("RtlExpandEnvironmentStrings_U %p %wZ %p %p\n",
Environment, Source, Destination, Length);
src_len = Source->Length / sizeof(WCHAR);
@ -180,14 +180,15 @@ copy:
dst_max--;
src_len--;
}
Destination->Length = (d - Destination->Buffer) * sizeof(WCHAR);
if (Length != NULL)
*Length = Destination->Length;
if (dst_max)
Destination->Buffer[Destination->Length / sizeof(WCHAR)] = 0;
DPRINT ("Destination %wZ\n", Destination);
return Status;
DPRINT("Destination %wZ\n", Destination);
return(Status);
}
@ -218,7 +219,7 @@ RtlSetEnvironmentVariable(PWSTR *Environment,
PUNICODE_STRING Value)
{
MEMORY_BASIC_INFORMATION mbi;
UNICODE_STRING var, ExpandedValue;
UNICODE_STRING var;
int hole_len, new_len, env_len = 0;
WCHAR *new_env = 0, *env_end = 0, *wcs, *env, *val = 0, *tail = 0, *hole = 0;
PWSTR head = NULL;
@ -283,45 +284,11 @@ RtlSetEnvironmentVariable(PWSTR *Environment,
}
found:
/* Perform inline replacement if Value references existing vars */
/* 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)
if (Value->Length > 0)
{
hole_len = tail - hole;
/* calculate new environment size */
new_size = ExpandedValue.Length + sizeof(WCHAR);
new_size = Value->Length + sizeof(WCHAR);
/* adding new variable */
if (f)
new_size += Name->Length + sizeof(WCHAR);
@ -345,9 +312,6 @@ found:
NULL);
if (!NT_SUCCESS(Status))
{
RtlFreeHeap(RtlGetProcessHeap(),
0,
ExpandedValue.Buffer);
if (Environment == NULL)
{
RtlReleasePebLock();
@ -367,9 +331,6 @@ found:
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
RtlFreeHeap(RtlGetProcessHeap(),
0,
ExpandedValue.Buffer);
if (Environment == NULL)
{
RtlReleasePebLock();
@ -428,9 +389,9 @@ found:
/* copy value */
memmove(hole,
ExpandedValue.Buffer,
ExpandedValue.Length);
hole += ExpandedValue.Length / sizeof(WCHAR);
Value->Buffer,
Value->Length);
hole += Value->Length / sizeof(WCHAR);
*hole = 0;
}
else
@ -448,9 +409,6 @@ found:
}
}
RtlFreeHeap(RtlGetProcessHeap(),
0,
ExpandedValue.Buffer);
if (Environment == NULL)
{
RtlReleasePebLock();
@ -483,7 +441,7 @@ RtlQueryEnvironmentVariable_U(PWSTR Environment,
}
if (Environment == NULL)
return STATUS_VARIABLE_NOT_FOUND;
return(STATUS_VARIABLE_NOT_FOUND);
Value->Length = 0;
if (SysEnvUsed == TRUE)
@ -503,12 +461,12 @@ RtlQueryEnvironmentVariable_U(PWSTR Environment,
;
if (varlen == len &&
!_wcsnicmp (var, Name->Buffer, len))
!_wcsnicmp(var, Name->Buffer, len))
{
Value->Length = (wcs - val) * sizeof(WCHAR);
if (Value->Length < Value->MaximumLength)
{
wcscpy (Value->Buffer, val);
wcscpy(Value->Buffer, val);
DPRINT("Value %S\n", val);
DPRINT("Return STATUS_SUCCESS\n");
Status = STATUS_SUCCESS;
@ -520,19 +478,19 @@ RtlQueryEnvironmentVariable_U(PWSTR Environment,
}
if (SysEnvUsed == TRUE)
RtlReleasePebLock ();
RtlReleasePebLock();
return Status;
return(Status);
}
}
wcs++;
}
if (SysEnvUsed == TRUE)
RtlReleasePebLock ();
RtlReleasePebLock();
DPRINT("Return STATUS_VARIABLE_NOT_FOUND\n");
return STATUS_VARIABLE_NOT_FOUND;
return(STATUS_VARIABLE_NOT_FOUND);
}
/* EOF */