mirror of https://github.com/acidanthera/audk.git
Adding StringNoCaseCompare to SortLib
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9535 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
3a5ac5bff0
commit
11d2decf81
|
@ -63,16 +63,35 @@ PerformQuickSort (
|
||||||
/**
|
/**
|
||||||
Function to compare 2 device paths for use as CompareFunction.
|
Function to compare 2 device paths for use as CompareFunction.
|
||||||
|
|
||||||
@param[in] Buffer1 pointer to Device Path to compare
|
@param[in] Buffer1 Pointer to Device Path to compare.
|
||||||
@param[in] Buffer2 pointer to second DevicePath to compare
|
@param[in] Buffer2 Pointer to second DevicePath to compare.
|
||||||
|
|
||||||
@retval 0 Buffer1 equal to Buffer2
|
@retval 0 Buffer1 equal to Buffer2.
|
||||||
@return < 0 Buffer1 is less than Buffer2
|
@return < 0 Buffer1 is less than Buffer2.
|
||||||
@return > 0 Buffer1 is greater than Buffer2
|
@return > 0 Buffer1 is greater than Buffer2.
|
||||||
**/
|
**/
|
||||||
INTN
|
INTN
|
||||||
|
EFIAPI
|
||||||
DevicePathCompare (
|
DevicePathCompare (
|
||||||
IN VOID *Buffer1,
|
IN VOID *Buffer1,
|
||||||
IN VOID *Buffer2
|
IN VOID *Buffer2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Function to compare 2 strings without regard to case of the characters.
|
||||||
|
|
||||||
|
@param[in] Buffer1 Pointer to String to compare (CHAR16**).
|
||||||
|
@param[in] Buffer2 Pointer to second String to compare (CHAR16**).
|
||||||
|
|
||||||
|
@retval 0 Buffer1 equal to Buffer2.
|
||||||
|
@return < 0 Buffer1 is less than Buffer2.
|
||||||
|
@return > 0 Buffer1 is greater than Buffer2.
|
||||||
|
**/
|
||||||
|
INTN
|
||||||
|
EFIAPI
|
||||||
|
StringNoCaseCompare (
|
||||||
|
IN VOID *Buffer1,
|
||||||
|
IN VOID *Buffer2
|
||||||
|
);
|
||||||
|
|
||||||
#endif //__SORT_LIB_H__
|
#endif //__SORT_LIB_H__
|
||||||
|
|
|
@ -185,3 +185,26 @@ DevicePathCompare (
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Function to compare 2 strings without regard to case of the characters.
|
||||||
|
|
||||||
|
@param[in] Buffer1 Pointer to String to compare.
|
||||||
|
@param[in] Buffer2 Pointer to second String to compare.
|
||||||
|
|
||||||
|
@retval 0 Buffer1 equal to Buffer2.
|
||||||
|
@return < 0 Buffer1 is less than Buffer2.
|
||||||
|
@return > 0 Buffer1 is greater than Buffer2.
|
||||||
|
**/
|
||||||
|
INTN
|
||||||
|
EFIAPI
|
||||||
|
StringNoCaseCompare (
|
||||||
|
IN VOID *Buffer1,
|
||||||
|
IN VOID *Buffer2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ASSERT(FALSE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Library/SortLib.h>
|
#include <Library/SortLib.h>
|
||||||
|
|
||||||
|
STATIC EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL;
|
||||||
|
STATIC EFI_UNICODE_COLLATION_PROTOCOL *mUnicodeCollation = NULL;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Worker function for QuickSorting. This function is identical to PerformQuickSort,
|
Worker function for QuickSorting. This function is identical to PerformQuickSort,
|
||||||
except that is uses the pre-allocated buffer so the in place sorting does not need to
|
except that is uses the pre-allocated buffer so the in place sorting does not need to
|
||||||
|
@ -199,9 +203,6 @@ DevicePathCompare (
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
INTN RetVal;
|
INTN RetVal;
|
||||||
|
|
||||||
STATIC EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevicePathToText = NULL;
|
|
||||||
STATIC EFI_UNICODE_COLLATION_PROTOCOL *UnicodeCollation = NULL;
|
|
||||||
|
|
||||||
DevicePath1 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer1;
|
DevicePath1 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer1;
|
||||||
DevicePath2 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer2;
|
DevicePath2 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer2;
|
||||||
|
|
||||||
|
@ -217,36 +218,36 @@ DevicePathCompare (
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DevicePathToText == NULL) {
|
if (mDevicePathToText == NULL) {
|
||||||
Status = gBS->LocateProtocol(
|
Status = gBS->LocateProtocol(
|
||||||
&gEfiDevicePathToTextProtocolGuid,
|
&gEfiDevicePathToTextProtocolGuid,
|
||||||
NULL,
|
NULL,
|
||||||
(VOID**)&DevicePathToText);
|
(VOID**)&mDevicePathToText);
|
||||||
|
|
||||||
ASSERT_EFI_ERROR(Status);
|
ASSERT_EFI_ERROR(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnicodeCollation == NULL) {
|
if (mUnicodeCollation == NULL) {
|
||||||
Status = gBS->LocateProtocol(
|
Status = gBS->LocateProtocol(
|
||||||
&gEfiUnicodeCollation2ProtocolGuid,
|
&gEfiUnicodeCollation2ProtocolGuid,
|
||||||
NULL,
|
NULL,
|
||||||
(VOID**)&UnicodeCollation);
|
(VOID**)&mUnicodeCollation);
|
||||||
|
|
||||||
ASSERT_EFI_ERROR(Status);
|
ASSERT_EFI_ERROR(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextPath1 = DevicePathToText->ConvertDevicePathToText(
|
TextPath1 = mDevicePathToText->ConvertDevicePathToText(
|
||||||
DevicePath1,
|
DevicePath1,
|
||||||
FALSE,
|
FALSE,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
TextPath2 = DevicePathToText->ConvertDevicePathToText(
|
TextPath2 = mDevicePathToText->ConvertDevicePathToText(
|
||||||
DevicePath2,
|
DevicePath2,
|
||||||
FALSE,
|
FALSE,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
RetVal = UnicodeCollation->StriColl(
|
RetVal = mUnicodeCollation->StriColl(
|
||||||
UnicodeCollation,
|
mUnicodeCollation,
|
||||||
TextPath1,
|
TextPath1,
|
||||||
TextPath2);
|
TextPath2);
|
||||||
|
|
||||||
|
@ -254,4 +255,39 @@ DevicePathCompare (
|
||||||
FreePool(TextPath2);
|
FreePool(TextPath2);
|
||||||
|
|
||||||
return (RetVal);
|
return (RetVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Function to compare 2 strings without regard to case of the characters.
|
||||||
|
|
||||||
|
@param[in] Buffer1 Pointer to String to compare.
|
||||||
|
@param[in] Buffer2 Pointer to second String to compare.
|
||||||
|
|
||||||
|
@retval 0 Buffer1 equal to Buffer2.
|
||||||
|
@return < 0 Buffer1 is less than Buffer2.
|
||||||
|
@return > 0 Buffer1 is greater than Buffer2.
|
||||||
|
**/
|
||||||
|
INTN
|
||||||
|
EFIAPI
|
||||||
|
StringNoCaseCompare (
|
||||||
|
IN VOID *Buffer1,
|
||||||
|
IN VOID *Buffer2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
if (mUnicodeCollation == NULL) {
|
||||||
|
Status = gBS->LocateProtocol(
|
||||||
|
&gEfiUnicodeCollation2ProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID**)&mUnicodeCollation);
|
||||||
|
|
||||||
|
ASSERT_EFI_ERROR(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (mUnicodeCollation->StriColl(
|
||||||
|
mUnicodeCollation,
|
||||||
|
*(CHAR16**)Buffer1,
|
||||||
|
*(CHAR16**)Buffer2));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue