[njs] Added njs_value_is_valid_number().
Dmitry Volyntsev
xeioex at nginx.com
Thu Apr 5 11:51:03 UTC 2018
details: http://hg.nginx.org/njs/rev/67edba3688e4
branches:
changeset: 493:67edba3688e4
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Thu Apr 05 14:50:45 2018 +0300
description:
Added njs_value_is_valid_number().
diffstat:
njs/njs_vm.c | 9 +++++++++
njs/njscript.h | 1 +
2 files changed, 10 insertions(+), 0 deletions(-)
diffs (30 lines):
diff -r 5fd1cb826b96 -r 67edba3688e4 njs/njs_vm.c
--- a/njs/njs_vm.c Wed Apr 04 16:21:09 2018 +0300
+++ b/njs/njs_vm.c Thu Apr 05 14:50:45 2018 +0300
@@ -3751,6 +3751,15 @@ njs_value_is_number(njs_value_t *value)
nxt_noinline nxt_int_t
+njs_value_is_valid_number(njs_value_t *value)
+{
+ return njs_is_number(value)
+ && !isnan(value->data.u.number)
+ && !isinf(value->data.u.number);
+}
+
+
+nxt_noinline nxt_int_t
njs_value_is_string(njs_value_t *value)
{
return njs_is_string(value);
diff -r 5fd1cb826b96 -r 67edba3688e4 njs/njscript.h
--- a/njs/njscript.h Wed Apr 04 16:21:09 2018 +0300
+++ b/njs/njscript.h Thu Apr 05 14:50:45 2018 +0300
@@ -191,6 +191,7 @@ NXT_EXPORT njs_function_t *njs_value_fun
NXT_EXPORT nxt_int_t njs_value_is_void(njs_value_t *value);
NXT_EXPORT nxt_int_t njs_value_is_boolean(njs_value_t *value);
NXT_EXPORT nxt_int_t njs_value_is_number(njs_value_t *value);
+NXT_EXPORT nxt_int_t njs_value_is_valid_number(njs_value_t *value);
NXT_EXPORT nxt_int_t njs_value_is_string(njs_value_t *value);
NXT_EXPORT nxt_int_t njs_value_is_object(njs_value_t *value);
NXT_EXPORT nxt_int_t njs_value_is_function(njs_value_t *value);
More information about the nginx-devel
mailing list