From a1c23195c882afd34d977e20badea2b8a846ff65 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 8 Feb 2013 09:39:25 +0100 Subject: [PATCH] Fix build with Visual Studio Which doesn't have nan(const char *tagp). Instead let's just use std::numeric_limits::quiet_NaN(). Change-Id: I13127a3813fc84e85681883c5a0ec89f7cd69667 Reviewed-by: Lars Knoll --- src/v4/qmljs_engine.cpp | 2 +- src/v4/qmljs_runtime.cpp | 2 +- src/v4/qmljs_runtime.h | 2 +- src/v4/qv4globalobject.cpp | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/v4/qmljs_engine.cpp b/src/v4/qmljs_engine.cpp index 9dd5e38..05a03f6 100644 --- a/src/v4/qmljs_engine.cpp +++ b/src/v4/qmljs_engine.cpp @@ -200,7 +200,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) glo->defineDefaultProperty(rootContext, QStringLiteral("JSON"), Value::fromObject(new (memoryManager) JsonObject(rootContext))); glo->defineReadonlyProperty(this, QStringLiteral("undefined"), Value::undefinedValue()); - glo->defineReadonlyProperty(this, QStringLiteral("NaN"), Value::fromDouble(nan(""))); + glo->defineReadonlyProperty(this, QStringLiteral("NaN"), Value::fromDouble(std::numeric_limits::quiet_NaN())); glo->defineReadonlyProperty(this, QStringLiteral("Infinity"), Value::fromDouble(Q_INFINITY)); evalFunction = new (memoryManager) EvalFunction(rootContext); diff --git a/src/v4/qmljs_runtime.cpp b/src/v4/qmljs_runtime.cpp index 639e699..1fcdf02 100644 --- a/src/v4/qmljs_runtime.cpp +++ b/src/v4/qmljs_runtime.cpp @@ -473,7 +473,7 @@ double __qmljs_string_to_number(const String *string) else if (ba == "-Infinity") d = -Q_INFINITY; else - d = nan(""); + d = std::numeric_limits::quiet_NaN(); } return d; } diff --git a/src/v4/qmljs_runtime.h b/src/v4/qmljs_runtime.h index 839133f..27ffff8 100644 --- a/src/v4/qmljs_runtime.h +++ b/src/v4/qmljs_runtime.h @@ -318,7 +318,7 @@ inline double __qmljs_to_number(Value value, ExecutionContext *ctx) { switch (value.type()) { case Value::Undefined_Type: - return nan(""); + return std::numeric_limits::quiet_NaN(); case Value::Null_Type: return 0; case Value::Boolean_Type: diff --git a/src/v4/qv4globalobject.cpp b/src/v4/qv4globalobject.cpp index 5020258..2d7bb71 100644 --- a/src/v4/qv4globalobject.cpp +++ b/src/v4/qv4globalobject.cpp @@ -523,7 +523,7 @@ Value GlobalFunctions::method_parseInt(ExecutionContext *context) bool stripPrefix = true; // 7 if (R) { // 8 if (R < 2 || R > 36) - return Value::fromDouble(nan("")); // 8a + return Value::fromDouble(std::numeric_limits::quiet_NaN()); // 8a if (R != 16) stripPrefix = false; // 8b } else { // 9 @@ -540,13 +540,13 @@ Value GlobalFunctions::method_parseInt(ExecutionContext *context) // 11: Z is progressively built below // 13: this is handled by the toInt function if (pos == end) // 12 - return Value::fromDouble(nan("")); + return Value::fromDouble(std::numeric_limits::quiet_NaN()); bool overflow = false; qint64 v_overflow; unsigned overflow_digit_count = 0; int d = toInt(*pos++, R); if (d == -1) - return Value::fromDouble(nan("")); + return Value::fromDouble(std::numeric_limits::quiet_NaN()); qint64 v = d; while (pos != end) { d = toInt(*pos++, R); @@ -600,7 +600,7 @@ Value GlobalFunctions::method_parseFloat(ExecutionContext *context) const char *end = 0; double d = qstrtod(begin, &end, &ok); if (end - begin == 0) - return Value::fromDouble(nan("")); // 3 + return Value::fromDouble(std::numeric_limits::quiet_NaN()); // 3 else return Value::fromDouble(d); } -- 2.7.4