OSDN Git Service

effectively revert 36e1687e0e22bafa8b3818204b595b31d5ba3a00
authorIvailo Monev <xakepa10@gmail.com>
Sun, 20 Jun 2021 06:22:25 +0000 (09:22 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 20 Jun 2021 06:22:25 +0000 (09:22 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/tools/qlocale.cpp

index 35bb116..81def15 100644 (file)
@@ -2418,6 +2418,16 @@ double QLocalePrivate::bytearrayToDouble(const char *num, bool *ok)
         return 0.0;
     }
 
+    // strtod() sets errno to ERANGE on nan/infinity
+    if (ok != Q_NULLPTR)
+        *ok = true;
+    if (qstrcmp(num, "nan") == 0)
+        return qSNaN();
+    if (qstrcmp(num, "+inf") == 0 || qstrcmp(num, "inf") == 0)
+        return qInf();
+    if (qstrcmp(num, "-inf") == 0)
+        return -qInf();
+
     char *endptr;
     Q_RESET_ERRNO
     double ret = std::strtod(num, &endptr);
@@ -2434,8 +2444,6 @@ double QLocalePrivate::bytearrayToDouble(const char *num, bool *ok)
         return 0.0;
     }
 
-    if (ok != Q_NULLPTR)
-        *ok = true;
     return ret;
 }