]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c
MdeModulePkg/TerminalDxe: Fix IA32 VS2015x86 build break
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / Vtutf8.c
index acdb8ca6f5c7244d176922a866937e2ed27de1b2..586e8ab769d982ad455fd3a508b661f966618d89 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Implementation of translation upon VT-UTF8.\r
 \r
-Copyright (c) 2006, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -15,13 +15,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Terminal.h"\r
 \r
 /**\r
-  Translate all VT-UTF8 characters in the Raw FIFI into unicode characters, \r
+  Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,\r
   and insert them into Unicode FIFO.\r
 \r
   @param TerminalDevice          The terminal device.\r
 \r
-  @return None.\r
-\r
 **/\r
 VOID\r
 VTUTF8RawDataToUnicode (\r
@@ -38,7 +36,7 @@ VTUTF8RawDataToUnicode (
   // and translate it into unicode, then push\r
   // the unicode into unicode fifo, until the raw fifo is empty.\r
   //\r
-  while (!IsRawFiFoEmpty (TerminalDevice)) {\r
+  while (!IsRawFiFoEmpty (TerminalDevice) && !IsUnicodeFiFoFull (TerminalDevice)) {\r
 \r
     GetOneValidUtf8Char (TerminalDevice, &Utf8Char, &ValidBytes);\r
 \r
@@ -57,11 +55,9 @@ VTUTF8RawDataToUnicode (
 \r
   @param  Utf8Device          The terminal device.\r
   @param  Utf8Char            Returned valid VT-UTF8 characters set.\r
-  @param  ValidBytes          The count of returned VT-VTF8 characters. \r
+  @param  ValidBytes          The count of returned VT-VTF8 characters.\r
                               If ValidBytes is zero, no valid VT-UTF8 returned.\r
 \r
-  @retval None.\r
-\r
 **/\r
 VOID\r
 GetOneValidUtf8Char (\r
@@ -129,6 +125,9 @@ GetOneValidUtf8Char (
       break;\r
 \r
     case 2:\r
+      //\r
+      // two-byte utf8 char go on\r
+      //\r
       if ((Temp & 0xc0) == 0x80) {\r
 \r
         Utf8Char->Utf8_2[0] = Temp;\r
@@ -142,15 +141,21 @@ GetOneValidUtf8Char (
       break;\r
 \r
     case 3:\r
+      //\r
+      // three-byte utf8 char go on\r
+      //\r
       if ((Temp & 0xc0) == 0x80) {\r
-\r
-        Utf8Char->Utf8_3[2 - Index] = Temp;\r
-        Index++;\r
-        if (Index == 3) {\r
+        if (Index == 1) {\r
+          Utf8Char->Utf8_3[1] = Temp;\r
+          Index++;\r
+        } else {\r
+          Utf8Char->Utf8_3[0] = Temp;\r
           FetchFlag = FALSE;\r
         }\r
       } else {\r
-\r
+        //\r
+        // reset *ValidBytes and Index to zero, let valid utf8 char search restart\r
+        //\r
         *ValidBytes = 0;\r
         Index       = 0;\r
       }\r
@@ -168,7 +173,7 @@ GetOneValidUtf8Char (
   return ;\r
 }\r
 \r
-/** \r
+/**\r
   Translate VT-UTF8 characters into one Unicode character.\r
 \r
   UTF8 Encoding Table\r
@@ -180,9 +185,7 @@ GetOneValidUtf8Char (
 \r
   @param  Utf8Char         VT-UTF8 character set needs translating.\r
   @param  ValidBytes       The count of valid VT-UTF8 characters.\r
-  @param  UnicodeChar      Returned unicode character. \r
-  \r
-  @return None.\r
+  @param  UnicodeChar      Returned unicode character.\r
 \r
 **/\r
 VOID\r
@@ -243,7 +246,7 @@ Utf8ToUnicode (
   return ;\r
 }\r
 \r
-/** \r
+/**\r
   Translate one Unicode character into VT-UTF8 characters.\r
 \r
   UTF8 Encoding Table\r
@@ -257,8 +260,6 @@ Utf8ToUnicode (
   @param  Utf8Char         Return VT-UTF8 character set.\r
   @param  ValidBytes       The count of valid VT-UTF8 characters. If\r
                            ValidBytes is zero, no valid VT-UTF8 returned.\r
-  \r
-  @return None.\r
 \r
 **/\r
 VOID\r
@@ -309,8 +310,8 @@ UnicodeToUtf8 (
   Check if input string is valid VT-UTF8 string.\r
 \r
   @param  TerminalDevice          The terminal device.\r
-  @param  WString                 The input string.          \r
\r
+  @param  WString                 The input string.\r
+\r
   @retval EFI_SUCCESS             If all input characters are valid.\r
 \r
 **/\r