/** @file\r
Provides interface to shell internal functions for shell commands.\r
\r
- (C) Copyright 2013-2014, Hewlett-Packard Development Company, L.P.\r
+ Copyright (c) 2013-2014, Hewlett-Packard Development Company, L.P.<BR>\r
Copyright (c) 2009 - 2014, 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
)\r
{\r
ALIAS_LIST *Node;\r
+ ALIAS_LIST *CommandAlias;\r
+ ALIAS_LIST *PrevCommandAlias; \r
+ INTN LexicalMatchValue;\r
\r
//\r
// Asserts for NULL\r
StrCpy(Node->CommandString, Command);\r
StrCpy(Node->Alias , Alias );\r
\r
+ InsertHeadList (&mAliasList.Link, &Node->Link);\r
+\r
//\r
- // add the new struct to the list\r
+ // Move a new pre-defined registered alias to its sorted ordered location in the list\r
//\r
- InsertTailList (&mAliasList.Link, &Node->Link);\r
+ for ( CommandAlias = (ALIAS_LIST *)GetFirstNode (&mAliasList.Link),\r
+ PrevCommandAlias = (ALIAS_LIST *)GetFirstNode (&mAliasList.Link)\r
+ ; !IsNull (&mAliasList.Link, &CommandAlias->Link)\r
+ ; CommandAlias = (ALIAS_LIST *) GetNextNode (&mAliasList.Link, &CommandAlias->Link) ) {\r
+ //\r
+ // Get Lexical comparison value between PrevCommandAlias and CommandAlias List Entry\r
+ //\r
+ LexicalMatchValue = gUnicodeCollation->StriColl (\r
+ gUnicodeCollation,\r
+ PrevCommandAlias->Alias,\r
+ CommandAlias->Alias\r
+ );\r
+\r
+ //\r
+ // Swap PrevCommandAlias and CommandAlias list entry if PrevCommandAlias list entry\r
+ // is alphabetically greater than CommandAlias list entry\r
+ // \r
+ if (LexicalMatchValue > 0) {\r
+ CommandAlias = (ALIAS_LIST *) SwapListEntries (&PrevCommandAlias->Link, &CommandAlias->Link);\r
+ } else if (LexicalMatchValue < 0) {\r
+ //\r
+ // PrevCommandAlias entry is lexically lower than CommandAlias entry\r
+ //\r
+ break;\r
+ }\r
+ }\r
\r
return (RETURN_SUCCESS);\r
}\r