details: http://hg.nginx.org/njs/rev/2cba0bd90189 branches: changeset: 354:2cba0bd90189 user: Andrey Zelenkov <zelen...@nginx.com> date: Wed Jun 07 16:36:13 2017 +0300 description: Fixed zero basis handling for scientific notation.
diffstat: njs/njs_number.c | 6 ++++-- njs/test/njs_unit_test.c | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diffs (32 lines): diff -r 7196ac334d64 -r 2cba0bd90189 njs/njs_number.c --- a/njs/njs_number.c Wed Jun 07 15:45:01 2017 +0300 +++ b/njs/njs_number.c Wed Jun 07 16:36:13 2017 +0300 @@ -154,8 +154,10 @@ njs_number_dec_parse(u_char **start, u_c p++; } - exponent = minus ? -exponent : exponent; - num = num * pow(10.0, exponent); + if (num != 0) { + exponent = minus ? -exponent : exponent; + num = num * pow(10.0, exponent); + } } } diff -r 7196ac334d64 -r 2cba0bd90189 njs/test/njs_unit_test.c --- a/njs/test/njs_unit_test.c Wed Jun 07 15:45:01 2017 +0300 +++ b/njs/test/njs_unit_test.c Wed Jun 07 16:36:13 2017 +0300 @@ -191,6 +191,12 @@ static njs_unit_test_t njs_test[] = { nxt_string("1.0e308"), nxt_string("1e+308") }, + { nxt_string("0e309"), + nxt_string("0") }, + + { nxt_string("0e-309"), + nxt_string("0") }, + { nxt_string("1e"), nxt_string("SyntaxError: Unexpected token \"e\" in 1") }, _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel