Revision: 13997
          http://edk2.svn.sourceforge.net/edk2/?rev=13997&view=rev
Author:   jcarsey
Date:     2012-12-13 21:26:22 +0000 (Thu, 13 Dec 2012)
Log Message:
-----------
ShellPkg: Updates to 'help' command

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Phillips <[email protected]>
reviewed-by: Jaben Carsey <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
    
trunk/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
    
trunk/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
    
trunk/edk2/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni
    
trunk/edk2/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni
    trunk/edk2/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c
    
trunk/edk2/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni

Modified: trunk/edk2/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
===================================================================
--- trunk/edk2/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c       
2012-12-13 21:11:21 UTC (rev 13996)
+++ trunk/edk2/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c       
2012-12-13 21:26:22 UTC (rev 13997)
@@ -334,8 +334,18 @@
   )
 {
   SHELL_COMMAND_INTERNAL_LIST_ENTRY *Node;
+  SHELL_COMMAND_INTERNAL_LIST_ENTRY *Command;
+  SHELL_COMMAND_INTERNAL_LIST_ENTRY *PrevCommand;
+  INTN LexicalMatchValue;
 
   //
+  // Initialize local variables.
+  //
+  Command = NULL;
+  PrevCommand = NULL;
+  LexicalMatchValue = 0;
+
+  //
   // ASSERTs for NULL parameters
   //
   ASSERT(CommandString  != NULL);
@@ -392,10 +402,41 @@
   }
 
   //
-  // add the new struct to the list
+  // Insert a new entry on top of the list
   //
-  InsertTailList (&mCommandList.Link, &Node->Link);
+  InsertHeadList (&mCommandList.Link, &Node->Link);
 
+  //
+  // Move a new registered command to its sorted ordered location in the list
+  //
+  for (Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode 
(&mCommandList.Link),
+        PrevCommand = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode 
(&mCommandList.Link)
+        ; !IsNull (&mCommandList.Link, &Command->Link)
+        ; Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode 
(&mCommandList.Link, &Command->Link)) {
+
+    //
+    // Get Lexical Comparison Value between PrevCommand and Command list entry
+    //
+    LexicalMatchValue = gUnicodeCollation->StriColl (
+                                             gUnicodeCollation,
+                                             PrevCommand->CommandString,
+                                             Command->CommandString
+                                             );
+
+    //
+    // Swap PrevCommand and Command list entry if PrevCommand list entry
+    // is alphabetically greater than Command list entry
+    //
+    if (LexicalMatchValue > 0){
+      Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *) SwapListEntries 
(&PrevCommand->Link, &Command->Link);
+    } else if (LexicalMatchValue < 0) {
+      //
+      // PrevCommand entry is lexically lower than Command entry
+      //
+      break;
+    }
+  }
+
   return (RETURN_SUCCESS);
 }
 

Modified: 
trunk/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
===================================================================
(Binary files differ)

Modified: 
trunk/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
===================================================================
(Binary files differ)

Modified: 
trunk/edk2/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni
===================================================================
(Binary files differ)

Modified: 
trunk/edk2/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni
===================================================================
(Binary files differ)

Modified: trunk/edk2/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c
===================================================================
--- trunk/edk2/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c       
2012-12-13 21:11:21 UTC (rev 13996)
+++ trunk/edk2/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c       
2012-12-13 21:26:22 UTC (rev 13997)
@@ -48,7 +48,9 @@
   CHAR16              *SectionToGetHelpOn;
   CHAR16              *HiiString;
   BOOLEAN             Found;
+  BOOLEAN             HelpPage;
 
+  HelpPage            = FALSE;
   ProblemParam        = NULL;
   ShellStatus         = SHELL_SUCCESS;
   OutText             = NULL;
@@ -109,6 +111,7 @@
         ASSERT(SectionToGetHelpOn == NULL);
         StrnCatGrow(&SectionToGetHelpOn, NULL, L"NAME", 0);
       } else {
+        HelpPage = TRUE;
         ASSERT(SectionToGetHelpOn == NULL);
         //
         // Get the section name for the given command name
@@ -119,7 +122,10 @@
           StrnCatGrow(&SectionToGetHelpOn, NULL, L"NAME,SYNOPSIS", 0);
         } else if (ShellCommandLineGetFlag(Package, L"-verbose") || 
ShellCommandLineGetFlag(Package, L"-v")) {
         } else {
-          StrnCatGrow(&SectionToGetHelpOn, NULL, L"NAME", 0);
+          //
+          // The output of help <command> will display NAME, SYNOPSIS, 
OPTIONS, DESCRIPTION, and EXAMPLES sections.
+          //
+          StrnCatGrow (&SectionToGetHelpOn, NULL, 
L"NAME,SYNOPSIS,OPTIONS,DESCRIPTION,EXAMPLES", 0);
         }
       }
 
@@ -139,6 +145,12 @@
             ; CommandList != NULL && !IsListEmpty(&CommandList->Link) && 
!IsNull(&CommandList->Link, &Node->Link)
             ; Node = (COMMAND_LIST*)GetNextNode(&CommandList->Link, 
&Node->Link)
            ){
+          //
+          // Checking execution break flag when print multiple command help 
information.
+          //
+          if (ShellGetExecutionBreakFlag ()) {
+            break;
+          } 
           if ((gUnicodeCollation->MetaiMatch(gUnicodeCollation, 
Node->CommandString, CommandToGetHelpOn)) ||
              (gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL) != NULL && 
(gUnicodeCollation->MetaiMatch(gUnicodeCollation, Node->CommandString, 
(CHAR16*)(gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL)))))) {
             //
@@ -153,16 +165,44 @@
               }
               ShellStatus = SHELL_NOT_FOUND;
             } else {
-              while (OutText[StrLen(OutText)-1] == L'\r' || 
OutText[StrLen(OutText)-1] == L'\n' || OutText[StrLen(OutText)-1] == L' ') {
-                OutText[StrLen(OutText)-1] = CHAR_NULL;
+              if (HelpPage == TRUE) {
+                 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN 
(STR_HELP_PAGE_COMMAND), gShellLevel3HiiHandle, OutText);
+              } else {
+                while (OutText[StrLen(OutText)-1] == L'\r' || 
OutText[StrLen(OutText)-1] == L'\n' || OutText[StrLen(OutText)-1] == L' ') {
+                  OutText[StrLen(OutText)-1] = CHAR_NULL;
+                }
+                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_COMMAND), 
gShellLevel3HiiHandle, Node->CommandString, OutText);
               }
-              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_COMMAND), 
gShellLevel3HiiHandle, Node->CommandString, OutText);
               FreePool(OutText);
               OutText = NULL;
               Found = TRUE;
             }
           }
         }
+        //
+        // Search the .man file for Shell applications (Shell external 
commands).
+        //
+        if (!Found) {
+          Status = gEfiShellProtocol->GetHelpText (CommandToGetHelpOn, 
SectionToGetHelpOn, &OutText);
+          if (EFI_ERROR(Status) || OutText == NULL) {
+            if (Status == EFI_DEVICE_ERROR) {
+              ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), 
gShellLevel3HiiHandle, CommandToGetHelpOn);
+            } else {
+              ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), 
gShellLevel3HiiHandle, CommandToGetHelpOn);
+            }
+            ShellStatus = SHELL_NOT_FOUND;
+          } else {
+            while (OutText[StrLen (OutText) - 1] == L'\r' || OutText[StrLen 
(OutText) - 1] == L'\n' || OutText[StrLen (OutText) - 1] == L' ') {
+              OutText[StrLen (OutText)-1] = CHAR_NULL;
+            }
+            ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_COMMAND), 
gShellLevel3HiiHandle, CommandToGetHelpOn, OutText);
+            if (OutText != NULL) {
+              FreePool (OutText);
+              OutText = NULL;
+            }
+            Found = TRUE;
+          }
+        }
       }
 
       if (!Found && ShellStatus == SHELL_SUCCESS) {

Modified: 
trunk/edk2/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
===================================================================
(Binary files differ)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to