diff options
author | Jaben Carsey <jaben.carsey@intel.com> | 2015-07-02 17:26:42 +0000 |
---|---|---|
committer | jcarsey <jcarsey@Edk2> | 2015-07-02 17:26:42 +0000 |
commit | 80f3e34f7a4e0439dba7187753cba35699cc36b3 (patch) | |
tree | 5bad1fe9a20c6097cc68e35bd84f09190148cbb8 /ShellPkg | |
parent | 371dc63dcffd018d762a8f7794a5652987372f81 (diff) | |
download | edk2-80f3e34f7a4e0439dba7187753cba35699cc36b3.zip edk2-80f3e34f7a4e0439dba7187753cba35699cc36b3.tar.gz edk2-80f3e34f7a4e0439dba7187753cba35699cc36b3.tar.bz2 |
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
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 3521515..0bf034f 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -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)))) {
|