From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: liming.gao@intel.com) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by groups.io with SMTP; Mon, 16 Sep 2019 18:42:08 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Sep 2019 18:42:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,514,1559545200"; d="scan'208";a="386393871" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga005.fm.intel.com with ESMTP; 16 Sep 2019 18:42:06 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 16 Sep 2019 18:42:06 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 16 Sep 2019 18:42:05 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.32]) by shsmsx102.ccr.corp.intel.com ([169.254.2.113]) with mapi id 14.03.0439.000; Tue, 17 Sep 2019 09:42:04 +0800 From: "Liming Gao" To: "devel@edk2.groups.io" , "Gao, Liming" , "tzhao@solarflare.com" CC: "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH v5 1/1] MdePkg: UefiLib: Add a function to check if a language is supported Thread-Topic: [edk2-devel] [PATCH v5 1/1] MdePkg: UefiLib: Add a function to check if a language is supported Thread-Index: AQHVaK7b9aoUDSZKfku7yGxiEmhoQKcmkJOwgAiQGXA= Date: Tue, 17 Sep 2019 01:42:03 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4F8CA1@SHSMSX104.ccr.corp.intel.com> References: <943c40b7-5863-eb26-2577-121ec1ca16fb@solarflare.com> <15C36A18D1048D26.28990@groups.io> In-Reply-To: <15C36A18D1048D26.28990@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Push @ea331a5c21f7d71980fe0ea2e4aa425474f8ffb2 >-----Original Message----- >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of >Liming Gao >Sent: Wednesday, September 11, 2019 10:56 PM >To: devel@edk2.groups.io; tzhao@solarflare.com >Cc: Kinney, Michael D >Subject: Re: [edk2-devel] [PATCH v5 1/1] MdePkg: UefiLib: Add a function = to >check if a language is supported > >Reviewed-by: Liming Gao > >> -----Original Message----- >> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of >Tom Zhao >> Sent: Wednesday, September 11, 2019 10:40 PM >> To: devel@edk2.groups.io >> Cc: Kinney, Michael D ; Gao, Liming > >> Subject: [edk2-devel] [PATCH v5 1/1] 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 >> Cc: Liming Gao >> Signed-off-by: Tom Zhao >> --- >> >> Notes: >> v3: >> - Add comment about usage for RFC4646 and ISO-639 >> v4: >> - Remove reference to CompareISO639Lang >> v5: >> - Change doxygen format to use @retval >> >> MdePkg/Include/Library/UefiLib.h | 17 ++++++ >> MdePkg/Library/UefiLib/UefiLib.c | 60 +++++++++++++------- >> 2 files changed, 56 insertions(+), 21 deletions(-) >> >> diff --git a/MdePkg/Include/Library/UefiLib.h >> b/MdePkg/Include/Library/UefiLib.h >> index 1650f30ddbc6..65e7c90eb94b 100644 >> --- a/MdePkg/Include/Library/UefiLib.h >> +++ b/MdePkg/Include/Library/UefiLib.h >> @@ -461,6 +461,23 @@ EfiTestChildHandle ( >> IN CONST EFI_GUID *ProtocolGuid >> ); >> +/** >> + * This function checks the supported languages list for a target lang= uage, >> + * This only supports RFC 4646 Languages. >> + * >> + * @param SupportedLanguages The supported languages >> + * @param TargetLanguage The target language >> + * >> + * @retval EFI_SUCCESS The target language is supported >> + * @retval EFI_UNSUPPORTED The target language is unsupported >> + */ >> +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..71eba51257f6 100644 >> --- a/MdePkg/Library/UefiLib/UefiLib.c >> +++ b/MdePkg/Library/UefiLib/UefiLib.c >> @@ -640,6 +640,36 @@ EfiTestChildHandle ( >> return Status; >> } >> +/** >> + * This function checks the supported languages list for a target lang= uage, >> + * This only supports RFC 4646 Languages. >> + * >> + * @param SupportedLanguages The supported languages >> + * @param TargetLanguage The target language >> + * >> + * @retval EFI_SUCCESS The target language is supported >> + * @retval EFI_UNSUPPORTED The target language is unsupported >> + */ >> +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 ';= '; >> SupportedLanguages++); >> + } >> + >> + return EFI_UNSUPPORTED; >> +} >> + >> /** >> This function looks up a Unicode string in UnicodeStringTable. >> @@ -800,24 +830,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)= && >> (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_UNSUPPORTED >> // >> @@ -1099,24 +1124,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 = ';'; >> SupportedLanguages++); >> } >> + } else { >> + Found =3D !IsLanguageSupported(Language, SupportedLanguages); >> } >> - >> // >> // If Language is not a member of SupportedLanguages, then return >> EFI_UNSUPPORTED >> // >> -- >> 2.21.0 >> >> >> > > >