diff options
-rw-r--r-- | src/lj_strscan.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/lj_strscan.c b/src/lj_strscan.c index f1e34a3d..1ae68c3f 100644 --- a/src/lj_strscan.c +++ b/src/lj_strscan.c | |||
@@ -445,12 +445,11 @@ StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt) | |||
445 | /* Fast path for decimal 32 bit integers. */ | 445 | /* Fast path for decimal 32 bit integers. */ |
446 | if (fmt == STRSCAN_INT && base == 10 && | 446 | if (fmt == STRSCAN_INT && base == 10 && |
447 | (dig < 10 || (dig == 10 && *sp <= '2' && x < 0x80000000u+neg))) { | 447 | (dig < 10 || (dig == 10 && *sp <= '2' && x < 0x80000000u+neg))) { |
448 | int32_t y = neg ? -(int32_t)x : (int32_t)x; | ||
449 | if ((opt & STRSCAN_OPT_TONUM)) { | 448 | if ((opt & STRSCAN_OPT_TONUM)) { |
450 | o->n = (double)y; | 449 | o->n = neg ? -(double)x : (double)x; |
451 | return STRSCAN_NUM; | 450 | return STRSCAN_NUM; |
452 | } else { | 451 | } else { |
453 | o->i = y; | 452 | o->i = neg ? -(int32_t)x : (int32_t)x; |
454 | return STRSCAN_INT; | 453 | return STRSCAN_INT; |
455 | } | 454 | } |
456 | } | 455 | } |