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
This commit is contained in:
Jaben Carsey 2013-11-15 20:28:58 +00:00 committed by jcarsey
parent d233c12291
commit e82edcf914
1 changed files with 29 additions and 6 deletions

View File

@ -253,6 +253,29 @@ InternalRemoveAliasFromList(
return (FALSE); return (FALSE);
} }
/**
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. Function for 'for' command.
@ -486,9 +509,9 @@ ShellCommandRunFor (
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
if (ArgSetWalker[0] == L'-') { if (ArgSetWalker[0] == L'-') {
Info->Current = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1); Info->Current = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
} else { } else {
Info->Current = (INTN)ShellStrToUintn(ArgSetWalker); Info->Current = (INTN)ReturnUintn(ArgSetWalker);
} }
ArgSetWalker = StrStr(ArgSetWalker, L" "); ArgSetWalker = StrStr(ArgSetWalker, L" ");
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') { while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
@ -508,9 +531,9 @@ ShellCommandRunFor (
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
} else { } else {
if (ArgSetWalker[0] == L'-') { if (ArgSetWalker[0] == L'-') {
Info->End = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1); Info->End = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
} else { } else {
Info->End = (INTN)ShellStrToUintn(ArgSetWalker); Info->End = (INTN)ReturnUintn(ArgSetWalker);
} }
if (Info->Current < Info->End) { if (Info->Current < Info->End) {
Info->Step = 1; Info->Step = 1;
@ -540,9 +563,9 @@ ShellCommandRunFor (
ASSERT(Info->Step == 1 || Info->Step == -1); ASSERT(Info->Step == 1 || Info->Step == -1);
} else { } else {
if (ArgSetWalker[0] == L'-') { if (ArgSetWalker[0] == L'-') {
Info->Step = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1); Info->Step = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
} else { } else {
Info->Step = (INTN)ShellStrToUintn(ArgSetWalker); Info->Step = (INTN)ReturnUintn(ArgSetWalker);
} }
if (StrStr(ArgSetWalker, L" ") != NULL) { if (StrStr(ArgSetWalker, L" ") != NULL) {