Author: dchapyshev
Date: Sun Sep 18 21:10:07 2016
New Revision: 72734

URL: http://svn.reactos.org/svn/reactos?rev=72734&view=rev
Log:
[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

Modified:
    trunk/reactos/dll/win32/kernel32/winnls/string/nls.c

Modified: trunk/reactos/dll/win32/kernel32/winnls/string/nls.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/winnls/string/nls.c?rev=72734&r1=72733&r2=72734&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/winnls/string/nls.c        [iso-8859-1] 
(original)
+++ trunk/reactos/dll/win32/kernel32/winnls/string/nls.c        [iso-8859-1] 
Sun Sep 18 21:10:07 2016
@@ -523,9 +523,6 @@
             {
                 Char = *MultiByteString++;
 
-                if (Char < 0x80)
-                    continue;
-
                 DBCSOffset = CodePageTable->DBCSOffsets[Char];
 
                 if (!DBCSOffset)
@@ -542,12 +539,6 @@
         {
             Char = *MultiByteString++;
 
-            if (Char < 0x80)
-            {
-                *WideCharString++ = Char;
-                continue;
-            }
-
             DBCSOffset = CodePageTable->DBCSOffsets[Char];
 
             if (!DBCSOffset)
@@ -556,8 +547,19 @@
                 continue;
             }
 
-            if (MultiByteString < MbsEnd)
-                *WideCharString++ = CodePageTable->DBCSOffsets[DBCSOffset + 
*(PUCHAR)MultiByteString++];
+            if (MultiByteString == MbsEnd)
+            {
+                *WideCharString++ = UNICODE_NULL;
+            }
+            else if (*MultiByteString == 0)
+            {
+                *WideCharString++ = UNICODE_NULL;
+                MultiByteString++;
+            }
+            else
+            {
+                *WideCharString++ = CodePageTable->DBCSOffsets[DBCSOffset + 
(UCHAR)*MultiByteString++];
+            }
         }
 
         if (MultiByteString < MbsEnd)
@@ -902,41 +904,43 @@
         SetLastError(ERROR_INVALID_PARAMETER);
         return 0;
     }
+
     CodePageTable = &CodePageEntry->CodePageTable;
 
 
     /* 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 || UsedDefaultChar)
+        if (Flags || DefaultChar || UsedDefaultChar)
         {
             BOOL TempUsedDefaultChar;
             USHORT DefChar;
 
             /* If UsedDefaultChar is not set, set it to a temporary value, so 
we don't have
                to check on every character */
-            if(!UsedDefaultChar)
+            if (!UsedDefaultChar)
                 UsedDefaultChar = &TempUsedDefaultChar;
 
             *UsedDefaultChar = FALSE;
 
             /* 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];
             else
                 DefChar = CodePageTable->TransDefaultChar;
 
             /* Does caller query for output buffer size? */
-            if(!MultiByteCount)
-            {
-                for(TempLength = 0; WideCharCount; WideCharCount--, 
WideCharString++, TempLength++)
+            if (!MultiByteCount)
+            {
+                for (TempLength = 0; WideCharCount; WideCharCount--, 
WideCharString++, TempLength++)
                 {
                     USHORT uChar;
 
                     if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
                     {
                         /* FIXME: Handle WC_COMPOSITECHECK */
+                        DPRINT1("WC_COMPOSITECHECK flag UNIMPLEMENTED\n");
                     }
 
                     uChar = ((PUSHORT) 
CodePageTable->WideCharTable)[*WideCharString];
@@ -957,15 +961,16 @@
             }
 
             /* Convert the WideCharString to the MultiByteString and verify if 
the mapping is valid */
-            for(TempLength = MultiByteCount;
-                WideCharCount && TempLength;
-                TempLength--, WideCharString++, WideCharCount--)
+            for (TempLength = MultiByteCount;
+                 WideCharCount && TempLength;
+                 TempLength--, WideCharString++, WideCharCount--)
             {
                 USHORT uChar;
 
                 if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
                 {
                     /* FIXME: Handle WC_COMPOSITECHECK */
+                    DPRINT1("WC_COMPOSITECHECK flag UNIMPLEMENTED\n");
                 }
 
                 uChar = 
((PUSHORT)CodePageTable->WideCharTable)[*WideCharString];
@@ -1044,7 +1049,7 @@
 
         return MultiByteCount - TempLength;
     }
-    else /* Not DBCS code page */
+    else /* SBCS code page */
     {
         INT nReturn;
 
@@ -1070,6 +1075,7 @@
                     if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
                     {
                         /* FIXME: Handle WC_COMPOSITECHECK */
+                        DPRINT1("WC_COMPOSITECHECK flag UNIMPLEMENTED\n");
                     }
 
                     if (!*UsedDefaultChar)
@@ -1096,6 +1102,7 @@
                 if ((Flags & WC_COMPOSITECHECK) && WideCharCount > 1)
                 {
                     /* FIXME: Handle WC_COMPOSITECHECK */
+                    DPRINT1("WC_COMPOSITECHECK flag UNIMPLEMENTED\n");
                 }
 
                 *MultiByteString = 
((PCHAR)CodePageTable->WideCharTable)[*WideCharString];


Reply via email to