Update code to make get string case insensitive about language

Signed-off-by: ydong10
Reviewed-by: rsun3
Reviewed-by: lgao4

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12517 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ydong10 2011-10-09 10:44:05 +00:00
parent d4a78455c6
commit 269218a300

View File

@ -1959,6 +1959,35 @@ HiiGetSecondaryLanguages (
return EFI_INVALID_LANGUAGE;
}
/**
Converts the ascii character of the string from uppercase to lowercase.
This is a internal function.
@param ConfigString String to be converted
**/
VOID
EFIAPI
AsciiHiiToLower (
IN CHAR8 *ConfigString
)
{
CHAR8 *String;
ASSERT (ConfigString != NULL);
//
// Convert all hex digits in range [A-F] in the configuration header to [a-f]
//
for (String = ConfigString; *String != '\0'; String++) {
if ( *String >= 'A' && *String <= 'Z') {
*String = (CHAR8) (*String - 'A' + 'a');
}
}
return;
}
/**
Compare whether two names of languages are identical.
@ -1976,12 +2005,28 @@ HiiCompareLanguage (
)
{
UINTN Index;
UINTN StrLen;
CHAR8 *Lan1;
CHAR8 *Lan2;
//
// Convert to lower to compare.
//
StrLen = AsciiStrSize (Language1);
Lan1 = AllocateZeroPool (StrLen);
AsciiStrCpy(Lan1, Language1);
AsciiHiiToLower (Lan1);
StrLen = AsciiStrSize (Language2);
Lan2 = AllocateZeroPool (StrLen);
AsciiStrCpy(Lan2, Language2);
AsciiHiiToLower (Lan2);
//
// Compare the Primary Language in Language1 to Language2
//
for (Index = 0; Language1[Index] != 0 && Language1[Index] != ';'; Index++) {
if (Language1[Index] != Language2[Index]) {
for (Index = 0; Lan1[Index] != 0 && Lan1[Index] != ';'; Index++) {
if (Lan1[Index] != Lan2[Index]) {
//
// Return FALSE if any characters are different.
//
@ -1989,6 +2034,9 @@ HiiCompareLanguage (
}
}
FreePool (Lan1);
FreePool (Lan2);
//
// Only return TRUE if Language2[Index] is a Null-terminator which means
// the Primary Language in Language1 is the same length as Language2. If