From 557b3f18d13017a818d38f00a7afbe6f618d5fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20H=C3=A4user?= <8659494+mhaeuser@users.noreply.github.com> Date: Sat, 27 Feb 2021 19:43:15 +0100 Subject: [PATCH] OcStringLib: Import MixedStrCmp() --- Include/Acidanthera/Library/OcStringLib.h | 23 +++++++++++++++++++++++ Library/OcStringLib/OcUnicodeLib.c | 14 ++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/Include/Acidanthera/Library/OcStringLib.h b/Include/Acidanthera/Library/OcStringLib.h index 9941d2df..d312022b 100755 --- a/Include/Acidanthera/Library/OcStringLib.h +++ b/Include/Acidanthera/Library/OcStringLib.h @@ -557,4 +557,27 @@ HasValidGuidStringPrefix ( IN CONST CHAR16 *String ); +/** + Compares two Null-terminated Unocide and ASCII strings, and returns the + difference between the first mismatched characters. + + This function compares the Null-terminated Unicode string FirstString to the + Null-terminated ASCII string SecondString. If FirstString is identical to + SecondString, then 0 is returned. Otherwise, the value returned is the first + mismatched character in SecondString subtracted from the first mismatched + character in FirstString. + + @param FirstString A pointer to a Null-terminated Unicode string. + @param SecondString A pointer to a Null-terminated ASCII string. + + @retval ==0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +MixedStrCmp ( + IN CONST CHAR16 *FirstString, + IN CONST CHAR8 *SecondString + ); + #endif // OC_STRING_LIB_H diff --git a/Library/OcStringLib/OcUnicodeLib.c b/Library/OcStringLib/OcUnicodeLib.c index 1c24422c..6392a19f 100755 --- a/Library/OcStringLib/OcUnicodeLib.c +++ b/Library/OcStringLib/OcUnicodeLib.c @@ -405,3 +405,17 @@ HasValidGuidStringPrefix ( return TRUE; } + +INTN +MixedStrCmp ( + IN CONST CHAR16 *FirstString, + IN CONST CHAR8 *SecondString + ) +{ + while (*FirstString != '\0' && *FirstString == *SecondString) { + ++FirstString; + ++SecondString; + } + + return *FirstString - *SecondString; +}