public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Liming Gao" <liming.gao@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Tom Zhao <tzhao@solarflare.com>
Subject: FW: [PATCH v1 1/1] MdePkg: UefiLib: Add a function to check if a language is supported
Date: Wed, 21 Aug 2019 06:50:23 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4D931A@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: 1b9545dc-b3aa-6f65-47e9-0304ed5bd89c@solarflare.com

Send it to new mail list. 

-----Original Message-----
From: Gao, Liming 
Sent: Wednesday, August 21, 2019 2:33 PM
To: 'Tom Zhao' <tzhao@solarflare.com>; edk2-devel@lists.01.org
Cc: Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [PATCH v1 1/1] MdePkg: UefiLib: Add a function to check if a language is supported

Tom:
  Please submit BZ https://bugzilla.tianocore.org/ for this request, and please introduce this API usage model. 
  Which module will be updated to consume this API?

>-----Original Message-----
>From: Tom Zhao [mailto:tzhao@solarflare.com]
>Sent: Wednesday, August 21, 2019 12:13 AM
>To: edk2-devel@lists.01.org
>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
><liming.gao@intel.com>
>Subject: [PATCH v1 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 <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
>
>The information contained in this message is confidential and is intended for
>the addressee(s) only. If you have received this message in error, please
>notify the sender immediately and delete the message. Unless you are an
>addressee (or authorized to receive for an addressee), you may not use, copy
>or disclose to anyone this message or any information contained in this
>message. The unauthorized use, disclosure, copying or alteration of this
>message is strictly prohibited.

       reply	other threads:[~2019-08-21  6:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1b9545dc-b3aa-6f65-47e9-0304ed5bd89c@solarflare.com>
2019-08-21  6:50 ` Liming Gao [this message]
2019-08-21 10:23 ` [PATCH v1 1/1] MdePkg: UefiLib: Add a function to check if a language is supported Tom Zhao
2019-08-21 13:34   ` [edk2-devel] " Liming Gao
2019-08-21 14:25     ` Tom Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E4D931A@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox