From d51088b764304f920a41a186bef45ca789e080dc Mon Sep 17 00:00:00 2001 From: jcarsey Date: Thu, 13 Dec 2012 21:26:22 +0000 Subject: ShellPkg: Updates to 'help' command Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chris Phillips reviewed-by: Jaben Carsey git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13997 6f19259b-4bc3-4df7-8a09-765794883524 --- .../UefiShellCommandLib/UefiShellCommandLib.c | 45 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'ShellPkg/Library/UefiShellCommandLib') diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c index fb44768c0b..66a242f66f 100644 --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c @@ -334,6 +334,16 @@ ShellCommandRegisterCommandName ( ) { 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 @@ -392,9 +402,40 @@ ShellCommandRegisterCommandName ( } // - // 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); } -- cgit v1.2.3