/** @file\r
Main file for endfor and for shell level 1 functions.\r
\r
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2012, 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
which accompanies this distribution. The full text of the license may be found at\r
return (FALSE);\r
}\r
\r
+/**\r
+ Function to determine whether a string is decimal or hex representation of a number\r
+ and return the number converted from the string.\r
+\r
+ @param[in] String String representation of a number\r
+\r
+ @return the number\r
+ @retval (UINTN)(-1) An error ocurred.\r
+**/\r
+UINTN\r
+EFIAPI\r
+ReturnUintn(\r
+ IN CONST CHAR16 *String\r
+ )\r
+{\r
+ UINT64 RetVal;\r
+\r
+ if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, FALSE, FALSE))) {\r
+ return ((UINTN)RetVal);\r
+ }\r
+ return ((UINTN)(-1));\r
+}\r
+\r
/**\r
Function for 'for' command.\r
\r
//\r
Info = AllocateZeroPool(sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]));\r
ASSERT(Info != NULL);\r
+ Info->Signature = SHELL_FOR_INFO_SIGNATURE;\r
CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1]));\r
Info->ReplacementName = Info->Set;\r
Info->CurrentValue = NULL;\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
if (ArgSetWalker[0] == L'-') {\r
- Info->Current = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);\r
+ Info->Current = 0 - (INTN)ReturnUintn(ArgSetWalker+1);\r
} else {\r
- Info->Current = (INTN)ShellStrToUintn(ArgSetWalker);\r
+ Info->Current = (INTN)ReturnUintn(ArgSetWalker);\r
}\r
ArgSetWalker = StrStr(ArgSetWalker, L" ");\r
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
if (ArgSetWalker[0] == L'-') {\r
- Info->End = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);\r
+ Info->End = 0 - (INTN)ReturnUintn(ArgSetWalker+1);\r
} else {\r
- Info->End = (INTN)ShellStrToUintn(ArgSetWalker);\r
+ Info->End = (INTN)ReturnUintn(ArgSetWalker);\r
}\r
if (Info->Current < Info->End) {\r
Info->Step = 1;\r
ASSERT(Info->Step == 1 || Info->Step == -1);\r
} else {\r
if (ArgSetWalker[0] == L'-') {\r
- Info->Step = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);\r
+ Info->Step = 0 - (INTN)ReturnUintn(ArgSetWalker+1);\r
} else {\r
- Info->Step = (INTN)ShellStrToUintn(ArgSetWalker);\r
+ Info->Step = (INTN)ReturnUintn(ArgSetWalker);\r
}\r
\r
if (StrStr(ArgSetWalker, L" ") != NULL) {\r
//\r
ASSERT(Info->Set != NULL);\r
if (Info->CurrentValue != NULL && *Info->CurrentValue != CHAR_NULL) {\r
- if (Info->CurrentValue[0] == L'\"') {\r
+ if (Info->CurrentValue[0] == L' ') {\r
Info->CurrentValue++;\r
}\r
-// while (Info->CurrentValue[0] == L' ') {\r
-// Info->CurrentValue++;\r
-// }\r
if (Info->CurrentValue[0] == L'\"') {\r
Info->CurrentValue++;\r
}\r