From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: solarflare.com, ip: 67.231.154.164, mailfrom: tzhao@solarflare.com) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by groups.io with SMTP; Wed, 21 Aug 2019 03:23:30 -0700 X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us4.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 1CCAD280057 for ; Wed, 21 Aug 2019 10:23:29 +0000 (UTC) Received: from [10.17.20.221] (10.17.20.221) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 21 Aug 2019 11:23:24 +0100 Subject: [PATCH v1 1/1] MdePkg: UefiLib: Add a function to check if a language is supported References: <1b9545dc-b3aa-6f65-47e9-0304ed5bd89c@solarflare.com> To: From: "Tom Zhao" X-Forwarded-Message-Id: <1b9545dc-b3aa-6f65-47e9-0304ed5bd89c@solarflare.com> Message-ID: Date: Wed, 21 Aug 2019 11:23:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1b9545dc-b3aa-6f65-47e9-0304ed5bd89c@solarflare.com> X-Originating-IP: [10.17.20.221] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24860.003 X-TM-AS-Result: No-9.474500-8.000000-10 X-TMASE-MatchedRID: TyMThhr6WqXoIFWS3x7BRIEMv3ouDK4xvIlhCV2dh5u1eX0jEQ9c6oYM M3r3suSe0NmT5OIoWwIzZle0l/yWKOt+XMwb8iOmPaBTJyy84wUO9z+P2gwiBSLT+St7cam6cij MZrr2iZ2t2gtuWr1Lmtp/Qghje9YunU4Y8605Xzn/Te3t5cJMG805KBm2/UMhB4sIhfTjqIHMRU Madz4R8nlBiMWIMKVz0AAj4Lcjr8XVWxUk3iLQj2hQCsqhuTNier1wlVoR6TQbVUVEY6U/r80Yl G6Yuf03IDr6DBTg5gXgdEytl3jQUO8/qMB6+F5bB7MHoYnrMyHHbZsG8T5ZjjdHHXXKh5RC3SlE gVuyN9s6LKHlv1otzZsoi2XrUn/JyeMtMD9QOgAXx02iyeDNzF1FkXVL+ky7dTWH+1KgSfzqE4t J+Doj97OpzzGjcj//xFxJJIPDxxacEDP5kMizN/7xEUzm3Fjh0HIRlf/TNbBUzXv81F2VFNR5JC Zt7Ep5wRSUP0inpeI= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--9.474500-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24860.003 X-MDID: 1566383009-jKa-TBMHuX6t Content-Type: multipart/alternative; boundary="------------6A9507202A7D60C6FF746E59" Content-Language: en-US --------------6A9507202A7D60C6FF746E59 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit -------- Forwarded Message -------- Subject: [PATCH v1 1/1] MdePkg: UefiLib: Add a function to check if a language is supported Date: Tue, 20 Aug 2019 17:13:19 +0100 From: Tom Zhao To: edk2-devel@lists.01.org CC: michael.d.kinney@intel.com, liming.gao@intel.com 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 Cc: Liming Gao Signed-off-by: Tom Zhao --- MdePkg/Include/Library/UefiLib.h | 16 ++++++ MdePkg/Library/UefiLib/UefiLib.c | 59 +++++++++++++------- 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/UefiLib.h index 1650f30ddbc6..9dd170cbe2bf 100644 --- a/MdePkg/Include/Library/UefiLib.h +++ b/MdePkg/Include/Library/UefiLib.h @@ -461,6 +461,22 @@ EfiTestChildHandle ( IN CONST EFI_GUID *ProtocolGuid ); +/** + * This function checks the supported languages list for a target language + * + * @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. diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/UefiLib.c index daa4af762e62..56281d25fd99 100644 --- a/MdePkg/Library/UefiLib/UefiLib.c +++ b/MdePkg/Library/UefiLib/UefiLib.c @@ -640,6 +640,35 @@ EfiTestChildHandle ( return Status; } +/** + * This function checks the supported languages list for a target language + * + * @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. @@ -800,24 +829,19 @@ LookupUnicodeString2 ( // Make sure Language is in the set of Supported Languages // Found = FALSE; - while (*SupportedLanguages != 0) { - if (Iso639Language) { + if (Iso639Language) { + while (*SupportedLanguages != 0) { if (CompareIso639LanguageCode (Language, SupportedLanguages)) { Found = TRUE; break; } 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 // @@ -1099,24 +1123,17 @@ AddUnicodeString2 ( // Make sure Language is a member of SupportedLanguages // Found = FALSE; - while (*SupportedLanguages != 0) { - if (Iso639Language) { + if (Iso639Language) { + while (*SupportedLanguages != 0) { if (CompareIso639LanguageCode (Language, SupportedLanguages)) { Found = TRUE; break; } 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 // -- 2.21.0 --------------6A9507202A7D60C6FF746E59 Content-Type: text/html; charset="windows-1252" Content-Transfer-Encoding: 7bit




-------- Forwarded Message --------
Subject: [PATCH v1 1/1] MdePkg: UefiLib: Add a function to check if a language is supported
Date: Tue, 20 Aug 2019 17:13:19 +0100
From: Tom Zhao <tzhao@solarflare.com>
To: edk2-devel@lists.01.org
CC: michael.d.kinney@intel.com, liming.gao@intel.com


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>
---
MdePkg/Include/Library/UefiLib.h | 16 ++++++
MdePkg/Library/UefiLib/UefiLib.c | 59 +++++++++++++-------
2 files changed, 54 insertions(+), 21 deletions(-)

diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/UefiLib.h
index 1650f30ddbc6..9dd170cbe2bf 100644
--- a/MdePkg/Include/Library/UefiLib.h
+++ b/MdePkg/Include/Library/UefiLib.h
@@ -461,6 +461,22 @@ EfiTestChildHandle (
IN CONST EFI_GUID *ProtocolGuid
);
+/**
+ * This function checks the supported languages list for a target language
+ *
+ * @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.
diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/UefiLib.c
index daa4af762e62..56281d25fd99 100644
--- a/MdePkg/Library/UefiLib/UefiLib.c
+++ b/MdePkg/Library/UefiLib/UefiLib.c
@@ -640,6 +640,35 @@ EfiTestChildHandle (
return Status;
}
+/**
+ * This function checks the supported languages list for a target language
+ *
+ * @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.
@@ -800,24 +829,19 @@ LookupUnicodeString2 (
// Make sure Language is in the set of Supported Languages
//
Found = FALSE;
- while (*SupportedLanguages != 0) {
- if (Iso639Language) {
+ if (Iso639Language) {
+ while (*SupportedLanguages != 0) {
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
Found = TRUE;
break;
}
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
//
@@ -1099,24 +1123,17 @@ AddUnicodeString2 (
// Make sure Language is a member of SupportedLanguages
//
Found = FALSE;
- while (*SupportedLanguages != 0) {
- if (Iso639Language) {
+ if (Iso639Language) {
+ while (*SupportedLanguages != 0) {
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
Found = TRUE;
break;
}
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
//
-- 
2.21.0

--------------6A9507202A7D60C6FF746E59--