summaryrefslogtreecommitdiff
path: root/ShellPkg/Library
diff options
context:
space:
mode:
authorJaben Carsey <Jaben.carsey@intel.com>2013-11-15 20:28:58 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2013-11-15 20:28:58 +0000
commite82edcf914c188271a9f6ebca6205c7e5c6b1276 (patch)
tree092589905689f76a5c4b42ace9682a40e14e3c89 /ShellPkg/Library
parentd233c1229161480fb7ba1407962172436fdc4f2c (diff)
downloadedk2-platforms-e82edcf914c188271a9f6ebca6205c7e5c6b1276.tar.xz
ShellPkg: "For Run" fix for spaces between numerals
Since this is expected to use a string with spaces between some of the numbers, the function must halt on spaces and not skip them. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey <Jaben.carsey@intel.com> Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14854 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/For.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
index b01c69d3da..f0c4a23b24 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
@@ -254,6 +254,29 @@ InternalRemoveAliasFromList(
}
/**
+ Function to determine whether a string is decimal or hex representation of a number
+ and return the number converted from the string.
+
+ @param[in] String String representation of a number
+
+ @return the number
+ @retval (UINTN)(-1) An error ocurred.
+**/
+UINTN
+EFIAPI
+ReturnUintn(
+ IN CONST CHAR16 *String
+ )
+{
+ UINT64 RetVal;
+
+ if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, FALSE, FALSE))) {
+ return ((UINTN)RetVal);
+ }
+ return ((UINTN)(-1));
+}
+
+/**
Function for 'for' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@@ -486,9 +509,9 @@ ShellCommandRunFor (
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ArgSetWalker[0] == L'-') {
- Info->Current = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
+ Info->Current = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
} else {
- Info->Current = (INTN)ShellStrToUintn(ArgSetWalker);
+ Info->Current = (INTN)ReturnUintn(ArgSetWalker);
}
ArgSetWalker = StrStr(ArgSetWalker, L" ");
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
@@ -508,9 +531,9 @@ ShellCommandRunFor (
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ArgSetWalker[0] == L'-') {
- Info->End = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
+ Info->End = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
} else {
- Info->End = (INTN)ShellStrToUintn(ArgSetWalker);
+ Info->End = (INTN)ReturnUintn(ArgSetWalker);
}
if (Info->Current < Info->End) {
Info->Step = 1;
@@ -540,9 +563,9 @@ ShellCommandRunFor (
ASSERT(Info->Step == 1 || Info->Step == -1);
} else {
if (ArgSetWalker[0] == L'-') {
- Info->Step = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
+ Info->Step = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
} else {
- Info->Step = (INTN)ShellStrToUintn(ArgSetWalker);
+ Info->Step = (INTN)ReturnUintn(ArgSetWalker);
}
if (StrStr(ArgSetWalker, L" ") != NULL) {