Changeset 74160 in vbox for trunk/src/VBox/Runtime/common/string/strtonum.cpp
- Timestamp:
- Sep 9, 2018 1:53:25 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strtonum.cpp
r69111 r74160 557 557 int iShift; 558 558 int rc; 559 int64_t i64;559 uint64_t u64; 560 560 unsigned char uch; 561 561 … … 605 605 * Note: We only support ascii digits at this time... :-) 606 606 */ 607 iShift = g_auchShift[uBase]; /** @todo test this, it's probably not 100% right yet. */607 iShift = g_auchShift[uBase]; 608 608 pszValue = psz; /* (Prefix and sign doesn't count in the digit counting.) */ 609 609 rc = VINF_SUCCESS; 610 i64 = 0;610 u64 = 0; 611 611 while ((uch = (unsigned char)*psz) != 0) 612 612 { 613 613 unsigned char chDigit = g_auchDigits[uch]; 614 int64_t i64Prev;614 uint64_t u64Prev; 615 615 616 616 if (chDigit >= uBase) 617 617 break; 618 618 619 i64Prev = i64;620 i64 *= uBase;621 i64 += chDigit;622 if ( i64Prev > i64 || (i64Prev >> iShift))619 u64Prev = u64; 620 u64 *= uBase; 621 u64 += chDigit; 622 if (u64Prev > u64 || (u64Prev >> iShift)) 623 623 rc = VWRN_NUMBER_TOO_BIG; 624 624 psz++; 625 625 } 626 626 627 if (!fPositive) 628 i64 = -i64; 627 if ( !(u64 & RT_BIT_64(63)) 628 || (!fPositive && u64 == RT_BIT_64(63)) ) 629 { /* likely */ } 630 else 631 rc = VWRN_NUMBER_TOO_BIG; 629 632 630 633 if (pi64) 631 *pi64 = i64;634 *pi64 = fPositive ? u64 : -(int64_t)u64; 632 635 633 636 if (psz == pszValue)
Note:
See TracChangeset
for help on using the changeset viewer.