]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
Refine the select language logic.
[mirror_edk2.git] / ShellPkg / Library / UefiHandleParsingLib / UefiHandleParsingLib.c
index 45ee9bd5d00164ff7f7cfbcf19a0b1fed062ce65..515fab3294d1dd4ce2c93168df937f3c04c9fbc3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides interface to advanced shell functionality for parsing both handle and protocol database.\r
 \r
-  Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -414,19 +414,15 @@ DevicePathProtocolDumpInformation(
   CHAR16                            *Temp;\r
   CHAR16                            *Temp2;\r
   EFI_STATUS                        Status;\r
-  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL  *DevPathToText;\r
   Temp = NULL;\r
 \r
-  Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID**)&DevPathToText);\r
+  Status = gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
   if (!EFI_ERROR(Status)) {\r
-    Status = gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
-    if (!EFI_ERROR(Status)) {\r
-      //\r
-      // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)\r
-      //\r
-      Temp = DevPathToText->ConvertDevicePathToText(DevPath, TRUE, TRUE);\r
-      gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);\r
-    }\r
+    //\r
+    // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)\r
+    //\r
+    Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);\r
+    gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);\r
   }\r
   if (!Verbose && Temp != NULL && StrLen(Temp) > 30) {\r
     Temp2 = NULL;\r
@@ -782,18 +778,21 @@ GetGuidFromStringName(
 /**\r
   Get best support language for this driver.\r
   \r
-  First base on the current platform used language to search,Second base on the \r
-  default language to search. The caller need to free the buffer of the best \r
-  language.\r
+  First base on the user input language  to search, second base on the current \r
+  platform used language to search, third get the first language from the \r
+  support language list. The caller need to free the buffer of the best language.\r
 \r
   @param[in] SupportedLanguages      The support languages for this driver.\r
+  @param[in] InputLanguage           The user input language.\r
   @param[in] Iso639Language          Whether get language for ISO639.\r
 \r
   @return                            The best support language for this driver.\r
 **/\r
 CHAR8 *\r
+EFIAPI\r
 GetBestLanguageForDriver (\r
-  IN CONST CHAR8  *SupportedLanguages, \r
+  IN CONST CHAR8  *SupportedLanguages,\r
+  IN CONST CHAR8  *InputLanguage,\r
   IN BOOLEAN      Iso639Language\r
   )\r
 {\r
@@ -805,8 +804,9 @@ GetBestLanguageForDriver (
   BestLanguage = GetBestLanguage(\r
                    SupportedLanguages,\r
                    Iso639Language,\r
+                   (InputLanguage != NULL) ? InputLanguage : "",\r
                    (LanguageVariable != NULL) ? LanguageVariable : "",\r
-                   Iso639Language ? "en" : "en-US",\r
+                   SupportedLanguages,\r
                    NULL\r
                    );\r
 \r
@@ -849,12 +849,8 @@ GetStringNameFromHandle(
     NULL,\r
     EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
   if (!EFI_ERROR(Status)) {\r
-    if (Language == NULL) {\r
-      BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, FALSE);\r
-      Language = BestLang;\r
-    }\r
-    Status = CompNameStruct->GetDriverName(CompNameStruct, (CHAR8*)Language, &RetVal);\r
-\r
+    BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);\r
+    Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);\r
     if (BestLang != NULL) {\r
       FreePool (BestLang);\r
       BestLang = NULL;\r
@@ -871,12 +867,8 @@ GetStringNameFromHandle(
     NULL,\r
     EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
   if (!EFI_ERROR(Status)) {\r
-    if (Language == NULL) {\r
-      BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, FALSE);\r
-      Language = BestLang;\r
-    }\r
-    Status = CompNameStruct->GetDriverName(CompNameStruct, (CHAR8*)Language, &RetVal);\r
-    \r
+    BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);\r
+    Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);\r
     if (BestLang != NULL) {\r
       FreePool (BestLang);\r
     }\r