mirror of https://github.com/acidanthera/audk.git
Update HiiDataBase driver to use GetBestLanguage() for matching RFC 4646 languages.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8262 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
62e71e2fbe
commit
844390f7d5
|
@ -784,6 +784,7 @@ InsertStringPackage (
|
|||
EFI_STATUS Status;
|
||||
EFI_HII_PACKAGE_HEADER PackageHeader;
|
||||
CHAR8 *Language;
|
||||
CHAR8 *MatchedLanguage;
|
||||
UINT32 LanguageSize;
|
||||
LIST_ENTRY *Link;
|
||||
|
||||
|
@ -809,8 +810,10 @@ 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);
|
||||
if (HiiCompareLanguage (Language, StringPackage->StringPkgHdr->Language)) {
|
||||
MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);
|
||||
if (MatchedLanguage != NULL) {
|
||||
FreePool (Language);
|
||||
FreePool (MatchedLanguage);
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1687,24 +1687,6 @@ 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,6 +968,7 @@ 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;
|
||||
|
@ -1014,7 +1015,9 @@ HiiNewString (
|
|||
Link = Link->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);
|
||||
if (MatchedLanguage != NULL) {
|
||||
FreePool (MatchedLanguage);
|
||||
Matched = TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -1320,6 +1323,7 @@ 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;
|
||||
|
@ -1353,7 +1357,9 @@ HiiGetString (
|
|||
Link = Link->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);
|
||||
if (MatchedLanguage != NULL) {
|
||||
FreePool (MatchedLanguage);
|
||||
Status = GetStringWorker (Private, StringPackage, StringId, String, StringSize, StringFontInfo);
|
||||
if (Status != EFI_NOT_FOUND) {
|
||||
return Status;
|
||||
|
@ -1421,6 +1427,7 @@ 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;
|
||||
|
@ -1446,7 +1453,9 @@ HiiSetString (
|
|||
Link = Link->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) Language, NULL);
|
||||
if (MatchedLanguage != NULL) {
|
||||
FreePool (MatchedLanguage);
|
||||
OldPackageLen = StringPackage->StringPkgHdr->Header.Length;
|
||||
Status = SetStringWorker (
|
||||
Private,
|
||||
|
@ -1603,6 +1612,7 @@ HiiGetSecondaryLanguages (
|
|||
HII_STRING_PACKAGE_INSTANCE *StringPackage;
|
||||
CHAR8 *Languages;
|
||||
UINTN ResultSize;
|
||||
CHAR8 *MatchedLanguage;
|
||||
|
||||
if (This == NULL || PackageList == NULL || FirstLanguage == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
@ -1635,7 +1645,9 @@ HiiGetSecondaryLanguages (
|
|||
Link1 = Link1->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link1, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) FirstLanguage)) {
|
||||
MatchedLanguage = GetBestLanguage (StringPackage->StringPkgHdr->Language, FALSE, (CHAR8 *) FirstLanguage, NULL);
|
||||
if (MatchedLanguage != NULL) {
|
||||
FreePool (MatchedLanguage);
|
||||
Languages = StringPackage->StringPkgHdr->Language;
|
||||
//
|
||||
// Language is a series of ';' terminated strings, first one is primary
|
||||
|
@ -1663,41 +1675,3 @@ 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