summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorTapan Shah <tapandshah@hp.com>2014-08-29 20:43:08 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2014-08-29 20:43:08 +0000
commit4ba9b812daf1695bc5f6ac99504e53569297c2bf (patch)
tree4524c1c461a189973ea5685c5139992798cdc997 /ShellPkg
parent227a4b1c489308275bfbb955c4fd2f3f36e7a04d (diff)
downloadedk2-platforms-4ba9b812daf1695bc5f6ac99504e53569297c2bf.tar.xz
Register pre-defined command aliases in sorted order.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tapan Shah <tapandshah@hp.com> Reviewed-By: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15999 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index 2984da9699..b3939ea4d6 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -1,7 +1,7 @@
/** @file
Provides interface to shell internal functions for shell commands.
- (C) Copyright 2013-2014, Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2013-2014, Hewlett-Packard Development Company, L.P.<BR>
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -777,6 +777,9 @@ ShellCommandRegisterAlias (
)
{
ALIAS_LIST *Node;
+ ALIAS_LIST *CommandAlias;
+ ALIAS_LIST *PrevCommandAlias;
+ INTN LexicalMatchValue;
//
// Asserts for NULL
@@ -800,10 +803,37 @@ ShellCommandRegisterAlias (
StrCpy(Node->CommandString, Command);
StrCpy(Node->Alias , Alias );
+ InsertHeadList (&mAliasList.Link, &Node->Link);
+
//
- // add the new struct to the list
+ // Move a new pre-defined registered alias to its sorted ordered location in the list
//
- InsertTailList (&mAliasList.Link, &Node->Link);
+ for ( CommandAlias = (ALIAS_LIST *)GetFirstNode (&mAliasList.Link),
+ PrevCommandAlias = (ALIAS_LIST *)GetFirstNode (&mAliasList.Link)
+ ; !IsNull (&mAliasList.Link, &CommandAlias->Link)
+ ; CommandAlias = (ALIAS_LIST *) GetNextNode (&mAliasList.Link, &CommandAlias->Link) ) {
+ //
+ // Get Lexical comparison value between PrevCommandAlias and CommandAlias List Entry
+ //
+ LexicalMatchValue = gUnicodeCollation->StriColl (
+ gUnicodeCollation,
+ PrevCommandAlias->Alias,
+ CommandAlias->Alias
+ );
+
+ //
+ // Swap PrevCommandAlias and CommandAlias list entry if PrevCommandAlias list entry
+ // is alphabetically greater than CommandAlias list entry
+ //
+ if (LexicalMatchValue > 0) {
+ CommandAlias = (ALIAS_LIST *) SwapListEntries (&PrevCommandAlias->Link, &CommandAlias->Link);
+ } else if (LexicalMatchValue < 0) {
+ //
+ // PrevCommandAlias entry is lexically lower than CommandAlias entry
+ //
+ break;
+ }
+ }
return (RETURN_SUCCESS);
}