mirror of
https://github.com/reactos/reactos.git
synced 2025-07-25 23:03:39 +00:00
[KERNEL32] - Remove unneded checks (these values can be received from table). - We have to insert UNICODE_NULL if it is the end of string or in string contains 0.
* Fixes 12 tests for kernel32:codepage svn path=/trunk/; revision=72734
This commit is contained in:
parent
a7c123661e
commit
be31da9af7
1 changed files with 28 additions and 21 deletions
|
@ -523,9 +523,6 @@ IntMultiByteToWideCharCP(UINT CodePage,
|
||||||
{
|
{
|
||||||
Char = *MultiByteString++;
|
Char = *MultiByteString++;
|
||||||
|
|
||||||
if (Char < 0x80)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
DBCSOffset = CodePageTable->DBCSOffsets[Char];
|
DBCSOffset = CodePageTable->DBCSOffsets[Char];
|
||||||
|
|
||||||
if (!DBCSOffset)
|
if (!DBCSOffset)
|
||||||
|
@ -542,12 +539,6 @@ IntMultiByteToWideCharCP(UINT CodePage,
|
||||||
{
|
{
|
||||||
Char = *MultiByteString++;
|
Char = *MultiByteString++;
|
||||||
|
|
||||||
if (Char < 0x80)
|
|
||||||
{
|
|
||||||
*WideCharString++ = Char;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DBCSOffset = CodePageTable->DBCSOffsets[Char];
|
DBCSOffset = CodePageTable->DBCSOffsets[Char];
|
||||||
|
|
||||||
if (!DBCSOffset)
|
if (!DBCSOffset)
|
||||||
|
@ -556,8 +547,19 @@ IntMultiByteToWideCharCP(UINT CodePage,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MultiByteString < MbsEnd)
|
if (MultiByteString == MbsEnd)
|
||||||
*WideCharString++ = CodePageTable->DBCSOffsets[DBCSOffset + *(PUCHAR)MultiByteString++];
|
{
|
||||||
|
*WideCharString++ = UNICODE_NULL;
|
||||||
|
}
|
||||||
|
else if (*MultiByteString == 0)
|
||||||
|
{
|
||||||
|
*WideCharString++ = UNICODE_NULL;
|
||||||
|
MultiByteString++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*WideCharString++ = CodePageTable->DBCSOffsets[DBCSOffset + (UCHAR)*MultiByteString++];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MultiByteString < MbsEnd)
|
if (MultiByteString < MbsEnd)
|
||||||
|
@ -902,41 +904,43 @@ IntWideCharToMultiByteCP(UINT CodePage,
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodePageTable = &CodePageEntry->CodePageTable;
|
CodePageTable = &CodePageEntry->CodePageTable;
|
||||||
|
|
||||||
|
|
||||||
/* Different handling for DBCS code pages. */
|
/* Different handling for DBCS code pages. */
|
||||||
if (CodePageTable->MaximumCharacterSize > 1)
|
if (CodePageTable->DBCSCodePage)
|
||||||
{
|
{
|
||||||
/* If Flags, DefaultChar or UsedDefaultChar were given, we have to do some more work */
|
/* If Flags, DefaultChar or UsedDefaultChar were given, we have to do some more work */
|
||||||
if(Flags || DefaultChar || UsedDefaultChar)
|
if (Flags || DefaultChar || UsedDefaultChar)
|
||||||
{
|
{
|
||||||
BOOL TempUsedDefaultChar;
|
BOOL TempUsedDefaultChar;
|
||||||
USHORT DefChar;
|
USHORT DefChar;
|
||||||
|
|
||||||
/* If UsedDefaultChar is not set, set it to a temporary value, so we don't have
|
/* If UsedDefaultChar is not set, set it to a temporary value, so we don't have
|
||||||
to check on every character */
|
to check on every character */
|
||||||
if(!UsedDefaultChar)
|
if (!UsedDefaultChar)
|
||||||
UsedDefaultChar = &TempUsedDefaultChar;
|
UsedDefaultChar = &TempUsedDefaultChar;
|
||||||
|
|
||||||
*UsedDefaultChar = FALSE;
|
*UsedDefaultChar = FALSE;
|
||||||
|
|
||||||
/* Use the CodePage's TransDefaultChar if none was given. Don't modify the DefaultChar pointer here. */
|
/* Use the CodePage's TransDefaultChar if none was given. Don't modify the DefaultChar pointer here. */
|
||||||
if(DefaultChar)
|
if (DefaultChar)
|
||||||
DefChar = DefaultChar[1] ? ((DefaultChar[0] << 8) | DefaultChar[1]) : DefaultChar[0];
|
DefChar = DefaultChar[1] ? ((DefaultChar[0] << 8) | DefaultChar[1]) : DefaultChar[0];
|
||||||
else
|
else
|
||||||
DefChar = CodePageTable->TransDefaultChar;
|
DefChar = CodePageTable->TransDefaultChar;
|
||||||
|
|
||||||
/* Does caller query for output buffer size? */
|
/* Does caller query for output buffer size? */
|
||||||
if(!MultiByteCount)
|
if (!MultiByteCount)
|
||||||
{
|
{
|
||||||
for(TempLength = 0; WideCharCount; WideCharCount--, WideCharString++, TempLength++)
|
for (TempLength = 0; WideCharCount; WideCharCount--, WideCharString++, TempLength++)
|
||||||
{
|
{
|
||||||
USHORT uChar;
|
USHORT uChar;
|
||||||
|
|
||||||
if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
|
if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
|
||||||
{
|
{
|
||||||
/* FIXME: Handle WC_COMPOSITECHECK */
|
/* FIXME: Handle WC_COMPOSITECHECK */
|
||||||
|
DPRINT1("WC_COMPOSITECHECK flag UNIMPLEMENTED\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
uChar = ((PUSHORT) CodePageTable->WideCharTable)[*WideCharString];
|
uChar = ((PUSHORT) CodePageTable->WideCharTable)[*WideCharString];
|
||||||
|
@ -957,15 +961,16 @@ IntWideCharToMultiByteCP(UINT CodePage,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the WideCharString to the MultiByteString and verify if the mapping is valid */
|
/* Convert the WideCharString to the MultiByteString and verify if the mapping is valid */
|
||||||
for(TempLength = MultiByteCount;
|
for (TempLength = MultiByteCount;
|
||||||
WideCharCount && TempLength;
|
WideCharCount && TempLength;
|
||||||
TempLength--, WideCharString++, WideCharCount--)
|
TempLength--, WideCharString++, WideCharCount--)
|
||||||
{
|
{
|
||||||
USHORT uChar;
|
USHORT uChar;
|
||||||
|
|
||||||
if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
|
if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
|
||||||
{
|
{
|
||||||
/* FIXME: Handle WC_COMPOSITECHECK */
|
/* FIXME: Handle WC_COMPOSITECHECK */
|
||||||
|
DPRINT1("WC_COMPOSITECHECK flag UNIMPLEMENTED\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
uChar = ((PUSHORT)CodePageTable->WideCharTable)[*WideCharString];
|
uChar = ((PUSHORT)CodePageTable->WideCharTable)[*WideCharString];
|
||||||
|
@ -1044,7 +1049,7 @@ IntWideCharToMultiByteCP(UINT CodePage,
|
||||||
|
|
||||||
return MultiByteCount - TempLength;
|
return MultiByteCount - TempLength;
|
||||||
}
|
}
|
||||||
else /* Not DBCS code page */
|
else /* SBCS code page */
|
||||||
{
|
{
|
||||||
INT nReturn;
|
INT nReturn;
|
||||||
|
|
||||||
|
@ -1070,6 +1075,7 @@ IntWideCharToMultiByteCP(UINT CodePage,
|
||||||
if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
|
if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
|
||||||
{
|
{
|
||||||
/* FIXME: Handle WC_COMPOSITECHECK */
|
/* FIXME: Handle WC_COMPOSITECHECK */
|
||||||
|
DPRINT1("WC_COMPOSITECHECK flag UNIMPLEMENTED\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*UsedDefaultChar)
|
if (!*UsedDefaultChar)
|
||||||
|
@ -1096,6 +1102,7 @@ IntWideCharToMultiByteCP(UINT CodePage,
|
||||||
if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
|
if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
|
||||||
{
|
{
|
||||||
/* FIXME: Handle WC_COMPOSITECHECK */
|
/* FIXME: Handle WC_COMPOSITECHECK */
|
||||||
|
DPRINT1("WC_COMPOSITECHECK flag UNIMPLEMENTED\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
*MultiByteString = ((PCHAR)CodePageTable->WideCharTable)[*WideCharString];
|
*MultiByteString = ((PCHAR)CodePageTable->WideCharTable)[*WideCharString];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue