mirror of
https://github.com/reactos/reactos.git
synced 2024-10-15 21:56:40 +00:00
- Reimplement RtlLargeIntegerToChar (based on Wine code with my changes). It fixes all large_int Wine tests
svn path=/trunk/; revision=39622
This commit is contained in:
parent
7e91e42329
commit
79d5681478
|
@ -1559,56 +1559,56 @@ RtlLargeIntegerToChar(
|
||||||
IN ULONG Length,
|
IN ULONG Length,
|
||||||
IN OUT PCHAR String)
|
IN OUT PCHAR String)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
ULONGLONG Val = Value->QuadPart;
|
||||||
ULONG Radix;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
CHAR temp[65];
|
CHAR Buffer[65];
|
||||||
ULONGLONG v = Value->QuadPart;
|
CHAR Digit;
|
||||||
ULONG i;
|
ULONG Len;
|
||||||
PCHAR tp;
|
PCHAR Pos;
|
||||||
PCHAR sp;
|
|
||||||
|
|
||||||
Radix = Base;
|
if (Base == 0) Base = 10;
|
||||||
if (Radix == 0)
|
|
||||||
Radix = 10;
|
|
||||||
|
|
||||||
if ((Radix != 2) && (Radix != 8) &&
|
if ((Base != 2) && (Base != 8) &&
|
||||||
(Radix != 10) && (Radix != 16))
|
(Base != 10) && (Base != 16))
|
||||||
return STATUS_INVALID_PARAMETER;
|
{
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
tp = temp;
|
Pos = &Buffer[64];
|
||||||
while (v || tp == temp)
|
*Pos = '\0';
|
||||||
{
|
|
||||||
i = v % Radix;
|
|
||||||
v = v / Radix;
|
|
||||||
if (i < 10)
|
|
||||||
*tp = i + '0';
|
|
||||||
else
|
|
||||||
*tp = i + 'A' - 10;
|
|
||||||
tp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ULONG)((ULONG_PTR)tp - (ULONG_PTR)temp) > Length)
|
do
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
{
|
||||||
|
Pos--;
|
||||||
|
Digit = Val % Base;
|
||||||
|
Val = Val / Base;
|
||||||
|
if (Digit < 10)
|
||||||
|
*Pos = '0' + Digit;
|
||||||
|
else
|
||||||
|
*Pos = 'A' + Digit - 10;
|
||||||
|
}
|
||||||
|
while (Val != 0L);
|
||||||
|
|
||||||
//_SEH2_TRY
|
Len = &Buffer[64] - Pos;
|
||||||
{
|
|
||||||
sp = String;
|
|
||||||
while (tp > temp)
|
|
||||||
*sp++ = *--tp;
|
|
||||||
|
|
||||||
if((ULONG)((ULONG_PTR)sp - (ULONG_PTR)String) < Length)
|
if (Len > Length)
|
||||||
*sp = 0;
|
return STATUS_BUFFER_OVERFLOW;
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
||||||
{
|
|
||||||
/* Get the error code */
|
|
||||||
Status = _SEH2_GetExceptionCode();
|
|
||||||
}
|
|
||||||
_SEH2_END;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return Status;
|
_SEH2_TRY
|
||||||
|
{
|
||||||
|
if (Len == Length)
|
||||||
|
RtlCopyMemory(String, Pos, Len);
|
||||||
|
else
|
||||||
|
RtlCopyMemory(String, Pos, Len + 1);
|
||||||
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
/* Get the error code */
|
||||||
|
Status = _SEH2_GetExceptionCode();
|
||||||
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue