Skip to content

Commit

Permalink
Fix tonumber("-0").
Browse files Browse the repository at this point in the history
Reported by bluecheetah001.
  • Loading branch information
Mike Pall committed Dec 8, 2019
1 parent de48d00 commit 45a7e50
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/lj_strscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,11 @@ StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt)
/* Fast path for decimal 32 bit integers. */
if (fmt == STRSCAN_INT && base == 10 &&
(dig < 10 || (dig == 10 && *sp <= '2' && x < 0x80000000u+neg))) {
int32_t y = neg ? -(int32_t)x : (int32_t)x;
if ((opt & STRSCAN_OPT_TONUM)) {
o->n = (double)y;
o->n = neg ? -(double)x : (double)x;
return STRSCAN_NUM;
} else {
o->i = y;
o->i = neg ? -(int32_t)x : (int32_t)x;
return STRSCAN_INT;
}
}
Expand Down

0 comments on commit 45a7e50

Please sign in to comment.