ShellPkg: fix string to number conversion with "0 "

also fixes a few out of date comments.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hp.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17816 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Jaben Carsey 2015-07-02 17:26:42 +00:00 committed by jcarsey
parent 371dc63dcf
commit 80f3e34f7a
1 changed files with 12 additions and 9 deletions

View File

@ -3729,7 +3729,7 @@ InternalShellHexCharToUintn (
/**
Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
This function returns a value of type UINTN by interpreting the contents
This function returns a value of type UINT64 by interpreting the contents
of the Unicode string specified by String as a hexadecimal number.
The format of the input Unicode string String is:
@ -3797,16 +3797,16 @@ InternalShellStrHexToUint64 (
Result = 0;
//
// Skip spaces if requested
// there is a space where there should't be
//
while (StopAtSpace && *String == L' ') {
String++;
if (*String == L' ') {
return (EFI_INVALID_PARAMETER);
}
while (ShellIsHexaDecimalDigitCharacter (*String)) {
//
// If the Hex Number represented by String overflows according
// to the range defined by UINTN, then ASSERT().
// to the range defined by UINT64, then return EFI_DEVICE_ERROR.
//
if (!(Result <= (RShiftU64((((UINT64) ~0) - InternalShellHexCharToUintn (*String)), 4)))) {
// if (!(Result <= ((((UINT64) ~0) - InternalShellHexCharToUintn (*String)) >> 4))) {
@ -3889,15 +3889,18 @@ InternalShellStrDecimalToUint64 (
Result = 0;
//
// Skip spaces if requested
// Stop upon space if requested
// (if the whole value was 0)
//
while (StopAtSpace && *String == L' ') {
String++;
if (StopAtSpace && *String == L' ') {
*Value = Result;
return (EFI_SUCCESS);
}
while (ShellIsDecimalDigitCharacter (*String)) {
//
// If the number represented by String overflows according
// to the range defined by UINT64, then ASSERT().
// to the range defined by UINT64, then return EFI_DEVICE_ERROR.
//
if (!(Result <= (DivU64x32((((UINT64) ~0) - (*String - L'0')),10)))) {