diff options
author | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-10-09 10:44:05 +0000 |
---|---|---|
committer | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-10-09 10:44:05 +0000 |
commit | 269218a3006c2b00e88948ed847f614cf28f4def (patch) | |
tree | c280d374ab18bba05f1ff70e2a2ccc807181880d | |
parent | d4a78455c6b0d9bd931ea459190e1de3beee70df (diff) | |
download | edk2-platforms-269218a3006c2b00e88948ed847f614cf28f4def.tar.xz |
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
-rw-r--r-- | MdeModulePkg/Universal/HiiDatabaseDxe/String.c | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c index f7a7d7fd55..617ba54509 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c @@ -1960,6 +1960,35 @@ HiiGetSecondaryLanguages ( }
/**
+ 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.
@param Language1 Name of language 1 from StringPackage
@@ -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
|