Changeset 7245 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Aug 12, 2004, 4:04:11 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/function.cpp
r7239 r7245 527 527 } else if (c >= 'A' && c <= 'Z') { 528 528 digit = c - 'A' + 10; 529 } else if (c >= 'a' && c <= ' Z') {529 } else if (c >= 'a' && c <= 'z') { 530 530 digit = c - 'a' + 10; 531 531 } … … 555 555 } 556 556 557 if (length - p >= 2 && s[p] == '0' && (s[p + 1] == 'x' || s[p + 1] == 'X')) { 558 if (radix == 0) 559 radix = 16; 560 if (radix == 16) 561 p += 2; 562 } 563 if (radix == 0) 564 radix = 10; 557 if ((radix == 0 || radix == 16) && length - p >= 2 && s[p] == '0' && (s[p + 1] == 'x' || s[p + 1] == 'X')) { 558 radix = 16; 559 p += 2; 560 } else if (radix == 0) { 561 if (p < length && s[p] == '0') 562 radix = 8; 563 else 564 radix = 10; 565 } 565 566 566 567 if (radix < 2 || radix > 36) … … 587 588 static double parseFloat(const UString &s) 588 589 { 590 // Check for 0x prefix here, because toDouble allows it, but we must treat it as 0. 591 // Need to skip any whitespace and then one + or - sign. 589 592 int length = s.size(); 590 593 int p = 0; 591 592 // Skip whitespace.593 594 while (p < length && isStrWhiteSpace(s[p].uc)) { 594 595 ++p; 595 596 } 596 597 // Check for 0x numbers here, because toDouble allows them, but we must not. 597 if (p < length && (s[p] == '+' || s[p] == '-')) { 598 ++p; 599 } 598 600 if (length - p >= 2 && s[p] == '0' && (s[p + 1] == 'x' || s[p + 1] == 'X')) { 599 return NaN;600 } 601 602 return s. substr(p).toDouble( true /*tolerant*/, false /* NaN for empty string */ );601 return 0; 602 } 603 604 return s.toDouble( true /*tolerant*/, false /* NaN for empty string */ ); 603 605 } 604 606
Note:
See TracChangeset
for help on using the changeset viewer.