\r
#include "UefiShellLevel1CommandsLib.h"\r
#include <Library/PrintLib.h>\r
+#include <Library/PathLib.h>\r
\r
typedef enum {\r
EndTagOr,\r
/**\r
Extract the next fragment, if there is one.\r
\r
- @param[in,out] Statement The current remaining statement.\r
- @param[in] Fragment The current fragment.\r
+ @param[in, out] Statement The current remaining statement.\r
+ @param[in] Fragment The current fragment.\r
\r
@retval FALSE There is not another fragment.\r
@retval TRUE There is another fragment.\r
CONST CHAR16 *TempLocation;\r
\r
ProfilesString = ShellGetEnvironmentVariable(L"profiles");\r
+ ASSERT(ProfilesString != NULL);\r
TempLocation = StrStr(ProfilesString, String);\r
if ((TempLocation != NULL) && (*(TempLocation-1) == L';') && (*(TempLocation+StrLen(String)) == L';')) {\r
return (TRUE);\r
/**\r
Process an if statement and determine if its is valid or not.\r
\r
- @param[in,out] PassingState Opon entry, the current state. Upon exit, \r
- the new state.\r
- @param[in] StartParameterNumber The number of the first parameter of\r
- this statement.\r
- @param[in] EndParameterNumber The number of the final parameter of\r
- this statement.\r
- @param[in] OperatorToUse The type of termination operator.\r
- @param[in] CaseInsensitive TRUE for case insensitive, FALSE otherwise.\r
- @param[in] ForceStringCompare TRUE for all string based, FALSE otherwise.\r
+ @param[in, out] PassingState Opon entry, the current state. Upon exit, \r
+ the new state.\r
+ @param[in] StartParameterNumber The number of the first parameter of\r
+ this statement.\r
+ @param[in] EndParameterNumber The number of the final parameter of\r
+ this statement.\r
+ @param[in] OperatorToUse The type of termination operator.\r
+ @param[in] CaseInsensitive TRUE for case insensitive, FALSE otherwise.\r
+ @param[in] ForceStringCompare TRUE for all string based, FALSE otherwise.\r
\r
@retval EFI_INVALID_PARAMETER A parameter was invalid.\r
@retval EFI_SUCCESS The operation was successful. \r
OUT END_TAG_TYPE *EndTag\r
)\r
{\r
- CHAR16 *Buffer;\r
- UINTN BufferSize;\r
-\r
*EndTag = EndTagMax;\r
\r
- for(Buffer = NULL, BufferSize = 0\r
+ for(\r
; ParameterNumber < gEfiShellParametersProtocol->Argc\r
; ParameterNumber++\r
) {\r
//\r
CommandName = NULL;\r
CommandName = StrnCatGrow(&CommandName, NULL, CommandNode->Cl, 0);\r
+ if (CommandName == NULL) {\r
+ continue;\r
+ }\r
CommandWalker = CommandName;\r
while (CommandWalker[0] == L' ') {\r
CommandWalker++;\r
BOOLEAN CurrentValue;\r
END_TAG_TYPE Ending;\r
END_TAG_TYPE PreviousEnding;\r
-\r
+ SCRIPT_FILE *CurrentScriptFile;\r
\r
Status = CommandInit();\r
ASSERT_EFI_ERROR(Status);\r
//\r
// Make sure that an End exists.\r
//\r
- if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), TRUE, TRUE, FALSE)) {\r
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
+ if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {\r
ShellPrintHiiEx(\r
-1, \r
-1, \r
gShellLevel1HiiHandle, \r
L"EnfIf", \r
L"If", \r
- ShellCommandGetCurrentScriptFile()!=NULL\r
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+ CurrentScriptFile!=NULL \r
+ && CurrentScriptFile->CurrentCommand!=NULL\r
+ ? CurrentScriptFile->CurrentCommand->Line:0);\r
return (SHELL_DEVICE_ERROR);\r
}\r
\r
// build up the next statement for analysis\r
//\r
if (!BuildNextStatement(CurrentParameter, &EndParameter, &Ending)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"Then", L"If", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
+ ShellPrintHiiEx(\r
+ -1, \r
+ -1, \r
+ NULL, \r
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+ gShellLevel1HiiHandle, \r
+ L"Then", \r
+ L"If",\r
+ CurrentScriptFile!=NULL \r
+ && CurrentScriptFile->CurrentCommand!=NULL\r
+ ? CurrentScriptFile->CurrentCommand->Line:0);\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
//\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
+ SCRIPT_FILE *CurrentScriptFile;\r
ASSERT_EFI_ERROR(CommandInit());\r
\r
if (gEfiShellParametersProtocol->Argc > 1) {\r
return (SHELL_UNSUPPORTED);\r
}\r
\r
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
\r
- if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {\r
+ if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {\r
ShellPrintHiiEx(\r
-1, \r
-1, \r
gShellLevel1HiiHandle, \r
L"If", \r
L"Else", \r
- ShellCommandGetCurrentScriptFile()!=NULL\r
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+ CurrentScriptFile!=NULL \r
+ && CurrentScriptFile->CurrentCommand!=NULL\r
+ ? CurrentScriptFile->CurrentCommand->Line:0);\r
return (SHELL_DEVICE_ERROR);\r
}\r
- if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {\r
+ if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {\r
ShellPrintHiiEx(\r
-1, \r
-1, \r
gShellLevel1HiiHandle, \r
L"If", \r
L"Else", \r
- ShellCommandGetCurrentScriptFile()!=NULL\r
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+ CurrentScriptFile!=NULL \r
+ && CurrentScriptFile->CurrentCommand!=NULL\r
+ ? CurrentScriptFile->CurrentCommand->Line:0);\r
return (SHELL_DEVICE_ERROR);\r
}\r
\r
- if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE)) {\r
+ if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, FALSE, FALSE, FALSE)) {\r
ShellPrintHiiEx(\r
-1, \r
-1, \r
gShellLevel1HiiHandle, \r
L"EndIf", \r
"Else", \r
- ShellCommandGetCurrentScriptFile()!=NULL\r
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+ CurrentScriptFile!=NULL \r
+ && CurrentScriptFile->CurrentCommand!=NULL\r
+ ? CurrentScriptFile->CurrentCommand->Line:0);\r
return (SHELL_DEVICE_ERROR);\r
}\r
\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
+ SCRIPT_FILE *CurrentScriptFile;\r
ASSERT_EFI_ERROR(CommandInit());\r
\r
if (gEfiShellParametersProtocol->Argc > 1) {\r
return (SHELL_UNSUPPORTED);\r
}\r
\r
- if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {\r
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
+ if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {\r
ShellPrintHiiEx(\r
-1, \r
-1, \r
gShellLevel1HiiHandle, \r
L"If", \r
L"EndIf", \r
- ShellCommandGetCurrentScriptFile()!=NULL\r
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+ CurrentScriptFile!=NULL \r
+ && CurrentScriptFile->CurrentCommand!=NULL\r
+ ? CurrentScriptFile->CurrentCommand->Line:0);\r
return (SHELL_DEVICE_ERROR);\r
}\r
\r