]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiLib/Console.c
Update copyright for files modified in this year
[mirror_edk2.git] / MdePkg / Library / UefiLib / Console.c
index d06b0a932dee45ceae2d5f0bdba2bd462f3513b9..9e842bae6a1b26afa655801f8c2ac62434286806 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
-  Mde UEFI library functions.\r
+  This module provide help function for displaying unicode string.\r
 \r
-  Copyright (c) 2006, Intel Corporation<BR>\r
+  Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
   All rights reserved. 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
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
-  Module Name:  Console.c\r
-\r
 **/\r
 \r
 \r
 \r
+\r
+#include "UefiLibInternal.h"\r
+\r
 typedef struct {\r
   CHAR16  WChar;\r
   UINT32  Width;\r
 } UNICODE_WIDTH_ENTRY;\r
 \r
-UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {\r
   //\r
   // General script area\r
   //\r
@@ -188,8 +189,10 @@ UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {
 };\r
 \r
 /**\r
-  This function computes and returns the width of the Unicode character \r
-  specified by UnicodeChar.\r
+  Retrieves the width of a Unicode character.\r
+\r
+  This function computes and returns the width of the Unicode character specified\r
+  by UnicodeChar.\r
 \r
   @param  UnicodeChar   A Unicode character.\r
 \r
@@ -204,10 +207,10 @@ GetGlyphWidth (
   IN CHAR16  UnicodeChar\r
   )\r
 {\r
-  UINTN               Index;\r
-  UINTN               Low;\r
-  UINTN               High;\r
-  UNICODE_WIDTH_ENTRY *Item;\r
+  UINTN                     Index;\r
+  UINTN                     Low;\r
+  UINTN                     High;\r
+  CONST UNICODE_WIDTH_ENTRY *Item;\r
 \r
   Item  = NULL;\r
   Low   = 0;\r
@@ -243,11 +246,15 @@ GetGlyphWidth (
 }\r
 \r
 /**\r
-  This function computes and returns the display length of\r
-  the Null-terminated Unicode string specified by String.\r
-  If String is NULL, then 0 is returned.\r
-  If any of the widths of the Unicode characters in String\r
-  can not be determined, then 0 is returned.\r
+  Computes the display length of a Null-terminated Unicode String.\r
+\r
+  This function computes and returns the display length of the Null-terminated Unicode\r
+  string specified by String.  If String is NULL then 0 is returned. If any of the widths\r
+  of the Unicode characters in String can not be determined, then 0 is returned. The display\r
+  width of String can be computed by summing the display widths of each Unicode character\r
+  in String.  Unicode characters that are narrow glyphs have a width of 1, and Unicode\r
+  characters that are width glyphs have a width of 2. \r
+  If String is not aligned on a 16-bit boundary, then ASSERT().\r
 \r
   @param  String      A pointer to a Null-terminated Unicode string.\r
 \r
@@ -263,6 +270,10 @@ UnicodeStringDisplayLength (
   UINTN      Length;\r
   UINTN      Width;\r
 \r
+  if (String == NULL) {\r
+    return 0;\r
+  }\r
+\r
   Length = 0;\r
   while (*String != 0) {\r
     Width = GetGlyphWidth (*String);\r