]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/String.c
Renamed
[mirror_edk2.git] / MdePkg / Library / BaseLib / String.c
index 909262e5872f78e81c4b947acfd7498157450894..83f0ff430b0817cb1a8e5c6131ab04e29e9ef452 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Unicode and ASCII string primatives.\r
 \r
-  Copyright (c) 2006 - 2007, 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
 \r
 **/\r
 \r
-//\r
-// Include common header file for this module.\r
-//\r
+#include "BaseLibInternals.h"\r
 \r
+#define QUOTIENT_MAX_UINTN_DIVIDED_BY_10      ((UINTN) -1 / 10)\r
+#define REMAINDER_MAX_UINTN_DIVIDED_BY_10    ((UINTN) -1 % 10)\r
 \r
-#include "BaseLibInternals.h"\r
+#define QUOTIENT_MAX_UINTN_DIVIDED_BY_16      ((UINTN) -1 / 16)\r
+#define REMAINDER_MAX_UINTN_DIVIDED_BY_16    ((UINTN) -1 % 16)\r
+\r
+#define QUOTIENT_MAX_UINT64_DIVIDED_BY_10      ((UINT64) -1 / 10)\r
+#define REMAINDER_MAX_UINT64_DIVIDED_BY_10    ((UINT64) -1 % 10)\r
+\r
+#define QUOTIENT_MAX_UINT64_DIVIDED_BY_16      ((UINT64) -1 / 16)\r
+#define REMAINDER_MAX_UINT64_DIVIDED_BY_16    ((UINT64) -1 % 16)\r
 \r
 /**\r
   Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
@@ -39,7 +46,7 @@
   @param  Destination Pointer to a Null-terminated Unicode string.\r
   @param  Source      Pointer to a Null-terminated Unicode string.\r
 \r
-  @return Destiantion\r
+  @return Destination pointing to the copied string.\r
 \r
 **/\r
 CHAR16 *\r
@@ -55,7 +62,7 @@ StrCpy (
   // Destination cannot be NULL\r
   //\r
   ASSERT (Destination != NULL);\r
-  ASSERT (((UINTN) Destination & 0x01) == 0);\r
+  ASSERT (((UINTN) Destination & BIT0) == 0);\r
 \r
   //\r
   // Destination and source cannot overlap\r
@@ -64,7 +71,7 @@ StrCpy (
   ASSERT ((UINTN)(Source - Destination) > StrLen (Source));\r
 \r
   ReturnValue = Destination;\r
-  while (*Source) {\r
+  while (*Source != 0) {\r
     *(Destination++) = *(Source++);\r
   }\r
   *Destination = 0;\r
@@ -97,7 +104,7 @@ StrCpy (
   @param  Source      Pointer to a Null-terminated Unicode string.\r
   @param  Length      Maximum number of Unicode characters to copy.\r
 \r
-  @return Destination\r
+  @return Destination pointing to the copied string.\r
 \r
 **/\r
 CHAR16 *\r
@@ -118,11 +125,10 @@ StrnCpy (
   // Destination cannot be NULL if Length is not zero\r
   //\r
   ASSERT (Destination != NULL);\r
-  ASSERT (((UINTN) Destination & 0x01) == 0);\r
+  ASSERT (((UINTN) Destination & BIT0) == 0);\r
 \r
   //\r
   // Destination and source cannot overlap\r
-  // Q: Does Source have to be NULL-terminated?\r
   //\r
   ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r
   ASSERT ((UINTN)(Source - Destination) >= Length);\r
@@ -164,7 +170,7 @@ StrLen (
   UINTN                             Length;\r
 \r
   ASSERT (String != NULL);\r
-  ASSERT (((UINTN) String & 0x01) == 0);\r
+  ASSERT (((UINTN) String & BIT0) == 0);\r
 \r
   for (Length = 0; *String != L'\0'; String++, Length++) {\r
     //\r
@@ -193,7 +199,7 @@ StrLen (
 \r
   @param  String  Pointer to a Null-terminated Unicode string.\r
 \r
-  @return The size of String.\r
+  @return The size in bytes of String.\r
 \r
 **/\r
 UINTN\r
@@ -229,8 +235,9 @@ StrSize (
   @param  FirstString   Pointer to a Null-terminated Unicode string.\r
   @param  SecondString  Pointer to a Null-terminated Unicode string.\r
 \r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
+  @retval 0      FirstString is identical to SecondString.\r
+  @return The first mismatched Unicode character in SecondString subtracted\r
+          from the first mismatched Unicode character in FirstString.\r
 \r
 **/\r
 INTN\r
@@ -279,8 +286,9 @@ StrCmp (
   @param  SecondString  Pointer to a Null-terminated Unicode string.\r
   @param  Length        Maximum number of Unicode characters to compare.\r
 \r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
+  @retval 0      FirstString is identical to SecondString.\r
+  @return The value returned is the first mismatched Unicode character in SecondString\r
+          subtracted from the first mismatched Unicode character in FirstString.\r
 \r
 **/\r
 INTN\r
@@ -340,7 +348,7 @@ StrnCmp (
   @param  Destination Pointer to a Null-terminated Unicode string.\r
   @param  Source      Pointer to a Null-terminated Unicode string.\r
 \r
-  @return Destination\r
+  @return Destination pointing to the concatenated Unicode string.\r
 \r
 **/\r
 CHAR16 *\r
@@ -394,7 +402,7 @@ StrCat (
   @param  Length      Maximum number of Unicode characters to concatenate from\r
                       Source.\r
 \r
-  @return Destination\r
+  @return Destination pointing to the concatenated Unicode string.\r
 \r
 **/\r
 CHAR16 *\r
@@ -434,11 +442,11 @@ StrnCat (
   or String contains more than PcdMaximumUnicodeStringLength Unicode \r
   characters not including the Null-terminator, then ASSERT().\r
 \r
-  @param  String                  Pointer to a Null-terminated Unicode string.\r
+  @param  String        Pointer to a Null-terminated Unicode string.\r
   @param  SearchString  Pointer to a Null-terminated Unicode string to search for.\r
 \r
-  @retval NULL            If the SearchString does not appear in String.\r
-  @retval !NULL           If there is a match.\r
+  @retval NULL          If the SearchString does not appear in String.\r
+  @return Pointer to the matching sub-string.\r
 \r
 **/\r
 CHAR16 *\r
@@ -493,15 +501,14 @@ StrStr (
   decimal character. The valid decimal character is from\r
   L'0' to L'9'.\r
 \r
-\r
   @param  Char  The character to check against.\r
 \r
   @retval TRUE  If the Char is a decmial character.\r
-  @retval FALSE Otherwise.\r
+  @retval FALSE If the Char is not a decmial character.\r
 \r
 **/\r
-STATIC\r
 BOOLEAN\r
+EFIAPI\r
 InternalIsDecimalDigitCharacter (\r
   IN      CHAR16                    Char\r
   )\r
@@ -514,19 +521,18 @@ InternalIsDecimalDigitCharacter (
   it maps to a valid small-case ASCII character.\r
 \r
   This internal function only deal with Unicode character\r
-  which maps to a valid small-case ASII character, i.e.\r
+  which maps to a valid small-case ASCII character, i.e.\r
   L'a' to L'z'. For other Unicode character, the input character\r
   is returned directly.\r
 \r
-\r
   @param  Char  The character to convert.\r
 \r
   @retval LowerCharacter   If the Char is with range L'a' to L'z'.\r
   @retval Unchanged        Otherwise.\r
 \r
 **/\r
-STATIC\r
 CHAR16\r
+EFIAPI\r
 InternalCharToUpper (\r
   IN      CHAR16                    Char\r
   )\r
@@ -548,11 +554,11 @@ InternalCharToUpper (
 \r
   @param  Char  The character to convert.\r
 \r
-  @retval UINTN   The numerical value converted.\r
+  @return The numerical value converted.\r
 \r
 **/\r
-STATIC\r
 UINTN\r
+EFIAPI\r
 InternalHexCharToUintn (\r
   IN      CHAR16                    Char\r
   )\r
@@ -575,11 +581,11 @@ InternalHexCharToUintn (
   @param  Char  The character to check against.\r
 \r
   @retval TRUE  If the Char is a hexadecmial character.\r
-  @retval FALSE Otherwise.\r
+  @retval FALSE If the Char is not a hexadecmial character.\r
 \r
 **/\r
-STATIC\r
 BOOLEAN\r
+EFIAPI\r
 InternalIsHexaDecimalDigitCharacter (\r
   IN      CHAR16                    Char\r
   )\r
@@ -621,7 +627,7 @@ InternalIsHexaDecimalDigitCharacter (
 \r
   @param  String                Pointer to a Null-terminated Unicode string.\r
 \r
-  @retval UINTN           \r
+  @return The value of type UINTN converted.\r
 \r
 **/\r
 UINTN\r
@@ -659,9 +665,9 @@ StrDecimalToUintn (
     // If the number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_10) ||\r
-      ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_10) &&\r
-      (*String - L'0') <= REMINDER_MAX_UINTN_DIVIDED_BY_10)\r
+    ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_10) ||\r
+      ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_10) &&\r
+      (*String - L'0') <= REMAINDER_MAX_UINTN_DIVIDED_BY_10)\r
       );\r
 \r
     Result = Result * 10 + (*String - L'0');\r
@@ -703,7 +709,7 @@ StrDecimalToUintn (
 \r
   @param  String                Pointer to a Null-terminated Unicode string.\r
 \r
-  @retval UINT64           \r
+  @return The value of type UINT64 converted.\r
 \r
 **/\r
 UINT64\r
@@ -741,9 +747,9 @@ StrDecimalToUint64 (
     // If the number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_10) || \r
-      ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_10) && \r
-      (*String - L'0') <= REMINDER_MAX_UINT64_DIVIDED_BY_10)\r
+    ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_10) || \r
+      ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_10) && \r
+      (*String - L'0') <= REMAINDER_MAX_UINT64_DIVIDED_BY_10)\r
       );\r
 \r
     Result = MultU64x32 (Result, 10) + (*String - L'0');\r
@@ -785,7 +791,7 @@ StrDecimalToUint64 (
 \r
   @param  String                Pointer to a Null-terminated Unicode string.\r
 \r
-  @retval UINTN\r
+  @return The value of type UINTN converted.\r
 \r
 **/\r
 UINTN\r
@@ -817,8 +823,8 @@ StrHexToUintn (
   }\r
 \r
   if (InternalCharToUpper (*String) == L'X') {\r
-    ASSERT (*(String - 1)  == L'0');\r
-    if (*(String - 1)  != L'0') {\r
+    ASSERT (*(String - 1) == L'0');\r
+    if (*(String - 1) != L'0') {\r
       return 0;\r
     }\r
     //\r
@@ -834,9 +840,9 @@ StrHexToUintn (
     // If the Hex Number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_16) ||\r
-      ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_16) && \r
-      (InternalHexCharToUintn (*String) <= REMINDER_MAX_UINTN_DIVIDED_BY_16))\r
+    ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_16) ||\r
+      ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_16) && \r
+      (InternalHexCharToUintn (*String) <= REMAINDER_MAX_UINTN_DIVIDED_BY_16))\r
       );\r
 \r
     Result = (Result << 4) + InternalHexCharToUintn (*String);\r
@@ -879,7 +885,7 @@ StrHexToUintn (
 \r
   @param  String                Pointer to a Null-terminated Unicode string.\r
 \r
-  @retval UINT64\r
+  @return The value of type UINT64 converted.\r
 \r
 **/\r
 UINT64\r
@@ -911,8 +917,8 @@ StrHexToUint64 (
   }\r
 \r
   if (InternalCharToUpper (*String) == L'X') {\r
-    ASSERT (*(String - 1)  == L'0');\r
-    if (*(String - 1)  != L'0') {\r
+    ASSERT (*(String - 1) == L'0');\r
+    if (*(String - 1) != L'0') {\r
       return 0;\r
     }\r
     //\r
@@ -928,9 +934,9 @@ StrHexToUint64 (
     // If the Hex Number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_16)|| \r
-      ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_16) && \r
-      (InternalHexCharToUintn (*String) <= REMINDER_MAX_UINT64_DIVIDED_BY_16))\r
+    ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_16)|| \r
+      ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_16) && \r
+      (InternalHexCharToUintn (*String) <= REMAINDER_MAX_UINT64_DIVIDED_BY_16))\r
       );\r
 \r
     Result = LShiftU64 (Result, 4);\r
@@ -951,11 +957,11 @@ StrHexToUint64 (
   @param  Char  The character to check against.\r
 \r
   @retval TRUE  If the Char is a decmial character.\r
-  @retval FALSE Otherwise.\r
+  @retval FALSE If the Char is not a decmial character.\r
 \r
 **/\r
-STATIC\r
 BOOLEAN\r
+EFIAPI\r
 InternalAsciiIsDecimalDigitCharacter (\r
   IN      CHAR8                     Char\r
   )\r
@@ -974,11 +980,11 @@ InternalAsciiIsDecimalDigitCharacter (
   @param  Char  The character to check against.\r
 \r
   @retval TRUE  If the Char is a hexadecmial character.\r
-  @retval FALSE Otherwise.\r
+  @retval FALSE If the Char is not a hexadecmial character.\r
 \r
 **/\r
-STATIC\r
 BOOLEAN\r
+EFIAPI\r
 InternalAsciiIsHexaDecimalDigitCharacter (\r
   IN      CHAR8                    Char\r
   )\r
@@ -1019,7 +1025,7 @@ InternalAsciiIsHexaDecimalDigitCharacter (
   @param  Source        Pointer to a Null-terminated Unicode string.\r
   @param  Destination   Pointer to a Null-terminated ASCII string.\r
 \r
-  @return Destination\r
+  @return Destination pointing to the converted ASCII string.\r
 \r
 **/\r
 CHAR8 *\r
@@ -1086,7 +1092,7 @@ UnicodeStrToAsciiStr (
   @param  Destination Pointer to a Null-terminated ASCII string.\r
   @param  Source      Pointer to a Null-terminated ASCII string.\r
 \r
-  @return Destination\r
+  @return Destination pointing to the copied string.\r
 \r
 **/\r
 CHAR8 *\r
@@ -1110,7 +1116,7 @@ AsciiStrCpy (
   ASSERT ((UINTN)(Source - Destination) > AsciiStrLen (Source));\r
 \r
   ReturnValue = Destination;\r
-  while (*Source) {\r
+  while (*Source != 0) {\r
     *(Destination++) = *(Source++);\r
   }\r
   *Destination = 0;\r
@@ -1140,7 +1146,7 @@ AsciiStrCpy (
   @param  Source      Pointer to a Null-terminated ASCII string.\r
   @param  Length      Maximum number of ASCII characters to copy.\r
 \r
-  @return Destination\r
+  @return Destination pointing to the copied string.\r
 \r
 **/\r
 CHAR8 *\r
@@ -1170,7 +1176,7 @@ AsciiStrnCpy (
 \r
   ReturnValue = Destination;\r
 \r
-  while (*Source && Length > 0) {\r
+  while (*Source != 0 && Length > 0) {\r
     *(Destination++) = *(Source++);\r
     Length--;\r
   }\r
@@ -1265,8 +1271,9 @@ AsciiStrSize (
   @param  FirstString   Pointer to a Null-terminated ASCII string.\r
   @param  SecondString  Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
+  @retval 0      FirstString is identical to SecondString.\r
+  @return The first mismatched ASCII character in SecondString subtracted\r
+          from the first mismatched ASCII character in FirstString.\r
 \r
 **/\r
 INTN\r
@@ -1291,20 +1298,20 @@ AsciiStrCmp (
 }\r
 \r
 /**\r
-  Converts a lowercase Ascii character to upper one\r
+  Converts a lowercase Ascii character to upper one.\r
 \r
   If Chr is lowercase Ascii character, then converts it to upper one.\r
 \r
   If Value >= 0xA0, then ASSERT().\r
   If (Value & 0x0F) >= 0x0A, then ASSERT().\r
 \r
-  @param  chr   one Ascii character\r
+  @param  Chr   one Ascii character\r
 \r
   @return The uppercase value of Ascii character \r
 \r
 **/\r
-STATIC\r
 CHAR8\r
+EFIAPI\r
 AsciiToUpper (\r
   IN      CHAR8                     Chr\r
   )\r
@@ -1322,11 +1329,11 @@ AsciiToUpper (
 \r
   @param  Char  The character to convert.\r
 \r
-  @retval UINTN   The numerical value converted.\r
+  @return The numerical value converted.\r
 \r
 **/\r
-STATIC\r
 UINTN\r
+EFIAPI\r
 InternalAsciiHexCharToUintn (\r
   IN      CHAR8                    Char\r
   )\r
@@ -1362,10 +1369,10 @@ InternalAsciiHexCharToUintn (
   @param  FirstString   Pointer to a Null-terminated ASCII string.\r
   @param  SecondString  Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval 0   FirstString is identical to SecondString using case insensitive\r
-              comparisons.\r
-  @retval !=0 FirstString is not identical to SecondString using case\r
-              insensitive comparisons.\r
+  @retval 0      FirstString is identical to SecondString using case insensitive\r
+                 comparisons.\r
+  @return The first mismatched lower case ASCII character in SecondString subtracted\r
+          from the first mismatched lower case ASCII character in FirstString.\r
 \r
 **/\r
 INTN\r
@@ -1420,8 +1427,9 @@ AsciiStriCmp (
   @param  SecondString  Pointer to a Null-terminated ASCII string.\r
   @param  Length        Maximum number of ASCII characters to compare.\r
                         \r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
+  @retval 0      FirstString is identical to SecondString.\r
+  @return The first mismatched ASCII character in SecondString subtracted from the\r
+          first mismatched ASCII character in FirstString.\r
 \r
 **/\r
 INTN\r
@@ -1476,7 +1484,7 @@ AsciiStrnCmp (
   @param  Destination Pointer to a Null-terminated ASCII string.\r
   @param  Source      Pointer to a Null-terminated ASCII string.\r
 \r
-  @return Destination\r
+  @return Destination pointing to the concatenated ASCII string.\r
 \r
 **/\r
 CHAR8 *\r
@@ -1527,7 +1535,7 @@ AsciiStrCat (
   @param  Length      Maximum number of ASCII characters to concatenate from\r
                       Source.\r
 \r
-  @return Destination\r
+  @return Destination pointing to the concatenated ASCII string.\r
 \r
 **/\r
 CHAR8 *\r
@@ -1568,7 +1576,7 @@ AsciiStrnCat (
   @param  SearchString    Pointer to a Null-terminated ASCII string to search for.\r
 \r
   @retval NULL            If the SearchString does not appear in String.\r
-  @retval !NULL           If there is a match.\r
+  @return Pointer to the matching sub-string.\r
 \r
 **/\r
 CHAR8 *\r
@@ -1643,7 +1651,7 @@ AsciiStrStr (
 \r
   @param  String                Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval UINTN           \r
+  @return The value of type UINTN converted.\r
 \r
 **/\r
 UINTN\r
@@ -1662,7 +1670,7 @@ AsciiStrDecimalToUintn (
   //\r
   // Ignore the pad spaces (space or tab)\r
   //\r
-  while ((*String == ' ') || (*String == '\t')) {\r
+  while ((*String == ' ') || (*String == '\t' )) {\r
     String++;\r
   }\r
 \r
@@ -1680,9 +1688,9 @@ AsciiStrDecimalToUintn (
     // If the number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_10) ||\r
-      ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_10) && \r
-      (*String - '0') <= REMINDER_MAX_UINTN_DIVIDED_BY_10)\r
+    ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_10) ||\r
+      ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_10) && \r
+      (*String - '0') <= REMAINDER_MAX_UINTN_DIVIDED_BY_10)\r
       );\r
 \r
     Result = Result * 10 + (*String - '0');\r
@@ -1720,7 +1728,7 @@ AsciiStrDecimalToUintn (
 \r
   @param  String                Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval UINT64           \r
+  @return The value of type UINT64 converted.\r
 \r
 **/\r
 UINT64\r
@@ -1739,7 +1747,7 @@ AsciiStrDecimalToUint64 (
   //\r
   // Ignore the pad spaces (space or tab)\r
   //\r
-  while ((*String == ' ') || (*String == '\t')) {\r
+  while ((*String == ' ') || (*String == '\t' )) {\r
     String++;\r
   }\r
 \r
@@ -1757,9 +1765,9 @@ AsciiStrDecimalToUint64 (
     // If the number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_10) || \r
-      ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_10) && \r
-      (*String - '0') <= REMINDER_MAX_UINT64_DIVIDED_BY_10)\r
+    ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_10) || \r
+      ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_10) && \r
+      (*String - '0') <= REMAINDER_MAX_UINT64_DIVIDED_BY_10)\r
       );\r
 \r
     Result = MultU64x32 (Result, 10) + (*String - '0');\r
@@ -1800,7 +1808,7 @@ AsciiStrDecimalToUint64 (
 \r
   @param  String                Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval UINTN\r
+  @return The value of type UINTN converted.\r
 \r
 **/\r
 UINTN\r
@@ -1819,7 +1827,7 @@ AsciiStrHexToUintn (
   //\r
   // Ignore the pad spaces (space or tab) \r
   //\r
-  while ((*String == ' ') || (*String == '\t')) {\r
+  while ((*String == ' ') || (*String == '\t' )) {\r
     String++;\r
   }\r
 \r
@@ -1831,8 +1839,8 @@ AsciiStrHexToUintn (
   }\r
 \r
   if (AsciiToUpper (*String) == 'X') {\r
-    ASSERT (*(String - 1)  == '0');\r
-    if (*(String - 1)  != '0') {\r
+    ASSERT (*(String - 1) == '0');\r
+    if (*(String - 1) != '0') {\r
       return 0;\r
     }\r
     //\r
@@ -1848,9 +1856,9 @@ AsciiStrHexToUintn (
     // If the Hex Number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-     ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_16) ||\r
-       ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_16) && \r
-       (InternalAsciiHexCharToUintn (*String) <= REMINDER_MAX_UINTN_DIVIDED_BY_16))\r
+     ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_16) ||\r
+       ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_16) && \r
+       (InternalAsciiHexCharToUintn (*String) <= REMAINDER_MAX_UINTN_DIVIDED_BY_16))\r
        );\r
 \r
     Result = (Result << 4) + InternalAsciiHexCharToUintn (*String);\r
@@ -1892,7 +1900,7 @@ AsciiStrHexToUintn (
 \r
   @param  String                Pointer to a Null-terminated ASCII string.\r
 \r
-  @retval UINT64\r
+  @return The value of type UINT64 converted.\r
 \r
 **/\r
 UINT64\r
@@ -1914,7 +1922,7 @@ AsciiStrHexToUint64 (
   //\r
   // Ignore the pad spaces (space or tab) \r
   //\r
-  while ((*String == ' ') || (*String == '\t')) {\r
+  while ((*String == ' ') || (*String == '\t' )) {\r
     String++;\r
   }\r
 \r
@@ -1926,8 +1934,8 @@ AsciiStrHexToUint64 (
   }\r
 \r
   if (AsciiToUpper (*String) == 'X') {\r
-    ASSERT (*(String - 1)  == '0');\r
-    if (*(String - 1)  != '0') {\r
+    ASSERT (*(String - 1) == '0');\r
+    if (*(String - 1) != '0') {\r
       return 0;\r
     }\r
     //\r
@@ -1943,9 +1951,9 @@ AsciiStrHexToUint64 (
     // If the Hex Number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_16) ||\r
-      ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_16) && \r
-      (InternalAsciiHexCharToUintn (*String) <= REMINDER_MAX_UINT64_DIVIDED_BY_16))\r
+    ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_16) ||\r
+      ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_16) && \r
+      (InternalAsciiHexCharToUintn (*String) <= REMAINDER_MAX_UINT64_DIVIDED_BY_16))\r
       );\r
 \r
     Result = LShiftU64 (Result, 4);\r
@@ -1981,7 +1989,7 @@ AsciiStrHexToUint64 (
   @param  Source        Pointer to a Null-terminated ASCII string.\r
   @param  Destination   Pointer to a Null-terminated Unicode string.\r
 \r
-  @return Destination\r
+  @return Destination pointing to the converted Unicode string.\r
 \r
 **/\r
 CHAR16 *\r
@@ -2034,7 +2042,7 @@ AsciiStrToUnicodeStr (
 \r
   @param  Value The 8-bit value to convert to BCD. Range 0..99.\r
 \r
-  @return The BCD value\r
+  @return The BCD value converted.\r
 \r
 **/\r
 UINT8\r
@@ -2058,7 +2066,7 @@ DecimalToBcd8 (
 \r
   @param  Value The 8-bit BCD value to convert to an 8-bit value.\r
 \r
-  @return The 8-bit value is returned.\r
+  @return The 8-bit decimal value converted.\r
 \r
 **/\r
 UINT8\r
@@ -2084,7 +2092,7 @@ BcdToDecimal8 (
 \r
   @param Nibble     The nibble which is in the low 4 bits of the input byte.\r
 \r
-  @retval  CHAR16   The Unicode hexadecimal character.\r
+  @return   The Unicode hexadecimal character.\r
   \r
 **/\r
 CHAR16\r
@@ -2103,7 +2111,7 @@ NibbleToHexChar (
 /** \r
   Convert binary buffer to a Unicode String in a specified sequence. \r
 \r
-  This function converts bytes in the binary Buffer Buf to a Unicode String Str. \r
+  This function converts bytes in the memory block pointed by Buffer to a Unicode String Str. \r
   Each byte will be represented by two Unicode characters. For example, byte 0xA1 will \r
   be converted into two Unicode character L'A' and L'1'. In the output String, the Unicode Character \r
   for the Most Significant Nibble will be put before the Unicode Character for the Least Significant\r
@@ -2115,18 +2123,17 @@ NibbleToHexChar (
   the input buffer for a 64-bits unsigned integrer 0x12345678abcdef1234 will be converted to\r
   a Unicode string equal to L"12345678abcdef1234".\r
 \r
-  @param String                        On input, String is pointed to the buffer allocated for the convertion.\r
-  @param StringLen                     The Length of String buffer to hold the output String. The length must include the tailing '\0' character.\r
-                                       The StringLen required to convert a N bytes Buffer will be a least equal to or greater \r
-                                       than 2*N + 1.\r
-  @param Buffer                        The pointer to a input buffer.\r
-  @param BufferSizeInBytes             Lenth in bytes of the input buffer.\r
+  @param String                 Pointer to the buffer allocated for the convertion.\r
+  @param StringLen              On input: Pointer to length in bytes of buffer to hold the Unicode string.\r
+                                On output:If return EFI_SUCCESS, pointer to length of Unicode string converted.\r
+                                          If return EFI_BUFFER_TOO_SMALL, pointer to length of string buffer desired.\r
+  @param Buffer                 The pointer to a input buffer.\r
+  @param BufferSizeInBytes      Lenth in bytes of the input buffer.\r
   \r
-\r
-  @retval  EFI_SUCCESS                 The convertion is successfull. All bytes in Buffer has been convert to the corresponding\r
-                                       Unicode character and placed into the right place in String.\r
-  @retval  EFI_BUFFER_TOO_SMALL        StringSizeInBytes is smaller than 2 * N + 1the number of bytes required to\r
-                                       complete the convertion. \r
+  @retval EFI_SUCCESS           The convertion is successfull. All bytes in Buffer has been convert to the corresponding\r
+                                Unicode character and placed into the right place in String.\r
+  @retval EFI_BUFFER_TOO_SMALL  StringSizeInBytes is smaller than 2 * N + 1the number of bytes required to\r
+                                complete the convertion. \r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
@@ -2277,7 +2284,10 @@ HexStringToBuf (
   Unicode character is converted to a byte. For example, Unicode character\r
   L'A' will be converted to 0x0A. \r
 \r
-  If Digit is NULL, then ASSERT.\r
+  If Digit is NULL, then ASSERT().\r
+  \r
+  @param  Digit       The output hexadecimal digit.\r
+  @param  Char        The input Unicode character.\r
 \r
   @retval TRUE        Char is in the range of Hexadecimal number. Digit is updated\r
                       to the byte value of the number.\r