[SCM] qtbase packaging branch, ubuntu, updated. 5.6.1+dfsg-3ubuntu3-5-gfbf4f37

Timo Jyrinki timo at moszumanska.debian.org
Wed Sep 7 10:59:48 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/qt/qtbase.git;a=commitdiff;h=fbf4f37

The following commit has been merged in the ubuntu branch:
commit fbf4f37c32b49e9cf743a03c33c3fd33353653ee
Author: Timo Jyrinki <timo.jyrinki at canonical.com>
Date:   Wed Sep 7 10:59:45 2016 +0000

    debian/patches/Replace-qdtoa-and-qstrtod-implementation-by-a-3rdpar.patch debian/patches/Add-thorough-tests-for-QLocale-string-double-conversions.patch debian/patches/Interpret-precision-128-as-shortest-double-conversio.patch:
    
    * debian/patches/Replace-qdtoa-and-qstrtod-implementation-by-a-3rdpar.patch
      debian/patches/Add-thorough-tests-for-QLocale-string-double-conversions.patch
      debian/patches/Interpret-precision-128-as-shortest-double-conversio.patch:
      - Fix broken conversion from QVariant to QString (LP: #1620173)
---
 debian/changelog                                   |    4 +
 ...sts-for-QLocale-string-double-conversions.patch |  204 +
 ...recision-128-as-shortest-double-conversio.patch |  549 ++
 ...oa-and-qstrtod-implementation-by-a-3rdpar.patch | 9992 ++++++++++++++++++++
 debian/patches/series                              |    3 +
 5 files changed, 10752 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 39d6cce..a6634d4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,10 @@ qtbase-opensource-src (5.6.1+dfsg-3ubuntu4) UNRELEASED; urgency=medium
   * debian/patches/Fix-gcc-Wsuggest-override-warning-on-Q_OBJECT.patch
     debian/patches/Fix-the-GCC-version-supporting-Wsuggest-override.patch:
     - Fix GCC -Wsuggest-override warning on Q_OBJECT (LP: #1619483)
+  * debian/patches/Replace-qdtoa-and-qstrtod-implementation-by-a-3rdpar.patch
+    debian/patches/Add-thorough-tests-for-QLocale-string-double-conversions.patch
+    debian/patches/Interpret-precision-128-as-shortest-double-conversio.patch:
+    - Fix broken conversion from QVariant to QString (LP: #1620173)
 
  -- Ubuntu Developers <ubuntu-devel-discuss at ubuntu.com>  Wed, 07 Sep 2016 07:42:31 +0000
 
diff --git a/debian/patches/Add-thorough-tests-for-QLocale-string-double-conversions.patch b/debian/patches/Add-thorough-tests-for-QLocale-string-double-conversions.patch
new file mode 100644
index 0000000..be2793a
--- /dev/null
+++ b/debian/patches/Add-thorough-tests-for-QLocale-string-double-conversions.patch
@@ -0,0 +1,204 @@
+From 0659bb810beec671dc7167e3066ad3646ef5ca8b Mon Sep 17 00:00:00 2001
+From: Ulf Hermann <ulf.hermann at theqtcompany.com>
+Date: Tue, 27 Oct 2015 13:13:10 +0100
+Subject: Add thorough tests for QLocale string/double conversions
+
+We want to be sure that the conversions are independent of the current
+locale set by setlocale(3) and we want to test both directions of the
+conversion.
+
+Change-Id: I01be19e680588478d07fd65a48796e806e681863
+Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart at woboq.com>
+---
+ tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 121 +++++++++++++++++++++--
+ 1 file changed, 114 insertions(+), 7 deletions(-)
+
+diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+index edaa000..d765a80 100644
+--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
++++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+@@ -42,6 +42,7 @@
+ #include <qdatetime.h>
+ #include <qprocess.h>
+ #include <float.h>
++#include <locale.h>
+ 
+ #include <qlocale.h>
+ #include <private/qlocale_p.h>
+@@ -140,8 +141,10 @@ private slots:
+     void legacyNames();
+     void unixLocaleName();
+     void matchingLocales();
+-    void double_conversion_data();
+-    void double_conversion();
++    void stringToDouble_data();
++    void stringToDouble();
++    void doubleToString_data();
++    void doubleToString();
+     void long_long_conversion_data();
+     void long_long_conversion();
+     void long_long_conversion_extra();
+@@ -664,7 +667,7 @@ void tst_QLocale::unixLocaleName()
+ #undef TEST_NAME
+ }
+ 
+-void tst_QLocale::double_conversion_data()
++void tst_QLocale::stringToDouble_data()
+ {
+     QTest::addColumn<QString>("locale_name");
+     QTest::addColumn<QString>("num_str");
+@@ -786,7 +789,7 @@ void tst_QLocale::double_conversion_data()
+     QTest::newRow("de_DE 9.876543,0e--2") << QString("de_DE") << QString("9.876543,0e")+QChar(8722)+QString("2")   << false << 0.0;
+ }
+ 
+-void tst_QLocale::double_conversion()
++void tst_QLocale::stringToDouble()
+ {
+ #define MY_DOUBLE_EPSILON (2.22045e-16)
+ 
+@@ -803,6 +806,11 @@ void tst_QLocale::double_conversion()
+     double d = locale.toDouble(num_str, &ok);
+     QCOMPARE(ok, good);
+ 
++    char *currentLocale = setlocale(LC_ALL, "de_DE");
++    QCOMPARE(locale.toDouble(num_str, &ok), d); // make sure result is independent of locale
++    QCOMPARE(ok, good);
++    setlocale(LC_ALL, currentLocale);
++
+     if (ok) {
+         double diff = d - num;
+         if (diff < 0)
+@@ -821,6 +829,90 @@ void tst_QLocale::double_conversion()
+     }
+ }
+ 
++void tst_QLocale::doubleToString_data()
++{
++    QTest::addColumn<QString>("locale_name");
++    QTest::addColumn<QString>("num_str");
++    QTest::addColumn<double>("num");
++    QTest::addColumn<char>("mode");
++    QTest::addColumn<int>("precision");
++
++    QTest::newRow("C 3.4 f 5")  << QString("C") << QString("3.40000")     << 3.4 << 'f' << 5;
++    QTest::newRow("C 3.4 f 0")  << QString("C") << QString("3")           << 3.4 << 'f' << 0;
++    QTest::newRow("C 3.4 e 5")  << QString("C") << QString("3.40000e+00") << 3.4 << 'e' << 5;
++    QTest::newRow("C 3.4 e 0")  << QString("C") << QString("3e+00")       << 3.4 << 'e' << 0;
++    QTest::newRow("C 3.4 g 5")  << QString("C") << QString("3.4")         << 3.4 << 'g' << 5;
++    QTest::newRow("C 3.4 g 1")  << QString("C") << QString("3")           << 3.4 << 'g' << 1;
++
++    QTest::newRow("C 3.4 f 1")  << QString("C") << QString("3.4")     << 3.4 << 'f' << 1;
++    QTest::newRow("C 3.4 e 1")  << QString("C") << QString("3.4e+00") << 3.4 << 'e' << 1;
++    QTest::newRow("C 3.4 g 2")  << QString("C") << QString("3.4")     << 3.4 << 'g' << 2;
++
++    QTest::newRow("de_DE 3,4 f 1")  << QString("de_DE") << QString("3,4")     << 3.4 << 'f' << 1;
++    QTest::newRow("de_DE 3,4 e 1")  << QString("de_DE") << QString("3,4e+00") << 3.4 << 'e' << 1;
++    QTest::newRow("de_DE 3,4 g 2")  << QString("de_DE") << QString("3,4")     << 3.4 << 'g' << 2;
++
++    QTest::newRow("C 0.035003945 f 12") << QString("C") << QString("0.035003945000")   << 0.035003945 << 'f' << 12;
++    QTest::newRow("C 0.035003945 f 6")  << QString("C") << QString("0.035004")         << 0.035003945 << 'f' << 6;
++    QTest::newRow("C 0.035003945 e 10") << QString("C") << QString("3.5003945000e-02") << 0.035003945 << 'e' << 10;
++    QTest::newRow("C 0.035003945 e 4")  << QString("C") << QString("3.5004e-02")       << 0.035003945 << 'e' << 4;
++    QTest::newRow("C 0.035003945 g 11") << QString("C") << QString("0.035003945")      << 0.035003945 << 'g' << 11;
++    QTest::newRow("C 0.035003945 g 5")  << QString("C") << QString("0.035004")         << 0.035003945 << 'g' << 5;
++
++    QTest::newRow("C 0.035003945 f 9")  << QString("C") << QString("0.035003945")   << 0.035003945 << 'f' << 9;
++    QTest::newRow("C 0.035003945 e 7")  << QString("C") << QString("3.5003945e-02") << 0.035003945 << 'e' << 7;
++    QTest::newRow("C 0.035003945 g 8")  << QString("C") << QString("0.035003945")   << 0.035003945 << 'g' << 8;
++
++    QTest::newRow("de_DE 0,035003945 f 9")  << QString("de_DE") << QString("0,035003945")   << 0.035003945 << 'f' << 9;
++    QTest::newRow("de_DE 0,035003945 e 7")  << QString("de_DE") << QString("3,5003945e-02") << 0.035003945 << 'e' << 7;
++    QTest::newRow("de_DE 0,035003945 g 8")  << QString("de_DE") << QString("0,035003945")   << 0.035003945 << 'g' << 8;
++
++    QTest::newRow("C 0.000003945 f 12") << QString("C") << QString("0.000003945000") << 0.000003945 << 'f' << 12;
++    QTest::newRow("C 0.000003945 f 6")  << QString("C") << QString("0.000004")       << 0.000003945 << 'f' << 6;
++    QTest::newRow("C 0.000003945 e 6")  << QString("C") << QString("3.945000e-06")   << 0.000003945 << 'e' << 6;
++    QTest::newRow("C 0.000003945 e 0")  << QString("C") << QString("4e-06")          << 0.000003945 << 'e' << 0;
++    QTest::newRow("C 0.000003945 g 7")  << QString("C") << QString("3.945e-06")      << 0.000003945 << 'g' << 7;
++    QTest::newRow("C 0.000003945 g 1")  << QString("C") << QString("4e-06")          << 0.000003945 << 'g' << 1;
++
++    QTest::newRow("C 0.000003945 f 9")  << QString("C") << QString("0.000003945") << 0.000003945 << 'f' << 9;
++    QTest::newRow("C 0.000003945 e 3")  << QString("C") << QString("3.945e-06")   << 0.000003945 << 'e' << 3;
++    QTest::newRow("C 0.000003945 g 4")  << QString("C") << QString("3.945e-06")   << 0.000003945 << 'g' << 4;
++
++    QTest::newRow("de_DE 0,000003945 f 9")  << QString("de_DE") << QString("0,000003945") << 0.000003945 << 'f' << 9;
++    QTest::newRow("de_DE 0,000003945 e 3")  << QString("de_DE") << QString("3,945e-06")   << 0.000003945 << 'e' << 3;
++    QTest::newRow("de_DE 0,000003945 g 4")  << QString("de_DE") << QString("3,945e-06")   << 0.000003945 << 'g' << 4;
++
++    QTest::newRow("C 12456789012 f 3")  << QString("C") << QString("12456789012.000")     << 12456789012.0 << 'f' << 3;
++    QTest::newRow("C 12456789012 e 13") << QString("C") << QString("1.2456789012000e+10") << 12456789012.0 << 'e' << 13;
++    QTest::newRow("C 12456789012 e 7")  << QString("C") << QString("1.2456789e+10")       << 12456789012.0 << 'e' << 7;
++    QTest::newRow("C 12456789012 g 14") << QString("C") << QString("12456789012")         << 12456789012.0 << 'g' << 14;
++    QTest::newRow("C 12456789012 g 8")  << QString("C") << QString("1.2456789e+10")       << 12456789012.0 << 'g' << 8;
++
++    QTest::newRow("C 12456789012 f 0")  << QString("C") << QString("12456789012")      << 12456789012.0 << 'f' << 0;
++    QTest::newRow("C 12456789012 e 10") << QString("C") << QString("1.2456789012e+10") << 12456789012.0 << 'e' << 10;
++    QTest::newRow("C 12456789012 g 11") << QString("C") << QString("12456789012")      << 12456789012.0 << 'g' << 11;
++
++    QTest::newRow("de_DE 12456789012 f 0")  << QString("de_DE") << QString("12.456.789.012")   << 12456789012.0 << 'f' << 0;
++    QTest::newRow("de_DE 12456789012 e 10") << QString("de_DE") << QString("1,2456789012e+10") << 12456789012.0 << 'e' << 10;
++    QTest::newRow("de_DE 12456789012 g 11") << QString("de_DE") << QString("12.456.789.012")   << 12456789012.0 << 'g' << 11;
++}
++
++void tst_QLocale::doubleToString()
++{
++    QFETCH(QString, locale_name);
++    QFETCH(QString, num_str);
++    QFETCH(double, num);
++    QFETCH(char, mode);
++    QFETCH(int, precision);
++
++    const QLocale locale(locale_name);
++    QCOMPARE(locale.toString(num, mode, precision), num_str);
++
++    char *currentLocale = setlocale(LC_ALL, "de_DE");
++    QCOMPARE(locale.toString(num, mode, precision), num_str);
++    setlocale(LC_ALL, currentLocale);
++}
++
+ void tst_QLocale::long_long_conversion_data()
+ {
+     QTest::addColumn<QString>("locale_name");
+@@ -952,7 +1044,8 @@ void tst_QLocale::fpExceptions()
+ #define _EM_INEXACT 0x00000001
+ #endif
+ 
+-    // check that qdtoa doesn't throw floating point exceptions when they are enabled
++    // check that double-to-string conversion doesn't throw floating point exceptions when they are
++    // enabled
+ #ifdef Q_OS_WIN
+     unsigned int oldbits = _control87(0, 0);
+     _control87( 0 | _EM_INEXACT, _MCW_EM );
+@@ -1830,13 +1923,27 @@ void tst_QLocale::underflowOverflow()
+ a(QLatin1String("0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e10"));
+ 
+     bool ok = false;
+-    a.toDouble(&ok);
++    double d = a.toDouble(&ok);
+     QVERIFY(!ok);
++    QCOMPARE(d, 0.0);
+ 
+     a = QLatin1String("1e600");
+     ok = false;
+-    a.toDouble(&ok);
++    d = a.toDouble(&ok);
++    QVERIFY(!ok); // detectable overflow
++    QCOMPARE(d, 0.0);
++
++    a = QLatin1String("-1e600");
++    ok = false;
++    d = a.toDouble(&ok);
++    QVERIFY(!ok); // detectable underflow
++    QCOMPARE(d, 0.0);
++
++    a = QLatin1String("1e-600");
++    ok = false;
++    d = a.toDouble(&ok);
+     QVERIFY(!ok);
++    QCOMPARE(d, 0.0);
+ 
+     a = QLatin1String("-9223372036854775809");
+     a.toLongLong(&ok);
+-- 
+cgit v1.0-4-g1e03
+
diff --git a/debian/patches/Interpret-precision-128-as-shortest-double-conversio.patch b/debian/patches/Interpret-precision-128-as-shortest-double-conversio.patch
new file mode 100644
index 0000000..7a97525
--- /dev/null
+++ b/debian/patches/Interpret-precision-128-as-shortest-double-conversio.patch
@@ -0,0 +1,549 @@
+From 726fed0d67013cbfac7921d3d4613ca83406fb0f Mon Sep 17 00:00:00 2001
+From: Ulf Hermann <ulf.hermann at theqtcompany.com>
+Date: Fri, 16 Oct 2015 16:52:51 +0200
+Subject: [PATCH] Interpret precision == -128 as "shortest" double conversion
+
+Also use this for converting doubles with QVariant. We generally want
+exact results there, rather than adding rounding errors whenever we
+convert.
+
+[ChangeLog][QtCore][QLocale] Added special value for double conversion
+precision to get shortest accurate representation.
+
+Change-Id: I905b8a103f39adf31d24b6ce2c8a283cf271b597
+Reviewed-by: Lars Knoll <lars.knoll at theqtcompany.com>
+---
+ src/corelib/kernel/qvariant.cpp                    | 21 ++----
+ src/corelib/tools/qlocale.cpp                      | 21 +++++-
+ src/corelib/tools/qlocale.h                        |  4 ++
+ src/corelib/tools/qlocale.qdoc                     | 17 +++++
+ src/corelib/tools/qlocale_tools.cpp                | 30 +++++---
+ src/corelib/tools/qlocale_tools_p.h                |  4 +-
+ tests/auto/corelib/kernel/qvariant/qvariant.pro    |  5 +-
+ .../auto/corelib/kernel/qvariant/tst_qvariant.cpp  | 51 ++++++++++---
+ tests/auto/corelib/tools/qlocale/test/test.pro     |  4 ++
+ tests/auto/corelib/tools/qlocale/tst_qlocale.cpp   | 83 +++++++++++++++-------
+ 10 files changed, 173 insertions(+), 67 deletions(-)
+
+diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
+index fdcbdb1..1e755cf 100644
+--- a/src/corelib/kernel/qvariant.cpp
++++ b/src/corelib/kernel/qvariant.cpp
+@@ -56,6 +56,7 @@
+ #include "qbytearraylist.h"
+ #endif
+ #include "private/qvariant_p.h"
++#include "private/qlocale_p.h"
+ #include "qmetatype_p.h"
+ #include <qmetaobject.h>
+ 
+@@ -71,18 +72,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifndef DBL_MANT_DIG
+-#  define DBL_MANT_DIG  53
+-#endif
+-#ifndef FLT_MANT_DIG
+-#  define FLT_MANT_DIG  24
+-#endif
+-
+-const int log10_2_10000 = 30103;    // log10(2) * 100000
+-// same as C++11 std::numeric_limits<T>::max_digits10
+-const int max_digits10_double = (DBL_MANT_DIG * log10_2_10000) / 100000 + 2;
+-const int max_digits10_float = (FLT_MANT_DIG * log10_2_10000) / 100000 + 2;
+-
+ namespace {
+ class HandlersManager
+ {
+@@ -433,10 +422,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
+             *str = QString::number(qMetaTypeUNumber(d));
+             break;
+         case QMetaType::Float:
+-            *str = QString::number(d->data.f, 'g', max_digits10_float);
++            *str = QString::number(d->data.f, 'g', QLocale::FloatingPointShortest);
+             break;
+         case QVariant::Double:
+-            *str = QString::number(d->data.d, 'g', max_digits10_double);
++            *str = QString::number(d->data.d, 'g', QLocale::FloatingPointShortest);
+             break;
+ #if !defined(QT_NO_DATESTRING)
+         case QVariant::Date:
+@@ -625,10 +614,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
+             *ba = v_cast<QString>(d)->toUtf8();
+             break;
+         case QVariant::Double:
+-            *ba = QByteArray::number(d->data.d, 'g', max_digits10_double);
++            *ba = QByteArray::number(d->data.d, 'g', QLocale::FloatingPointShortest);
+             break;
+         case QMetaType::Float:
+-            *ba = QByteArray::number(d->data.f, 'g', max_digits10_float);
++            *ba = QByteArray::number(d->data.f, 'g', QLocale::FloatingPointShortest);
+             break;
+         case QMetaType::Char:
+         case QMetaType::SChar:
+diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
+index dcb77a2..072d62f 100644
+--- a/src/corelib/tools/qlocale.cpp
++++ b/src/corelib/tools/qlocale.cpp
+@@ -2743,7 +2743,7 @@ QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const Q
+                                     const QChar exponential, const QChar group, const QChar decimal,
+                                     double d, int precision, DoubleForm form, int width, unsigned flags)
+ {
+-    if (precision < 0)
++    if (precision != QLocale::FloatingPointShortest && precision < 0)
+         precision = 6;
+     if (width < 0)
+         width = 0;
+@@ -2753,7 +2753,9 @@ QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const Q
+ 
+     int decpt;
+     int bufSize = 1;
+-    if (form == DFDecimal) // optimize for numbers smaller than 512k
++    if (precision == QLocale::FloatingPointShortest)
++        bufSize += DoubleMaxSignificant;
++    else if (form == DFDecimal) // optimize for numbers between -512k and 512k
+         bufSize += ((d > (1 << 19) || d < -(1 << 19)) ? DoubleMaxDigitsBeforeDecimal : 6) +
+                 precision;
+     else // Add extra digit due to different interpretations of precision. Also, "nan" has to fit.
+@@ -2798,7 +2800,20 @@ QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const Q
+                 PrecisionMode mode = (flags & Alternate) ?
+                             PMSignificantDigits : PMChopTrailingZeros;
+ 
+-                if (decpt != digits.length() && (decpt <= -4 || decpt > precision))
++                int cutoff = precision < 0 ? 6 : precision;
++                // Find out which representation is shorter
++                if (precision == QLocale::FloatingPointShortest && decpt > 0) {
++                    cutoff = digits.length() + 4; // 'e', '+'/'-', one digit exponent
++                    if (decpt <= 10) {
++                        ++cutoff;
++                    } else {
++                        cutoff += decpt > 100 ? 2 : 1;
++                    }
++                    if (!always_show_decpt && digits.length() > decpt)
++                        ++cutoff; // decpt shown in exponent form, but not in decimal form
++                }
++
++                if (decpt != digits.length() && (decpt <= -4 || decpt > cutoff))
+                     num_str = exponentForm(_zero, decimal, exponential, group, plus, minus,
+                                            digits, decpt, precision, mode,
+                                            always_show_decpt);
+diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
+index 729fd73..f64a25b 100644
+--- a/src/corelib/tools/qlocale.h
++++ b/src/corelib/tools/qlocale.h
+@@ -848,6 +848,10 @@ public:
+     };
+     Q_DECLARE_FLAGS(NumberOptions, NumberOption)
+ 
++    enum FloatingPointPrecisionOption {
++        FloatingPointShortest = -128
++    };
++
+     enum CurrencySymbolFormat {
+         CurrencyIsoCode,
+         CurrencySymbol,
+diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc
+index c87e67c..03095d8 100644
+--- a/src/corelib/tools/qlocale.qdoc
++++ b/src/corelib/tools/qlocale.qdoc
+@@ -941,6 +941,23 @@
+ */
+ 
+ /*!
++    \enum QLocale::FloatingPointPrecisionOption
++
++    This enum defines constants that can be given as precision to QString::number(),
++    QByteArray::number(), and QLocale::toString() when converting floats or doubles,
++    in order to express a variable number of digits as precision.
++
++    
alue FloatingPointShortest The conversion algorithm will try to find the
++            shortest accurate representation for the given number. "Accurate" means
++            that you get the exact same number back from an inverse conversion on
++            the generated string representation.
++
++    \sa toString(), QString, QByteArray
++
++    \since 5.7
++*/
++
++/*!
+     \enum QLocale::MeasurementSystem
+ 
+     This enum defines which units are used for measurement.
+diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp
+index 18d1096..890f63a 100644
+--- a/src/corelib/tools/qlocale_tools.cpp
++++ b/src/corelib/tools/qlocale_tools.cpp
+@@ -114,10 +114,16 @@ void doubleToAscii(double d, QLocaleData::DoubleForm form, int precision, char *
+     if (form == QLocaleData::DFExponent && precision >= 0)
+         ++precision;
+ 
+-    double_conversion::DoubleToStringConverter::DoubleToAscii(d,
+-            form == QLocaleData::DFDecimal ? double_conversion::DoubleToStringConverter::FIXED :
+-                                             double_conversion::DoubleToStringConverter::PRECISION,
+-            precision, buf, bufSize, &sign, &length, &decpt);
++    double_conversion::DoubleToStringConverter::DtoaMode mode;
++    if (precision == QLocale::FloatingPointShortest) {
++        mode = double_conversion::DoubleToStringConverter::SHORTEST;
++    } else if (form == QLocaleData::DFSignificantDigits || form == QLocaleData::DFExponent) {
++        mode = double_conversion::DoubleToStringConverter::PRECISION;
++    } else {
++        mode = double_conversion::DoubleToStringConverter::FIXED;
++    }
++    double_conversion::DoubleToStringConverter::DoubleToAscii(d, mode, precision, buf, bufSize,
++                                                              &sign, &length, &decpt);
+ #else // QT_NO_DOUBLECONVERSION || QT_BOOTSTRAPPED
+ 
+     // Cut the precision at 999, to fit it into the format string. We can't get more than 17
+@@ -126,6 +132,8 @@ void doubleToAscii(double d, QLocaleData::DoubleForm form, int precision, char *
+     // to honor higher precisions. We define that at more than 999 digits that is not the case.
+     if (precision > 999)
+         precision = 999;
++    else if (precision == QLocale::FloatingPointShortest)
++        precision = QLocaleData::DoubleMaxSignificant; // "shortest" mode not supported by snprintf
+ 
+     if (isZero(d)) {
+         // Negative zero is expected as simple "0", not "-0". We cannot do d < 0, though.
+@@ -442,7 +450,7 @@ QString qlltoa(qlonglong l, int base, const QChar zero)
+ }
+ 
+ QString &decimalForm(QChar zero, QChar decimal, QChar group,
+-                     QString &digits, int decpt, uint precision,
++                     QString &digits, int decpt, int precision,
+                      PrecisionMode pm,
+                      bool always_show_decpt,
+                      bool thousands_group)
+@@ -459,11 +467,11 @@ QString &decimalForm(QChar zero, QChar decimal, QChar group,
+ 
+     if (pm == PMDecimalDigits) {
+         uint decimal_digits = digits.length() - decpt;
+-        for (uint i = decimal_digits; i < precision; ++i)
++        for (int i = decimal_digits; i < precision; ++i)
+             digits.append(zero);
+     }
+     else if (pm == PMSignificantDigits) {
+-        for (uint i = digits.length(); i < precision; ++i)
++        for (int i = digits.length(); i < precision; ++i)
+             digits.append(zero);
+     }
+     else { // pm == PMChopTrailingZeros
+@@ -485,18 +493,18 @@ QString &decimalForm(QChar zero, QChar decimal, QChar group,
+ 
+ QString &exponentForm(QChar zero, QChar decimal, QChar exponential,
+                       QChar group, QChar plus, QChar minus,
+-                      QString &digits, int decpt, uint precision,
++                      QString &digits, int decpt, int precision,
+                       PrecisionMode pm,
+                       bool always_show_decpt)
+ {
+     int exp = decpt - 1;
+ 
+     if (pm == PMDecimalDigits) {
+-        for (uint i = digits.length(); i < precision + 1; ++i)
++        for (int i = digits.length(); i < precision + 1; ++i)
+             digits.append(zero);
+     }
+     else if (pm == PMSignificantDigits) {
+-        for (uint i = digits.length(); i < precision; ++i)
++        for (int i = digits.length(); i < precision; ++i)
+             digits.append(zero);
+     }
+     else { // pm == PMChopTrailingZeros
+@@ -534,7 +542,7 @@ QString qdtoa(qreal d, int *decpt, int *sign)
+ 
+     // Some versions of libdouble-conversion like an extra digit, probably for '

-- 
qtbase packaging



More information about the pkg-kde-commits mailing list