[njs] Fixed parseInt('-0').
Dmitry Volyntsev
xeioex at nginx.com
Mon Jun 24 23:37:30 UTC 2019
details: https://hg.nginx.org/njs/rev/56dee6c2ad95
branches:
changeset: 1014:56dee6c2ad95
user: Artem S. Povalyukhin <artem.povaluhin at gmail.com>
date: Sat Jun 22 23:35:52 2019 +0300
description:
Fixed parseInt('-0').
diffstat:
njs/njs_number.c | 3 ++-
njs/test/njs_unit_test.c | 3 +++
2 files changed, 5 insertions(+), 1 deletions(-)
diffs (26 lines):
diff -r df8d48ea3875 -r 56dee6c2ad95 njs/njs_number.c
--- a/njs/njs_number.c Thu Jun 20 15:20:34 2019 +0300
+++ b/njs/njs_number.c Sat Jun 22 23:35:52 2019 +0300
@@ -802,7 +802,8 @@ njs_number_parse_int(njs_vm_t *vm, njs_v
n = njs_number_radix_parse(&p, end, radix);
if (n >= 0) {
- num = minus ? -n : n;
+ num = n;
+ num = minus ? -num : num;
}
}
diff -r df8d48ea3875 -r 56dee6c2ad95 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Thu Jun 20 15:20:34 2019 +0300
+++ b/njs/test/njs_unit_test.c Sat Jun 22 23:35:52 2019 +0300
@@ -11744,6 +11744,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("parseInt('0', 37)"),
nxt_string("NaN") },
+ { nxt_string("1/parseInt('-0')"),
+ nxt_string("-Infinity") },
+
{ nxt_string("parseFloat.name"),
nxt_string("parseFloat") },
More information about the nginx-devel
mailing list