]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/BaseSortLib/BaseSortLib.c
fixed license header / copyright date on all files.
[mirror_edk2.git] / ShellPkg / Library / BaseSortLib / BaseSortLib.c
index 904dece1ba1250575f4a3d5f2aeeb013a81ee187..eaee544d3d61ce8a56fb7d801465d60cb08f0cbd 100644 (file)
@@ -1,14 +1,14 @@
 /** @file\r
   Library used for sorting routines.\r
 \r
-Copyright (c) 2009, 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
-http://opensource.org/licenses/bsd-license.php\r
+  Copyright (c) 2009-2010, 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
+  http://opensource.org/licenses/bsd-license.php\r
 \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
+  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
 **/\r
 \r
@@ -18,11 +18,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
-#include <Library/SortLib.h> \r
+#include <Library/SortLib.h>\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
+  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
   allocate and free buffers constantly.\r
 \r
   Each element must be equal sized.\r
@@ -38,7 +38,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
                                 on return a buffer of sorted elements\r
   @param[in] Count              the number of elements in the buffer to sort\r
   @param[in] ElementSize        Size of an element in bytes\r
-  @param[in] CompareFunction    The function to call to perform the comparison \r
+  @param[in] CompareFunction    The function to call to perform the comparison\r
                                 of any 2 elements\r
   @param[in] Buffer             Buffer of size ElementSize for use in swapping\r
 **/\r
@@ -60,7 +60,7 @@ QuickSortWorker (
   ASSERT(CompareFunction  != NULL);\r
   ASSERT(Buffer  != NULL);\r
 \r
-  if ( Count < 2 \r
+  if ( Count < 2\r
     || ElementSize  < 1\r
     ){\r
     return;\r
@@ -78,7 +78,7 @@ QuickSortWorker (
   // and everything "right" are above it\r
   //\r
   for ( LoopCount = 0\r
-      ; LoopCount < Count -1 \r
+      ; LoopCount < Count -1\r
       ; LoopCount++\r
       ){\r
     //\r
@@ -86,7 +86,7 @@ QuickSortWorker (
     //\r
     if (CompareFunction((VOID*)((UINT8*)BufferToSort+((LoopCount)*ElementSize)),Pivot) <= 0){\r
       //\r
-      // swap \r
+      // swap\r
       //\r
       CopyMem (Buffer, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize), ElementSize);\r
       CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), (UINT8*)BufferToSort+((LoopCount)*ElementSize), ElementSize);\r
@@ -94,7 +94,7 @@ QuickSortWorker (
 \r
       //\r
       // increment NextSwapLocation\r
-      // \r
+      //\r
       NextSwapLocation++;\r
     }\r
   }\r
@@ -106,20 +106,20 @@ QuickSortWorker (
   CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), Buffer, ElementSize);\r
 \r
   //\r
-  // Now recurse on 2 paritial lists.  neither of these will have the 'pivot' element \r
+  // Now recurse on 2 paritial lists.  neither of these will have the 'pivot' element\r
   // IE list is sorted left half, pivot element, sorted right half...\r
   //\r
   QuickSortWorker(\r
-    BufferToSort, \r
-    NextSwapLocation, \r
-    ElementSize, \r
+    BufferToSort,\r
+    NextSwapLocation,\r
+    ElementSize,\r
     CompareFunction,\r
     Buffer);\r
 \r
   QuickSortWorker(\r
     (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,\r
-    Count - NextSwapLocation - 1, \r
-    ElementSize, \r
+    Count - NextSwapLocation - 1,\r
+    ElementSize,\r
     CompareFunction,\r
     Buffer);\r
 \r
@@ -140,7 +140,7 @@ QuickSortWorker (
                                 on return a buffer of sorted elements\r
   @param[in] Count              the number of elements in the buffer to sort\r
   @param[in] ElementSize        Size of an element in bytes\r
-  @param[in] CompareFunction    The function to call to perform the comparison \r
+  @param[in] CompareFunction    The function to call to perform the comparison\r
                                 of any 2 elements\r
 **/\r
 VOID\r
@@ -173,15 +173,38 @@ PerformQuickSort (
 \r
 /**\r
   Not supported in Base version.\r
-  \r
+\r
   ASSERT and return 0.\r
 **/\r
 INTN\r
 DevicePathCompare (\r
-  IN  VOID             *Buffer1,\r
-  IN  VOID             *Buffer2\r
+  IN  CONST VOID             *Buffer1,\r
+  IN  CONST VOID             *Buffer2\r
+  )\r
+{\r
+  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  CONST VOID             *Buffer1,\r
+  IN  CONST VOID             *Buffer2\r
   )\r
 {\r
   ASSERT(FALSE);\r
   return 0;\r
-}
\ No newline at end of file
+}\r
+\r
+\r