Fix build with Visual Studio
authorSimon Hausmann <simon.hausmann@digia.com>
Fri, 8 Feb 2013 08:39:25 +0000 (09:39 +0100)
committerLars Knoll <lars.knoll@digia.com>
Sat, 9 Feb 2013 09:50:14 +0000 (10:50 +0100)
Which doesn't have nan(const char *tagp). Instead let's just use
std::numeric_limits<double>::quiet_NaN().

Change-Id: I13127a3813fc84e85681883c5a0ec89f7cd69667
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/v4/qmljs_engine.cpp
src/v4/qmljs_runtime.cpp
src/v4/qmljs_runtime.h
src/v4/qv4globalobject.cpp

index 9dd5e38..05a03f6 100644 (file)
@@ -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<double>::quiet_NaN()));
     glo->defineReadonlyProperty(this, QStringLiteral("Infinity"), Value::fromDouble(Q_INFINITY));
 
     evalFunction = new (memoryManager) EvalFunction(rootContext);
index 639e699..1fcdf02 100644 (file)
@@ -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<double>::quiet_NaN();
     }
     return d;
 }
index 839133f..27ffff8 100644 (file)
@@ -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<double>::quiet_NaN();
     case Value::Null_Type:
         return 0;
     case Value::Boolean_Type:
index 5020258..2d7bb71 100644 (file)
@@ -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<double>::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<double>::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<double>::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<double>::quiet_NaN()); // 3
     else
         return Value::fromDouble(d);
 }