Commit e00708e3 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added new is_finite helper.

parent b1197a15
......@@ -264,8 +264,7 @@ static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
if(FAILED(hres))
return hres;
if(!isinf(n) && !isnan(n))
ret = TRUE;
ret = is_finite(n);
}
if(r)
......
......@@ -339,6 +339,7 @@ HRESULT variant_change_type(script_ctx_t*,VARIANT*,VARIANT*,VARTYPE) DECLSPEC_HI
HRESULT decode_source(WCHAR*) DECLSPEC_HIDDEN;
HRESULT double_to_string(double,jsstr_t**) DECLSPEC_HIDDEN;
BOOL is_finite(double) DECLSPEC_HIDDEN;
typedef struct named_item_t {
IDispatch *disp;
......
......@@ -53,6 +53,11 @@ const char *debugstr_jsval(const jsval_t v)
return NULL;
}
BOOL is_finite(double n)
{
return !isnan(n) && !isinf(n);
}
#define MIN_BLOCK_SIZE 128
#define ARENA_FREE_FILLER 0xaa
......@@ -641,7 +646,7 @@ HRESULT to_int32(script_ctx_t *ctx, jsval_t v, INT *ret)
if(FAILED(hres))
return hres;
*ret = isnan(n) || isinf(n) ? 0 : n;
*ret = is_finite(n) ? n : 0;
return S_OK;
}
......
......@@ -16,9 +16,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <math.h>
#include <assert.h>
......@@ -257,7 +254,7 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
val = number->value;
if(radix==10 || isnan(val) || isinf(val)) {
if(radix==10 || !is_finite(val)) {
hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres))
return hres;
......@@ -383,7 +380,7 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
}
val = number->value;
if(isinf(val) || isnan(val)) {
if(!is_finite(val)) {
hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres))
return hres;
......@@ -424,7 +421,7 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
}
val = number->value;
if(isinf(val) || isnan(val)) {
if(!is_finite(val)) {
hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres))
return hres;
......@@ -465,7 +462,7 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
}
val = number->value;
if(isinf(val) || isnan(val) || !prec) {
if(!is_finite(val) || !prec) {
hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres))
return hres;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment