]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Adding StringNoCaseCompare to SortLib
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 7 Dec 2009 18:04:03 +0000 (18:04 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 7 Dec 2009 18:04:03 +0000 (18:04 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9535 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Include/Library/SortLib.h
ShellPkg/Library/BaseSortLib/BaseSortLib.c
ShellPkg/Library/UefiSortLib/UefiSortLib.c

index 276199457234f5e4473b2921496be1d23753076f..e213b7a40e569f10e188ac13f3230eb4007d0ade 100644 (file)
@@ -63,16 +63,35 @@ PerformQuickSort (
 /**\r
   Function to compare 2 device paths for use as CompareFunction.\r
 \r
-  @param[in] Buffer1            pointer to Device Path to compare\r
-  @param[in] Buffer2            pointer to second DevicePath to compare\r
+  @param[in] Buffer1            Pointer to Device Path to compare.\r
+  @param[in] Buffer2            Pointer to second DevicePath to compare.\r
 \r
-  @retval 0                           Buffer1 equal to Buffer2\r
-  @return < 0                         Buffer1 is less than Buffer2\r
-  @return > 0                         Buffer1 is greater than Buffer2                     \r
+  @retval 0                     Buffer1 equal to Buffer2.\r
+  @return < 0                   Buffer1 is less than Buffer2.\r
+  @return > 0                   Buffer1 is greater than Buffer2.                 \r
 **/\r
 INTN\r
+EFIAPI\r
 DevicePathCompare (\r
   IN  VOID             *Buffer1,\r
   IN  VOID             *Buffer2\r
   );\r
+\r
+/**\r
+  Function to compare 2 strings without regard to case of the characters.\r
+\r
+  @param[in] Buffer1            Pointer to String to compare (CHAR16**). \r
+  @param[in] Buffer2            Pointer to second String to compare (CHAR16**).\r
+\r
+  @retval 0                     Buffer1 equal to Buffer2.\r
+  @return < 0                   Buffer1 is less than Buffer2.\r
+  @return > 0                   Buffer1 is greater than Buffer2.                 \r
+**/\r
+INTN\r
+EFIAPI\r
+StringNoCaseCompare (\r
+  IN  VOID             *Buffer1,\r
+  IN  VOID             *Buffer2\r
+  );\r
+\r
 #endif //__SORT_LIB_H__\r
index 8ee9abb3d382a6145edc2b544c2dcbad64c87b7a..91b2a17e7abf2840baf9facd0630b345974e03db 100644 (file)
@@ -185,3 +185,26 @@ DevicePathCompare (
   ASSERT(FALSE);\r
   return 0;\r
 }\r
+\r
+/**\r
+  Function to compare 2 strings without regard to case of the characters.\r
+\r
+  @param[in] Buffer1            Pointer to String to compare.\r
+  @param[in] Buffer2            Pointer to second String to compare.\r
+\r
+  @retval 0                     Buffer1 equal to Buffer2.\r
+  @return < 0                   Buffer1 is less than Buffer2.\r
+  @return > 0                   Buffer1 is greater than Buffer2.                 \r
+**/\r
+INTN\r
+EFIAPI\r
+StringNoCaseCompare (\r
+  IN  VOID             *Buffer1,\r
+  IN  VOID             *Buffer2\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}\r
+\r
+\r
index 08b8169e213da2cb1752c6289dccb91b6eb67354..1df45fb5ae0e0b811d386d94bfce7e113f813cb1 100644 (file)
@@ -25,6 +25,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/SortLib.h> \r
 \r
+STATIC EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL;\r
+STATIC EFI_UNICODE_COLLATION_PROTOCOL   *mUnicodeCollation = NULL;\r
+\r
+\r
 /**\r
   Worker function for QuickSorting.  This function is identical to PerformQuickSort, \r
   except that is uses the pre-allocated buffer so the in place sorting does not need to \r
@@ -199,9 +203,6 @@ DevicePathCompare (
   EFI_STATUS                Status;\r
   INTN                      RetVal;\r
    \r
-  STATIC EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevicePathToText = NULL;\r
-  STATIC EFI_UNICODE_COLLATION_PROTOCOL   *UnicodeCollation = NULL;\r
-\r
   DevicePath1 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer1;\r
   DevicePath2 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer2;\r
 \r
@@ -217,36 +218,36 @@ DevicePathCompare (
     return 1;\r
   }\r
   \r
-  if (DevicePathToText == NULL) {\r
+  if (mDevicePathToText == NULL) {\r
     Status = gBS->LocateProtocol(\r
       &gEfiDevicePathToTextProtocolGuid,\r
       NULL,\r
-      (VOID**)&DevicePathToText);\r
+      (VOID**)&mDevicePathToText);\r
 \r
     ASSERT_EFI_ERROR(Status);\r
   }\r
 \r
-  if (UnicodeCollation == NULL) {\r
+  if (mUnicodeCollation == NULL) {\r
     Status = gBS->LocateProtocol(\r
       &gEfiUnicodeCollation2ProtocolGuid,\r
       NULL,\r
-      (VOID**)&UnicodeCollation);\r
+      (VOID**)&mUnicodeCollation);\r
 \r
     ASSERT_EFI_ERROR(Status);\r
   }\r
 \r
-  TextPath1 = DevicePathToText->ConvertDevicePathToText(\r
+  TextPath1 = mDevicePathToText->ConvertDevicePathToText(\r
     DevicePath1,\r
     FALSE,\r
     FALSE);\r
 \r
-  TextPath2 = DevicePathToText->ConvertDevicePathToText(\r
+  TextPath2 = mDevicePathToText->ConvertDevicePathToText(\r
     DevicePath2,\r
     FALSE,\r
     FALSE);\r
   \r
-  RetVal = UnicodeCollation->StriColl(\r
-    UnicodeCollation,\r
+  RetVal = mUnicodeCollation->StriColl(\r
+    mUnicodeCollation,\r
     TextPath1,\r
     TextPath2);\r
 \r
@@ -254,4 +255,39 @@ DevicePathCompare (
   FreePool(TextPath2);\r
 \r
   return (RetVal);\r
-}
\ No newline at end of file
+}\r
+\r
+/**\r
+  Function to compare 2 strings without regard to case of the characters.\r
+\r
+  @param[in] Buffer1            Pointer to String to compare.\r
+  @param[in] Buffer2            Pointer to second String to compare.\r
+\r
+  @retval 0                     Buffer1 equal to Buffer2.\r
+  @return < 0                   Buffer1 is less than Buffer2.\r
+  @return > 0                   Buffer1 is greater than Buffer2.                 \r
+**/\r
+INTN\r
+EFIAPI\r
+StringNoCaseCompare (\r
+  IN  VOID             *Buffer1,\r
+  IN  VOID             *Buffer2\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  if (mUnicodeCollation == NULL) {\r
+    Status = gBS->LocateProtocol(\r
+      &gEfiUnicodeCollation2ProtocolGuid,\r
+      NULL,\r
+      (VOID**)&mUnicodeCollation);\r
+\r
+    ASSERT_EFI_ERROR(Status);\r
+  }\r
+\r
+  return (mUnicodeCollation->StriColl(\r
+    mUnicodeCollation,\r
+    *(CHAR16**)Buffer1,\r
+    *(CHAR16**)Buffer2));\r
+}\r
+\r
+\r