From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: liming.gao@intel.com) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Wed, 21 Aug 2019 06:34:06 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2019 06:34:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,412,1559545200"; d="scan'208,217";a="378948123" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga006.fm.intel.com with ESMTP; 21 Aug 2019 06:34:05 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 21 Aug 2019 06:34:05 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 21 Aug 2019 06:34:05 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 21 Aug 2019 06:34:04 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.112]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.250]) with mapi id 14.03.0439.000; Wed, 21 Aug 2019 21:34:03 +0800 From: "Liming Gao" To: "devel@edk2.groups.io" , "tzhao@solarflare.com" Subject: Re: [edk2-devel] [PATCH v1 1/1] MdePkg: UefiLib: Add a function to check if a language is supported Thread-Topic: [edk2-devel] [PATCH v1 1/1] MdePkg: UefiLib: Add a function to check if a language is supported Thread-Index: AQHVV3JC3RKVOLH0oEWy1buMKq+AsqcE3+cAgAC6uPA= Date: Wed, 21 Aug 2019 13:34:03 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4D94EA@SHSMSX104.ccr.corp.intel.com> References: <1b9545dc-b3aa-6f65-47e9-0304ed5bd89c@solarflare.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMWRmMTJhMDItMGNiYy00ZjZkLTg4MTYtYzc4NjdmNjk0NDAxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoidnJxRmVaVmRWemRpb1JLY1AxT2R5OHJPNzBFZlBHcDg5aHhvbVZ4MDFzdk5IdHpSbTFMMWFLZlFcL1htalwvUzJiIn0= dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_4A89E2EF3DFEDB4C8BFDE51014F606A14E4D94EASHSMSX104ccrcor_" --_000_4A89E2EF3DFEDB4C8BFDE51014F606A14E4D94EASHSMSX104ccrcor_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Tom: Can you send the patch by the command 'git send-email xxx.patch'? If so,= I can extract the patch from the mail. If this function is only used in UefiLib, how about define it as the int= ernal function? Thanks Liming From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Tom = Zhao Sent: Wednesday, August 21, 2019 6:23 PM To: devel@edk2.groups.io Subject: [edk2-devel] [PATCH v1 1/1] MdePkg: UefiLib: Add a function to ch= eck if a language is supported -------- Forwarded Message -------- Subject: [PATCH v1 1/1] MdePkg: UefiLib: Add a function to check if a language is s= upported 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/Uef= iLib.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 languag= e + * + * @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/Uef= iLib.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 languag= e + * + * @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 !=3D 0) { + for (Index =3D 0; SupportedLanguages[Index] !=3D 0 && SupportedLanguages= [Index] !=3D ';'; Index++); + if ((AsciiStrnCmp(SupportedLanguages, TargetLanguage, Index) =3D=3D 0) &= & (TargetLanguage[Index] =3D=3D 0)) { + return EFI_SUCCESS; + } + SupportedLanguages +=3D Index; + for (; *SupportedLanguages !=3D 0 && *SupportedLanguages =3D=3D ';'; Sup= portedLanguages++); + } + + 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 =3D FALSE; - while (*SupportedLanguages !=3D 0) { - if (Iso639Language) { + if (Iso639Language) { + while (*SupportedLanguages !=3D 0) { if (CompareIso639LanguageCode (Language, SupportedLanguages)) { Found =3D TRUE; break; } SupportedLanguages +=3D 3; - } else { - for (Index =3D 0; SupportedLanguages[Index] !=3D 0 && SupportedLanguages= [Index] !=3D ';'; Index++); - if ((AsciiStrnCmp(SupportedLanguages, Language, Index) =3D=3D 0) && (Lan= guage[Index] =3D=3D 0)) { - Found =3D TRUE; - break; - } - SupportedLanguages +=3D Index; - for (; *SupportedLanguages !=3D 0 && *SupportedLanguages =3D=3D ';'; Sup= portedLanguages++); } + } else { + Found =3D !IsLanguageSupported(Language, SupportedLanguages); } + // // If Language is not a member of SupportedLanguages, then return EFI_UNSU= PPORTED // @@ -1099,24 +1123,17 @@ AddUnicodeString2 ( // Make sure Language is a member of SupportedLanguages // Found =3D FALSE; - while (*SupportedLanguages !=3D 0) { - if (Iso639Language) { + if (Iso639Language) { + while (*SupportedLanguages !=3D 0) { if (CompareIso639LanguageCode (Language, SupportedLanguages)) { Found =3D TRUE; break; } SupportedLanguages +=3D 3; - } else { - for (Index =3D 0; SupportedLanguages[Index] !=3D 0 && SupportedLanguages= [Index] !=3D ';'; Index++); - if (AsciiStrnCmp(SupportedLanguages, Language, Index) =3D=3D 0) { - Found =3D TRUE; - break; - } - SupportedLanguages +=3D Index; - for (; *SupportedLanguages !=3D 0 && *SupportedLanguages =3D=3D ';'; Sup= portedLanguages++); } + } else { + Found =3D !IsLanguageSupported(Language, SupportedLanguages); } - // // If Language is not a member of SupportedLanguages, then return EFI_UNSU= PPORTED // -- 2.21.0 --_000_4A89E2EF3DFEDB4C8BFDE51014F606A14E4D94EASHSMSX104ccrcor_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Tom:

  Can you send t= he patch by the command ‘git send-email xxx.patch’? If so, I ca= n extract the patch from the mail.

 

  If this functi= on is only used in UefiLib, how about define it as the internal function?

 

Thanks

Liming

From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of To= m Zhao
Sent: Wednesday, August 21, 2019 6:23 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] [PATCH v1 1/1] MdePkg: UefiLib: Add a functio= n to check if a language is supported

 

 



-------- 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 <mic= hael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@inte= l.com>
Signed-off-by: Tom Zhao <tzhao@= solarflare.com>
---
MdePkg/Include/Library/UefiLib.h | 16 ++++++
MdePkg/Library/UefiLib/UefiLib.c | 59 +++++++&= #43;+++++-------
2 files changed, 54 insertions(+), 21 deletions(-)

diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/Uef= iLib.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 lan= guage
+ *
+ * @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/Uef= iLib.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 lan= guage
+ *
+ * @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 !=3D 0) {
+ for (Index =3D 0; SupportedLanguages[Index] !=3D 0 && Suppor= tedLanguages[Index] !=3D ';'; Index++);
+ if ((AsciiStrnCmp(SupportedLanguages, TargetLanguage, Index) =3D=3D = 0) && (TargetLanguage[Index] =3D=3D 0)) {
+ return EFI_SUCCESS;
+ }
+ SupportedLanguages +=3D Index;
+ for (; *SupportedLanguages !=3D 0 && *SupportedLanguages =3D= = =3D ';'; 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 =3D FALSE;
- while (*SupportedLanguages !=3D 0) {
- if (Iso639Language) {
+ if (Iso639Language) {
+ while (*SupportedLanguages !=3D 0) {
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
Found =3D TRUE;
break;
}
SupportedLanguages +=3D 3;
- } else {
- for (Index =3D 0; SupportedLanguages[Index] !=3D 0 && SupportedL= anguages[Index] !=3D ';'; Index++);
- if ((AsciiStrnCmp(SupportedLanguages, Language, Index) =3D=3D 0) &&a= mp; (Language[Index] =3D=3D 0)) {
- Found =3D TRUE;
- break;
- }
- SupportedLanguages +=3D Index;
- for (; *SupportedLanguages !=3D 0 && *SupportedLanguages =3D=3D = ';'; SupportedLanguages++);
}
+ } else {
+ Found =3D !IsLanguageSupported(Language, SupportedLanguages);
}
+
//
// If Language is not a member of SupportedLanguages, then return EFI_UNSU= PPORTED
//
@@ -1099,24 +1123,17 @@ AddUnicodeString2 (
// Make sure Language is a member of SupportedLanguages
//
Found =3D FALSE;
- while (*SupportedLanguages !=3D 0) {
- if (Iso639Language) {
+ if (Iso639Language) {
+ while (*SupportedLanguages !=3D 0) {
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
Found =3D TRUE;
break;
}
SupportedLanguages +=3D 3;
- } else {
- for (Index =3D 0; SupportedLanguages[Index] !=3D 0 && SupportedL= anguages[Index] !=3D ';'; Index++);
- if (AsciiStrnCmp(SupportedLanguages, Language, Index) =3D=3D 0) {
- Found =3D TRUE;
- break;
- }
- SupportedLanguages +=3D Index;
- for (; *SupportedLanguages !=3D 0 && *SupportedLanguages =3D=3D = ';'; SupportedLanguages++);
}
+ } else {
+ Found =3D !IsLanguageSupported(Language, SupportedLanguages);
}
-
//
// If Language is not a member of SupportedLanguages, then return EFI_UNSU= PPORTED
//

-- 
2.21.0
 

--_000_4A89E2EF3DFEDB4C8BFDE51014F606A14E4D94EASHSMSX104ccrcor_--