Roll back changes to apply GetBestLanguage() in HiiDataBase. Exact language match...
authorrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 26 May 2009 03:48:50 +0000 (03:48 +0000)
committerrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 26 May 2009 03:48:50 +0000 (03:48 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8384 6f19259b-4bc3-4df7-8a09-765794883524

EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c
MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
MdeModulePkg/Universal/HiiDatabaseDxe/String.c

index d0b356b..d83750b 100644 (file)
@@ -307,7 +307,6 @@ HiiThunkGetString (
 \r
   Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
 \r
-  Iso639AsciiLanguage = NULL;\r
   Rfc4646AsciiLanguage = NULL;\r
 \r
   if (LanguageString != NULL) {\r
@@ -322,6 +321,7 @@ HiiThunkGetString (
     // in Iso639. So map it to the Language Identifier defined in RFC4646.\r
     //\r
     Rfc4646AsciiLanguage = ConvertLanguagesIso639ToRfc4646 (Iso639AsciiLanguage);\r
+    FreePool (Iso639AsciiLanguage);\r
 \r
     //\r
     // If Rfc4646AsciiLanguage is NULL, more language mapping must be added to \r
@@ -337,67 +337,56 @@ HiiThunkGetString (
     goto Done;\r
   }\r
 \r
-  if (Rfc4646AsciiLanguage == NULL) {\r
-    //\r
-    // Get the languages that the package specified by HiiHandle supports\r
-    //\r
-    SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);\r
-    if (SupportedLanguages == NULL) {\r
-      goto Error2;\r
-    }\r
+  //\r
+  // Get the languages that the package specified by HiiHandle supports\r
+  //\r
+  SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);\r
+  if (SupportedLanguages == NULL) {\r
+    goto Error2;\r
+  }\r
 \r
-    //\r
-    // Get the current platform language setting\r
-    //\r
-    PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang");\r
-    if (PlatformLanguage == NULL) {\r
-      goto Error1;\r
-    }\r
+  //\r
+  // Get the current platform language setting\r
+  //\r
+  PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang");\r
+  if (PlatformLanguage == NULL) {\r
+    goto Error1;\r
+  }\r
 \r
-    //\r
-    // Get the best matching language from SupportedLanguages\r
-    //\r
-    BestLanguage = GetBestLanguage (\r
-                     SupportedLanguages, \r
-                     FALSE,                // RFC 4646 mode\r
-                     PlatformLanguage,     // Next highest priority\r
-                     SupportedLanguages,   // Lowest priority \r
-                     NULL\r
-                     );\r
-    if (BestLanguage == NULL) {\r
-      FreePool (PlatformLanguage);\r
+  //\r
+  // Get the best matching language from SupportedLanguages\r
+  //\r
+  BestLanguage = GetBestLanguage (\r
+                   SupportedLanguages, \r
+                   FALSE,                // RFC 4646 mode\r
+                   (Rfc4646AsciiLanguage != NULL) ? Rfc4646AsciiLanguage : "",\r
+                   PlatformLanguage,     // Next highest priority\r
+                   SupportedLanguages,   // Lowest priority \r
+                   NULL\r
+                   );\r
+  if (BestLanguage == NULL) {\r
+    FreePool (PlatformLanguage);\r
 Error1:\r
-      FreePool (SupportedLanguages);\r
+    FreePool (SupportedLanguages);\r
 Error2:\r
-      Status = EFI_INVALID_PARAMETER;\r
-      goto Done;\r
-    }\r
-\r
-    Status = mHiiStringProtocol->GetString (\r
-                                 mHiiStringProtocol,\r
-                                 BestLanguage,\r
-                                 UefiHiiHandle,\r
-                                 Token,\r
-                                 StringBuffer,\r
-                                 BufferLengthTemp,\r
-                                 NULL\r
-                                 );\r
-    FreePool (BestLanguage);\r
-  } else {\r
-    Status = mHiiStringProtocol->GetString (\r
-                                 mHiiStringProtocol,\r
-                                 Rfc4646AsciiLanguage,\r
-                                 UefiHiiHandle,\r
-                                 Token,\r
-                                 StringBuffer,\r
-                                 BufferLengthTemp,\r
-                                 NULL\r
-                                 );\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto Done;\r
   }\r
 \r
+  Status = mHiiStringProtocol->GetString (\r
+                               mHiiStringProtocol,\r
+                               BestLanguage,\r
+                               UefiHiiHandle,\r
+                               Token,\r
+                               StringBuffer,\r
+                               BufferLengthTemp,\r
+                               NULL\r
+                               );\r
+  FreePool (BestLanguage);\r
+\r
 Done:\r
-       if (Iso639AsciiLanguage != NULL) {\r
-    FreePool (Iso639AsciiLanguage);\r
+       if (Rfc4646AsciiLanguage != NULL) {\r
+    FreePool (Rfc4646AsciiLanguage);\r
   }\r
   \r
   return Status;\r
index 9081e7c..918559e 100644 (file)
@@ -784,7 +784,6 @@ InsertStringPackage (
   EFI_STATUS                  Status;\r
   EFI_HII_PACKAGE_HEADER      PackageHeader;\r
   CHAR8                       *Language;\r
-  CHAR8                       *MatchedLanguage;\r
   UINT32                      LanguageSize;\r
   LIST_ENTRY                  *Link;\r
 \r
@@ -810,10 +809,8 @@ InsertStringPackage (
   AsciiStrCpy (Language, (CHAR8 *) PackageHdr + HeaderSize - LanguageSize);\r
   for (Link = PackageList->StringPkgHdr.ForwardLink; Link != &PackageList->StringPkgHdr; Link = Link->ForwardLink) {\r
     StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);\r
-    MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);\r
-    if (MatchedLanguage != NULL) {\r
+    if (HiiCompareLanguage (Language, StringPackage->StringPkgHdr->Language)) {\r
       FreePool (Language);\r
-      FreePool (MatchedLanguage);\r
       return EFI_UNSUPPORTED;\r
     }\r
   }\r
index af6ef9a..81f42c5 100644 (file)
@@ -1745,6 +1745,24 @@ HiiGetAltCfg (
   OUT EFI_STRING                               *AltCfgResp\r
   );\r
 \r
+\r
+/**\r
+  Compare whether two names of languages are identical.\r
+\r
+  @param  Language1              Name of language 1\r
+  @param  Language2              Name of language 2\r
+\r
+  @retval TRUE                   same\r
+  @retval FALSE                  not same\r
+\r
+**/\r
+BOOLEAN\r
+HiiCompareLanguage (\r
+  IN  CHAR8  *Language1,\r
+  IN  CHAR8  *Language2\r
+  )\r
+;\r
+\r
 //\r
 // Global variables\r
 //\r
index 052abca..00ff6ce 100644 (file)
@@ -968,7 +968,6 @@ HiiNewString (
   EFI_HII_SIBT_EXT2_BLOCK             Ext2;\r
   HII_FONT_INFO                       *LocalFont;\r
   HII_GLOBAL_FONT_INFO                *GlobalFont;\r
-  CHAR8                               *MatchedLanguage;\r
 \r
   if (This == NULL || String == NULL || StringId == NULL || Language == NULL || PackageList == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1015,9 +1014,7 @@ HiiNewString (
        Link = Link->ForwardLink\r
       ) {\r
     StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);\r
-    MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);\r
-    if (MatchedLanguage != NULL) {\r
-      FreePool (MatchedLanguage);\r
+    if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {\r
       Matched = TRUE;\r
       break;\r
     }\r
@@ -1323,7 +1320,6 @@ HiiGetString (
   HII_DATABASE_RECORD                 *DatabaseRecord;\r
   HII_DATABASE_PACKAGE_LIST_INSTANCE  *PackageListNode;\r
   HII_STRING_PACKAGE_INSTANCE         *StringPackage;\r
-  CHAR8                               *MatchedLanguage;\r
 \r
   if (This == NULL || Language == NULL || StringId < 1 || StringSize == NULL || PackageList == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1357,9 +1353,7 @@ HiiGetString (
          Link =  Link->ForwardLink\r
         ) {\r
         StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);\r
-        MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);\r
-        if (MatchedLanguage != NULL) {\r
-          FreePool (MatchedLanguage);\r
+        if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {\r
           Status = GetStringWorker (Private, StringPackage, StringId, String, StringSize, StringFontInfo);\r
           if (Status != EFI_NOT_FOUND) {\r
             return Status;\r
@@ -1427,7 +1421,6 @@ HiiSetString (
   HII_DATABASE_PACKAGE_LIST_INSTANCE  *PackageListNode;\r
   HII_STRING_PACKAGE_INSTANCE         *StringPackage;\r
   UINT32                              OldPackageLen;\r
-  CHAR8                               *MatchedLanguage;\r
 \r
   if (This == NULL || Language == NULL || StringId < 1 || String == NULL || PackageList == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1453,9 +1446,7 @@ HiiSetString (
          Link =  Link->ForwardLink\r
         ) {\r
       StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);\r
-      MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);\r
-      if (MatchedLanguage != NULL) {\r
-        FreePool (MatchedLanguage);\r
+      if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {\r
         OldPackageLen = StringPackage->StringPkgHdr->Header.Length;\r
         Status = SetStringWorker (\r
                    Private,\r
@@ -1612,7 +1603,6 @@ HiiGetSecondaryLanguages (
   HII_STRING_PACKAGE_INSTANCE         *StringPackage;\r
   CHAR8                               *Languages;\r
   UINTN                               ResultSize;\r
-  CHAR8                               *MatchedLanguage;\r
 \r
   if (This == NULL || PackageList == NULL || FirstLanguage == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1645,9 +1635,7 @@ HiiGetSecondaryLanguages (
          Link1 = Link1->ForwardLink\r
         ) {\r
     StringPackage = CR (Link1, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);\r
-    MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) FirstLanguage, NULL);\r
-    if (MatchedLanguage != NULL) {\r
-      FreePool (MatchedLanguage);\r
+    if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) FirstLanguage)) {\r
       Languages = StringPackage->StringPkgHdr->Language;\r
       //\r
       // Language is a series of ';' terminated strings, first one is primary\r
@@ -1675,3 +1663,41 @@ HiiGetSecondaryLanguages (
   return EFI_INVALID_LANGUAGE;\r
 }\r
 \r
+/**\r
+  Compare whether two names of languages are identical.\r
+\r
+  @param  Language1              Name of language 1\r
+  @param  Language2              Name of language 2\r
+\r
+  @retval TRUE                   same\r
+  @retval FALSE                  not same\r
+\r
+**/\r
+BOOLEAN\r
+HiiCompareLanguage (\r
+  IN  CHAR8  *Language1,\r
+  IN  CHAR8  *Language2\r
+  )\r
+{\r
+  //\r
+  // Porting Guide:\r
+  // This library interface is simply obsolete.\r
+  // Include the source code to user code.\r
+  //\r
+  UINTN Index;\r
+\r
+  for (Index = 0; (Language1[Index] != 0) && (Language2[Index] != 0); Index++) {\r
+    if (Language1[Index] != Language2[Index]) {\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  if (((Language1[Index] == 0) && (Language2[Index] == 0))   || \r
+         ((Language1[Index] == 0) && (Language2[Index] != ';')) ||\r
+         ((Language1[Index] == ';') && (Language2[Index] != 0)) ||\r
+         ((Language1[Index] == ';') && (Language2[Index] != ';'))) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r