Skip to content

Commit a16fb0d

Browse files
committed
fix parseInt of '0'
1 parent 7cf24cb commit a16fb0d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/library.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3852,6 +3852,7 @@ LibraryManager.library = {
38523852
}
38533853

38543854
// Find base.
3855+
var ok = false;
38553856
var finalBase = base;
38563857
if (!finalBase) {
38573858
if ({{{ makeGetValue('str', 0, 'i8') }}} == '0'.charCodeAt(0)) {
@@ -3862,21 +3863,21 @@ LibraryManager.library = {
38623863
} else {
38633864
finalBase = 8;
38643865
str++;
3866+
ok = true; // we saw an initial zero, perhaps the entire thing is just "0"
38653867
}
38663868
}
38673869
}
38683870
if (!finalBase) finalBase = 10;
38693871

38703872
// Get digits.
38713873
var chr;
3872-
var ok = false;
38733874
while ((chr = {{{ makeGetValue('str', 0, 'i8') }}}) != 0) {
38743875
var digit = parseInt(String.fromCharCode(chr), finalBase);
38753876
if (isNaN(digit)) {
38763877
break;
38773878
} else {
3878-
ok = true;
38793879
str++;
3880+
ok = true;
38803881
}
38813882
}
38823883
if (!ok) {

0 commit comments

Comments
 (0)