- 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:
Dmitry Chapyshev 2009-02-16 12:07:27 +00:00
parent 7e91e42329
commit 79d5681478

View file

@ -1559,54 +1559,54 @@ RtlLargeIntegerToChar(
IN ULONG Length, IN ULONG Length,
IN OUT PCHAR String) IN OUT PCHAR String)
{ {
ULONGLONG Val = Value->QuadPart;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
ULONG Radix; CHAR Buffer[65];
CHAR temp[65]; CHAR Digit;
ULONGLONG v = Value->QuadPart; ULONG Len;
ULONG i; PCHAR Pos;
PCHAR tp;
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;
tp = temp;
while (v || tp == temp)
{ {
i = v % Radix; return STATUS_INVALID_PARAMETER;
v = v / Radix;
if (i < 10)
*tp = i + '0';
else
*tp = i + 'A' - 10;
tp++;
} }
if ((ULONG)((ULONG_PTR)tp - (ULONG_PTR)temp) > Length) Pos = &Buffer[64];
*Pos = '\0';
do
{
Pos--;
Digit = Val % Base;
Val = Val / Base;
if (Digit < 10)
*Pos = '0' + Digit;
else
*Pos = 'A' + Digit - 10;
}
while (Val != 0L);
Len = &Buffer[64] - Pos;
if (Len > Length)
return STATUS_BUFFER_OVERFLOW; return STATUS_BUFFER_OVERFLOW;
//_SEH2_TRY _SEH2_TRY
{ {
sp = String; if (Len == Length)
while (tp > temp) RtlCopyMemory(String, Pos, Len);
*sp++ = *--tp; else
RtlCopyMemory(String, Pos, Len + 1);
if((ULONG)((ULONG_PTR)sp - (ULONG_PTR)String) < Length)
*sp = 0;
} }
#if 0
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{ {
/* Get the error code */ /* Get the error code */
Status = _SEH2_GetExceptionCode(); Status = _SEH2_GetExceptionCode();
} }
_SEH2_END; _SEH2_END;
#endif
return Status; return Status;
} }