mirror of https://github.com/acidanthera/audk.git
Roll back changes to apply GetBestLanguage() in HiiDataBase. Exact language match should be used in HiiDatabase.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8384 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
b0a5e682d6
commit
f324bf4dbe
|
@ -307,7 +307,6 @@ HiiThunkGetString (
|
|||
|
||||
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
||||
|
||||
Iso639AsciiLanguage = NULL;
|
||||
Rfc4646AsciiLanguage = NULL;
|
||||
|
||||
if (LanguageString != NULL) {
|
||||
|
@ -322,6 +321,7 @@ HiiThunkGetString (
|
|||
// in Iso639. So map it to the Language Identifier defined in RFC4646.
|
||||
//
|
||||
Rfc4646AsciiLanguage = ConvertLanguagesIso639ToRfc4646 (Iso639AsciiLanguage);
|
||||
FreePool (Iso639AsciiLanguage);
|
||||
|
||||
//
|
||||
// If Rfc4646AsciiLanguage is NULL, more language mapping must be added to
|
||||
|
@ -337,67 +337,56 @@ HiiThunkGetString (
|
|||
goto Done;
|
||||
}
|
||||
|
||||
if (Rfc4646AsciiLanguage == NULL) {
|
||||
//
|
||||
// Get the languages that the package specified by HiiHandle supports
|
||||
//
|
||||
SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);
|
||||
if (SupportedLanguages == NULL) {
|
||||
goto Error2;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the current platform language setting
|
||||
//
|
||||
PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang");
|
||||
if (PlatformLanguage == NULL) {
|
||||
goto Error1;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the best matching language from SupportedLanguages
|
||||
//
|
||||
BestLanguage = GetBestLanguage (
|
||||
SupportedLanguages,
|
||||
FALSE, // RFC 4646 mode
|
||||
PlatformLanguage, // Next highest priority
|
||||
SupportedLanguages, // Lowest priority
|
||||
NULL
|
||||
);
|
||||
if (BestLanguage == NULL) {
|
||||
FreePool (PlatformLanguage);
|
||||
Error1:
|
||||
FreePool (SupportedLanguages);
|
||||
Error2:
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = mHiiStringProtocol->GetString (
|
||||
mHiiStringProtocol,
|
||||
BestLanguage,
|
||||
UefiHiiHandle,
|
||||
Token,
|
||||
StringBuffer,
|
||||
BufferLengthTemp,
|
||||
NULL
|
||||
);
|
||||
FreePool (BestLanguage);
|
||||
} else {
|
||||
Status = mHiiStringProtocol->GetString (
|
||||
mHiiStringProtocol,
|
||||
Rfc4646AsciiLanguage,
|
||||
UefiHiiHandle,
|
||||
Token,
|
||||
StringBuffer,
|
||||
BufferLengthTemp,
|
||||
NULL
|
||||
);
|
||||
//
|
||||
// Get the languages that the package specified by HiiHandle supports
|
||||
//
|
||||
SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);
|
||||
if (SupportedLanguages == NULL) {
|
||||
goto Error2;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the current platform language setting
|
||||
//
|
||||
PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang");
|
||||
if (PlatformLanguage == NULL) {
|
||||
goto Error1;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the best matching language from SupportedLanguages
|
||||
//
|
||||
BestLanguage = GetBestLanguage (
|
||||
SupportedLanguages,
|
||||
FALSE, // RFC 4646 mode
|
||||
(Rfc4646AsciiLanguage != NULL) ? Rfc4646AsciiLanguage : "",
|
||||
PlatformLanguage, // Next highest priority
|
||||
SupportedLanguages, // Lowest priority
|
||||
NULL
|
||||
);
|
||||
if (BestLanguage == NULL) {
|
||||
FreePool (PlatformLanguage);
|
||||
Error1:
|
||||
FreePool (SupportedLanguages);
|
||||
Error2:
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = mHiiStringProtocol->GetString (
|
||||
mHiiStringProtocol,
|
||||
BestLanguage,
|
||||
UefiHiiHandle,
|
||||
Token,
|
||||
StringBuffer,
|
||||
BufferLengthTemp,
|
||||
NULL
|
||||
);
|
||||
FreePool (BestLanguage);
|
||||
|
||||
Done:
|
||||
if (Iso639AsciiLanguage != NULL) {
|
||||
FreePool (Iso639AsciiLanguage);
|
||||
if (Rfc4646AsciiLanguage != NULL) {
|
||||
FreePool (Rfc4646AsciiLanguage);
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
|
|
@ -784,7 +784,6 @@ InsertStringPackage (
|
|||
EFI_STATUS Status;
|
||||
EFI_HII_PACKAGE_HEADER PackageHeader;
|
||||
CHAR8 *Language;
|
||||
CHAR8 *MatchedLanguage;
|
||||
UINT32 LanguageSize;
|
||||
LIST_ENTRY *Link;
|
||||
|
||||
|
@ -810,10 +809,8 @@ InsertStringPackage (
|
|||
AsciiStrCpy (Language, (CHAR8 *) PackageHdr + HeaderSize - LanguageSize);
|
||||
for (Link = PackageList->StringPkgHdr.ForwardLink; Link != &PackageList->StringPkgHdr; Link = Link->ForwardLink) {
|
||||
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);
|
||||
if (MatchedLanguage != NULL) {
|
||||
if (HiiCompareLanguage (Language, StringPackage->StringPkgHdr->Language)) {
|
||||
FreePool (Language);
|
||||
FreePool (MatchedLanguage);
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1745,6 +1745,24 @@ HiiGetAltCfg (
|
|||
OUT EFI_STRING *AltCfgResp
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Compare whether two names of languages are identical.
|
||||
|
||||
@param Language1 Name of language 1
|
||||
@param Language2 Name of language 2
|
||||
|
||||
@retval TRUE same
|
||||
@retval FALSE not same
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
HiiCompareLanguage (
|
||||
IN CHAR8 *Language1,
|
||||
IN CHAR8 *Language2
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// Global variables
|
||||
//
|
||||
|
|
|
@ -968,7 +968,6 @@ HiiNewString (
|
|||
EFI_HII_SIBT_EXT2_BLOCK Ext2;
|
||||
HII_FONT_INFO *LocalFont;
|
||||
HII_GLOBAL_FONT_INFO *GlobalFont;
|
||||
CHAR8 *MatchedLanguage;
|
||||
|
||||
if (This == NULL || String == NULL || StringId == NULL || Language == NULL || PackageList == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
@ -1015,9 +1014,7 @@ HiiNewString (
|
|||
Link = Link->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);
|
||||
if (MatchedLanguage != NULL) {
|
||||
FreePool (MatchedLanguage);
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
Matched = TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -1323,7 +1320,6 @@ HiiGetString (
|
|||
HII_DATABASE_RECORD *DatabaseRecord;
|
||||
HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageListNode;
|
||||
HII_STRING_PACKAGE_INSTANCE *StringPackage;
|
||||
CHAR8 *MatchedLanguage;
|
||||
|
||||
if (This == NULL || Language == NULL || StringId < 1 || StringSize == NULL || PackageList == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
@ -1357,9 +1353,7 @@ HiiGetString (
|
|||
Link = Link->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);
|
||||
if (MatchedLanguage != NULL) {
|
||||
FreePool (MatchedLanguage);
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
Status = GetStringWorker (Private, StringPackage, StringId, String, StringSize, StringFontInfo);
|
||||
if (Status != EFI_NOT_FOUND) {
|
||||
return Status;
|
||||
|
@ -1427,7 +1421,6 @@ HiiSetString (
|
|||
HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageListNode;
|
||||
HII_STRING_PACKAGE_INSTANCE *StringPackage;
|
||||
UINT32 OldPackageLen;
|
||||
CHAR8 *MatchedLanguage;
|
||||
|
||||
if (This == NULL || Language == NULL || StringId < 1 || String == NULL || PackageList == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
@ -1453,9 +1446,7 @@ HiiSetString (
|
|||
Link = Link->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);
|
||||
if (MatchedLanguage != NULL) {
|
||||
FreePool (MatchedLanguage);
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
OldPackageLen = StringPackage->StringPkgHdr->Header.Length;
|
||||
Status = SetStringWorker (
|
||||
Private,
|
||||
|
@ -1612,7 +1603,6 @@ HiiGetSecondaryLanguages (
|
|||
HII_STRING_PACKAGE_INSTANCE *StringPackage;
|
||||
CHAR8 *Languages;
|
||||
UINTN ResultSize;
|
||||
CHAR8 *MatchedLanguage;
|
||||
|
||||
if (This == NULL || PackageList == NULL || FirstLanguage == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
@ -1645,9 +1635,7 @@ HiiGetSecondaryLanguages (
|
|||
Link1 = Link1->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link1, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) FirstLanguage, NULL);
|
||||
if (MatchedLanguage != NULL) {
|
||||
FreePool (MatchedLanguage);
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) FirstLanguage)) {
|
||||
Languages = StringPackage->StringPkgHdr->Language;
|
||||
//
|
||||
// Language is a series of ';' terminated strings, first one is primary
|
||||
|
@ -1675,3 +1663,41 @@ HiiGetSecondaryLanguages (
|
|||
return EFI_INVALID_LANGUAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
Compare whether two names of languages are identical.
|
||||
|
||||
@param Language1 Name of language 1
|
||||
@param Language2 Name of language 2
|
||||
|
||||
@retval TRUE same
|
||||
@retval FALSE not same
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
HiiCompareLanguage (
|
||||
IN CHAR8 *Language1,
|
||||
IN CHAR8 *Language2
|
||||
)
|
||||
{
|
||||
//
|
||||
// Porting Guide:
|
||||
// This library interface is simply obsolete.
|
||||
// Include the source code to user code.
|
||||
//
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; (Language1[Index] != 0) && (Language2[Index] != 0); Index++) {
|
||||
if (Language1[Index] != Language2[Index]) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (((Language1[Index] == 0) && (Language2[Index] == 0)) ||
|
||||
((Language1[Index] == 0) && (Language2[Index] != ';')) ||
|
||||
((Language1[Index] == ';') && (Language2[Index] != 0)) ||
|
||||
((Language1[Index] == ';') && (Language2[Index] != ';'))) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue