mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 21:54:27 +02:00
MdePkg: UefiLib: Add a function to check if a language is supported
Add a function that checks if a target language is in the supported languages list. Add some calls to this function where appropriate in UefiLib.c Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Tom Zhao <tzhao@solarflare.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
26fc074a5f
commit
ea331a5c21
@ -461,6 +461,23 @@ EfiTestChildHandle (
|
|||||||
IN CONST EFI_GUID *ProtocolGuid
|
IN CONST EFI_GUID *ProtocolGuid
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function checks the supported languages list for a target language,
|
||||||
|
* This only supports RFC 4646 Languages.
|
||||||
|
*
|
||||||
|
* @param SupportedLanguages The supported languages
|
||||||
|
* @param TargetLanguage The target language
|
||||||
|
*
|
||||||
|
* @return Returns EFI_SUCCESS if the language is supported,
|
||||||
|
* EFI_UNSUPPORTED otherwise
|
||||||
|
*/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
IsLanguageSupported (
|
||||||
|
IN CONST CHAR8 *SupportedLanguages,
|
||||||
|
IN CONST CHAR8 *TargetLanguage
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function looks up a Unicode string in UnicodeStringTable.
|
This function looks up a Unicode string in UnicodeStringTable.
|
||||||
|
|
||||||
|
@ -640,6 +640,36 @@ EfiTestChildHandle (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function checks the supported languages list for a target language,
|
||||||
|
* This only supports RFC 4646 Languages.
|
||||||
|
*
|
||||||
|
* @param SupportedLanguages The supported languages
|
||||||
|
* @param TargetLanguage The target language
|
||||||
|
*
|
||||||
|
* @return Returns EFI_SUCCESS if the language is supported,
|
||||||
|
* EFI_UNSUPPORTED otherwise
|
||||||
|
*/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
IsLanguageSupported (
|
||||||
|
IN CONST CHAR8 *SupportedLanguages,
|
||||||
|
IN CONST CHAR8 *TargetLanguage
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN Index;
|
||||||
|
while (*SupportedLanguages != 0) {
|
||||||
|
for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);
|
||||||
|
if ((AsciiStrnCmp(SupportedLanguages, TargetLanguage, Index) == 0) && (TargetLanguage[Index] == 0)) {
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
SupportedLanguages += Index;
|
||||||
|
for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function looks up a Unicode string in UnicodeStringTable.
|
This function looks up a Unicode string in UnicodeStringTable.
|
||||||
|
|
||||||
@ -800,24 +830,19 @@ LookupUnicodeString2 (
|
|||||||
// Make sure Language is in the set of Supported Languages
|
// Make sure Language is in the set of Supported Languages
|
||||||
//
|
//
|
||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
while (*SupportedLanguages != 0) {
|
if (Iso639Language) {
|
||||||
if (Iso639Language) {
|
while (*SupportedLanguages != 0) {
|
||||||
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
|
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
|
||||||
Found = TRUE;
|
Found = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SupportedLanguages += 3;
|
SupportedLanguages += 3;
|
||||||
} else {
|
|
||||||
for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);
|
|
||||||
if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {
|
|
||||||
Found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SupportedLanguages += Index;
|
|
||||||
for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Found = !IsLanguageSupported(Language, SupportedLanguages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED
|
// If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED
|
||||||
//
|
//
|
||||||
@ -1099,24 +1124,17 @@ AddUnicodeString2 (
|
|||||||
// Make sure Language is a member of SupportedLanguages
|
// Make sure Language is a member of SupportedLanguages
|
||||||
//
|
//
|
||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
while (*SupportedLanguages != 0) {
|
if (Iso639Language) {
|
||||||
if (Iso639Language) {
|
while (*SupportedLanguages != 0) {
|
||||||
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
|
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
|
||||||
Found = TRUE;
|
Found = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SupportedLanguages += 3;
|
SupportedLanguages += 3;
|
||||||
} else {
|
|
||||||
for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);
|
|
||||||
if (AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) {
|
|
||||||
Found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SupportedLanguages += Index;
|
|
||||||
for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Found = !IsLanguageSupported(Language, SupportedLanguages);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED
|
// If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user