summaryrefslogtreecommitdiff
path: root/src/lj_strscan.c
diff options
context:
space:
mode:
authorMike Pall <mike>2019-12-08 19:51:33 +0100
committerMike Pall <mike>2019-12-08 19:51:33 +0100
commit45a7e5073ce0a59465fef0b80bb08bd4e76b7979 (patch)
treee3aa0cfc3013a41309779396ed94278b07b9eb54 /src/lj_strscan.c
parentde48d000941f58a8d4d816e9d227de8a4f3c9de6 (diff)
downloadluajit2-45a7e5073ce0a59465fef0b80bb08bd4e76b7979.tar.gz
Fix tonumber("-0").
Reported by bluecheetah001.
Diffstat (limited to 'src/lj_strscan.c')
-rw-r--r--src/lj_strscan.c5
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)
/* 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;
}
}