mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2026-02-01 15:59:39 +00:00
OcStringLib: Fix compilation with UDK, which has no CharToUpper
This commit is contained in:
parent
3837176219
commit
392185b0e3
@ -19,6 +19,35 @@
|
||||
#include <Library/OcStringLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
|
||||
/**
|
||||
Convert a Unicode character to upper case only if
|
||||
it maps to a valid small-case ASCII character.
|
||||
|
||||
This internal function only deal with Unicode character
|
||||
which maps to a valid small-case ASII character, i.e.
|
||||
L'a' to L'z'. For other Unicode character, the input character
|
||||
is returned directly.
|
||||
|
||||
|
||||
@param Char The character to convert.
|
||||
|
||||
@retval LowerCharacter If the Char is with range L'a' to L'z'.
|
||||
@retval Unchanged Otherwise.
|
||||
|
||||
**/
|
||||
STATIC
|
||||
CHAR16
|
||||
InternalCharToUpper (
|
||||
IN CHAR16 Char
|
||||
)
|
||||
{
|
||||
if (Char >= L'a' && Char <= L'z') {
|
||||
return (CHAR16) (Char - (L'a' - L'A'));
|
||||
}
|
||||
|
||||
return Char;
|
||||
}
|
||||
|
||||
/**
|
||||
Performs a case insensitive comparison of two Null-terminated Unicode strings,
|
||||
and returns the difference between the first mismatched Unicode characters.
|
||||
@ -64,13 +93,13 @@ StriCmp (
|
||||
ASSERT (StrSize (FirstString) != 0);
|
||||
ASSERT (StrSize (SecondString) != 0);
|
||||
|
||||
UpperFirstString = CharToUpper (*FirstString);
|
||||
UpperSecondString = CharToUpper (*SecondString);
|
||||
UpperFirstString = InternalCharToUpper (*FirstString);
|
||||
UpperSecondString = InternalCharToUpper (*SecondString);
|
||||
while ((*FirstString != '\0') && (*SecondString != '\0') && (UpperFirstString == UpperSecondString)) {
|
||||
FirstString++;
|
||||
SecondString++;
|
||||
UpperFirstString = CharToUpper (*FirstString);
|
||||
UpperSecondString = CharToUpper (*SecondString);
|
||||
UpperFirstString = InternalCharToUpper (*FirstString);
|
||||
UpperSecondString = InternalCharToUpper (*SecondString);
|
||||
}
|
||||
|
||||
return UpperFirstString - UpperSecondString;
|
||||
@ -140,16 +169,16 @@ StrniCmp (
|
||||
ASSERT (Length <= PcdGet32 (PcdMaximumUnicodeStringLength));
|
||||
}
|
||||
|
||||
UpperFirstString = CharToUpper (*FirstString);
|
||||
UpperSecondString = CharToUpper (*SecondString);
|
||||
UpperFirstString = InternalCharToUpper (*FirstString);
|
||||
UpperSecondString = InternalCharToUpper (*SecondString);
|
||||
while ((*FirstString != L'\0') &&
|
||||
(*SecondString != L'\0') &&
|
||||
(UpperFirstString == UpperSecondString) &&
|
||||
(Length > 1)) {
|
||||
FirstString++;
|
||||
SecondString++;
|
||||
UpperFirstString = CharToUpper (*FirstString);
|
||||
UpperSecondString = CharToUpper (*SecondString);
|
||||
UpperFirstString = InternalCharToUpper (*FirstString);
|
||||
UpperSecondString = InternalCharToUpper (*SecondString);
|
||||
Length--;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user