Author: dgorbachev
Date: Sat Dec 13 09:42:56 2008
New Revision: 38042
URL:
http://svn.reactos.org/svn/reactos?rev=38042&view=rev
Log:
- Remove DBCSCodePage field from NLS_FILE_HEADER structure.
- Make RtlInitCodePageTable function slightly clearer.
- Fix IntIsLeadByte function (thanks to Gregor Schneider, bug #3944).
Modified:
trunk/reactos/dll/win32/kernel32/misc/nls.c
trunk/reactos/include/ndk/rtltypes.h
trunk/reactos/lib/rtl/nls.c
Modified: trunk/reactos/dll/win32/kernel32/misc/nls.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/nl…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/nls.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/nls.c [iso-8859-1] Sat Dec 13 09:42:56 2008
@@ -1067,13 +1067,13 @@
WINAPI
IntIsLeadByte(PCPTABLEINFO TableInfo, BYTE Byte)
{
- UINT LeadByteNo;
+ UINT i;
if (TableInfo->MaximumCharacterSize == 2)
{
- for (LeadByteNo = 0; LeadByteNo < MAXIMUM_LEADBYTES; LeadByteNo++)
- {
- if (TableInfo->LeadByte[LeadByteNo] == Byte)
+ for (i = 0; i < MAXIMUM_LEADBYTES && TableInfo->LeadByte[i]; i +=
2)
+ {
+ if (Byte >= TableInfo->LeadByte[i] && Byte <=
TableInfo->LeadByte[i+1])
return TRUE;
}
}
Modified: trunk/reactos/include/ndk/rtltypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtltypes.h?rev…
==============================================================================
--- trunk/reactos/include/ndk/rtltypes.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/rtltypes.h [iso-8859-1] Sat Dec 13 09:42:56 2008
@@ -1242,7 +1242,6 @@
USHORT UniDefaultChar;
USHORT TransDefaultChar;
USHORT TransUniDefaultChar;
- USHORT DBCSCodePage;
UCHAR LeadByte[MAXIMUM_LEADBYTES];
} NLS_FILE_HEADER, *PNLS_FILE_HEADER;
Modified: trunk/reactos/lib/rtl/nls.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/nls.c?rev=38042&am…
==============================================================================
--- trunk/reactos/lib/rtl/nls.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/nls.c [iso-8859-1] Sat Dec 13 09:42:56 2008
@@ -144,13 +144,12 @@
OUT PCPTABLEINFO CodePageTable)
{
PNLS_FILE_HEADER NlsFileHeader;
- PUSHORT Ptr;
- USHORT Offset;
DPRINT("RtlInitCodePageTable() called\n");
NlsFileHeader = (PNLS_FILE_HEADER)TableBase;
+ /* Copy header fields first */
CodePageTable->CodePage = NlsFileHeader->CodePage;
CodePageTable->MaximumCharacterSize = NlsFileHeader->MaximumCharacterSize;
CodePageTable->DefaultChar = NlsFileHeader->DefaultChar;
@@ -162,35 +161,30 @@
&NlsFileHeader->LeadByte,
MAXIMUM_LEADBYTES);
- /* Set Pointer to start of multi byte table */
- Ptr = (PUSHORT)((ULONG_PTR)TableBase + 2 * NlsFileHeader->HeaderSize);
-
- /* Get offset to the wide char table */
- Offset = (USHORT)(*Ptr++) + NlsFileHeader->HeaderSize + 1;
-
- /* Set pointer to the multi byte table */
- CodePageTable->MultiByteTable = Ptr;
-
- /* Skip ANSI and OEM table */
- Ptr += 256;
- if (*Ptr++)
- Ptr += 256;
-
- /* Set pointer to DBCS ranges */
- CodePageTable->DBCSRanges = (PUSHORT)Ptr;
-
- if (*Ptr > 0)
+ /* Offset to wide char table is after the header */
+ CodePageTable->WideCharTable = TableBase + NlsFileHeader->HeaderSize + 1 +
+ TableBase[NlsFileHeader->HeaderSize];
+
+ /* Then multibyte table (256 wchars) follows */
+ CodePageTable->MultiByteTable = TableBase + NlsFileHeader->HeaderSize + 1;
+
+ /* Check the presence of glyph table (256 wchars) */
+ if (!CodePageTable->MultiByteTable[256])
+ CodePageTable->DBCSRanges = CodePageTable->MultiByteTable + 256 + 1;
+ else
+ CodePageTable->DBCSRanges = CodePageTable->MultiByteTable + 256 + 1 + 256;
+
+ /* Is this double-byte code page? */
+ if (*CodePageTable->DBCSRanges)
{
CodePageTable->DBCSCodePage = 1;
- CodePageTable->DBCSOffsets = (PUSHORT)++Ptr;
+ CodePageTable->DBCSOffsets = CodePageTable->DBCSRanges + 1;
}
else
{
CodePageTable->DBCSCodePage = 0;
- CodePageTable->DBCSOffsets = 0;
- }
-
- CodePageTable->WideCharTable = (PVOID)((ULONG_PTR)TableBase + 2 * Offset);
+ CodePageTable->DBCSOffsets = NULL;
+ }
}