From 4a12dfd454c56a0256fa4ec4b4b27dac8ae79bf1 Mon Sep 17 00:00:00 2001 From: ydong10 Date: Thu, 17 Mar 2011 07:31:35 +0000 Subject: [PATCH] =?UTF-8?q?Use=20exactly=20match=20method=20for=20HiiCompa?= =?UTF-8?q?reLanguage.=20Compare=20all=20of=20Language2=20against=20the=20?= =?UTF-8?q?characters=20in=20Language1=20up=20to=20the=20first=20=E2=80=98?= =?UTF-8?q?;=E2=80=99=20or=20Null=20terminator.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11409 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/HiiDatabaseDxe/String.c | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c index eeac9c2087..194e44e6d0 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c @@ -1967,11 +1967,25 @@ HiiCompareLanguage ( IN CHAR8 *Language2 ) { - UINTN Language2Len; + UINTN Index; // - // When languages are exactly same, they will be identical. + // Compare the Primary Language in Language1 to Language2 // - Language2Len = AsciiStrLen (Language2); - return (BOOLEAN) (AsciiStrnCmp (Language1, Language2, Language2Len) == 0); + for (Index = 0; Language1[Index] != 0 && Language1[Index] != ';'; Index++) { + if (Language1[Index] != Language2[Index]) { + // + // Return FALSE if any characters are different. + // + return FALSE; + } + } + + // + // Only return TRUE if Language2[Index] is a Null-terminator which means + // the Primary Language in Language1 is the same length as Language2. If + // Language2[Index] is not a Null-terminator, then Language2 is longer than + // the Primary Language in Language1, and FALSE must be returned. + // + return (Language2[Index] == 0); }