]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BaseLib: Introduce CharToUpper and AsciiCharToUpper publicly
authorMike Turner <miketur@microsoft.com>
Wed, 30 Jan 2019 08:33:49 +0000 (16:33 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 31 Jan 2019 12:19:14 +0000 (20:19 +0800)
Introduce two public functions CharToUpper and AsciiCharToUpper.
They have the same functions as InternalCharToUpper and
InternalBaseLibAsciiToUpper.Considering the internal functions will
be removed,so directly I change their function names to the public ones'.
https://bugzilla.tianocore.org/show_bug.cgi?id=1369

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
MdePkg/Include/Library/BaseLib.h
MdePkg/Library/BaseLib/SafeString.c
MdePkg/Library/BaseLib/String.c

index 1eb842384ee26634cb1b8ea4ed8294cefddd8b98..c58e4b089d9674a176bd798dfbb1f257da49c9e8 100644 (file)
@@ -2,7 +2,7 @@
   Provides string functions, linked list functions, math functions, synchronization\r
   functions, file path functions, and CPU architecture-specific functions.\r
 \r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2008 - 2009, Apple Inc. 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
@@ -2720,6 +2720,46 @@ AsciiStrnToUnicodeStrS (
   OUT     UINTN                     *DestinationLength\r
   );\r
 \r
+/**\r
+  Convert a Unicode character to upper case only if\r
+  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 ASCII character, i.e.\r
+  L'a' to L'z'. For other Unicode character, the input character\r
+  is returned directly.\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
+CHAR16\r
+EFIAPI\r
+CharToUpper (\r
+  IN      CHAR16                    Char\r
+  );\r
+\r
+/**\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
+\r
+  @return The uppercase value of Ascii character\r
+\r
+**/\r
+CHAR8\r
+EFIAPI\r
+AsciiCharToUpper (\r
+  IN      CHAR8                     Chr\r
+  );\r
+\r
 /**\r
   Converts an 8-bit value to an 8-bit BCD value.\r
 \r
index 417497cbc96a47aae6f54998df8407c742a78e00..27e337f0aac1f40df44c67028c4fe32226d951b0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Safe String functions.\r
 \r
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2019, 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
@@ -905,7 +905,7 @@ StrHexToUintnS (
     String++;\r
   }\r
 \r
-  if (InternalCharToUpper (*String) == L'X') {\r
+  if (CharToUpper (*String) == L'X') {\r
     if (*(String - 1) != L'0') {\r
       *Data = 0;\r
       return RETURN_SUCCESS;\r
@@ -1036,7 +1036,7 @@ StrHexToUint64S (
     String++;\r
   }\r
 \r
-  if (InternalCharToUpper (*String) == L'X') {\r
+  if (CharToUpper (*String) == L'X') {\r
     if (*(String - 1) != L'0') {\r
       *Data = 0;\r
       return RETURN_SUCCESS;\r
@@ -2459,7 +2459,7 @@ AsciiStrHexToUintnS (
     String++;\r
   }\r
 \r
-  if (InternalBaseLibAsciiToUpper (*String) == 'X') {\r
+  if (AsciiCharToUpper (*String) == 'X') {\r
     if (*(String - 1) != '0') {\r
       *Data = 0;\r
       return RETURN_SUCCESS;\r
@@ -2586,7 +2586,7 @@ AsciiStrHexToUint64S (
     String++;\r
   }\r
 \r
-  if (InternalBaseLibAsciiToUpper (*String) == 'X') {\r
+  if (AsciiCharToUpper (*String) == 'X') {\r
     if (*(String - 1) != '0') {\r
       *Data = 0;\r
       return RETURN_SUCCESS;\r
index e6df12797d94d41f60b00020ee02b38dbe65f15d..467d91069d9d32b5657c58e45470307b65dcba67 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Unicode and ASCII string primitives.\r
 \r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2019, 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
@@ -552,7 +552,7 @@ InternalIsDecimalDigitCharacter (
 **/\r
 CHAR16\r
 EFIAPI\r
-InternalCharToUpper (\r
+CharToUpper (\r
   IN      CHAR16                    Char\r
   )\r
 {\r
@@ -586,7 +586,7 @@ InternalHexCharToUintn (
     return Char - L'0';\r
   }\r
 \r
-  return (10 + InternalCharToUpper (Char) - L'A');\r
+  return (10 + CharToUpper (Char) - L'A');\r
 }\r
 \r
 /**\r
@@ -1181,7 +1181,7 @@ AsciiStrCmp (
 **/\r
 CHAR8\r
 EFIAPI\r
-InternalBaseLibAsciiToUpper (\r
+AsciiCharToUpper (\r
   IN      CHAR8                     Chr\r
   )\r
 {\r
@@ -1211,7 +1211,7 @@ InternalAsciiHexCharToUintn (
     return Char - '0';\r
   }\r
 \r
-  return (10 + InternalBaseLibAsciiToUpper (Char) - 'A');\r
+  return (10 + AsciiCharToUpper (Char) - 'A');\r
 }\r
 \r
 \r
@@ -1260,13 +1260,13 @@ AsciiStriCmp (
   ASSERT (AsciiStrSize (FirstString));\r
   ASSERT (AsciiStrSize (SecondString));\r
 \r
-  UpperFirstString  = InternalBaseLibAsciiToUpper (*FirstString);\r
-  UpperSecondString = InternalBaseLibAsciiToUpper (*SecondString);\r
+  UpperFirstString  = AsciiCharToUpper (*FirstString);\r
+  UpperSecondString = AsciiCharToUpper (*SecondString);\r
   while ((*FirstString != '\0') && (*SecondString != '\0') && (UpperFirstString == UpperSecondString)) {\r
     FirstString++;\r
     SecondString++;\r
-    UpperFirstString  = InternalBaseLibAsciiToUpper (*FirstString);\r
-    UpperSecondString = InternalBaseLibAsciiToUpper (*SecondString);\r
+    UpperFirstString  = AsciiCharToUpper (*FirstString);\r
+    UpperSecondString = AsciiCharToUpper (*SecondString);\r
   }\r
 \r
   return UpperFirstString - UpperSecondString;\r