summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKarim Pinter <karim.pinter@qt.io>2017-01-18 11:00:13 +0200
committerKarim Pinter <karim.pinter@qt.io>2017-01-20 09:40:12 +0000
commit82c5cc6532ac5d0323ecda94b6767e1fdaef2639 (patch)
tree116a67e467457c394c7b2d62ea168082332e7ea4 /src
parentb7f8783f25cf1ff0eadbab59701acd46bff58e9a (diff)
downloadqtxmlpatterns-82c5cc6532ac5d0323ecda94b6767e1fdaef2639.tar.gz
fractionDigits doesn't count the trailing 0s anymore
fractionDigits were counting also the trailing 0s, which is against the standard https://www.w3.org/TR/xmlschema-2/#rf-fractionDigits Task-number: QTBUG-58245 Change-Id: I9175d4870de82e25c4df2317394ccfba8048fb48 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/xmlpatterns/schema/qxsdtypechecker.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/xmlpatterns/schema/qxsdtypechecker.cpp b/src/xmlpatterns/schema/qxsdtypechecker.cpp
index 2e4ce8e..d6b224f 100644
--- a/src/xmlpatterns/schema/qxsdtypechecker.cpp
+++ b/src/xmlpatterns/schema/qxsdtypechecker.cpp
@@ -37,6 +37,8 @@
**
****************************************************************************/
+#include <QtMath>
+
#include "qxsdtypechecker_p.h"
#include "qabstractdatetime_p.h"
@@ -150,13 +152,12 @@ static int fractionDigitsForDecimal(const QString &lexicalValue)
{
// we use the lexical value here, as the conversion to double might strip
// away decimal positions
-
- QString trimmedValue(lexicalValue.trimmed());
- const int pos = trimmedValue.indexOf(QLatin1Char('.'));
- if (pos == -1) // no '.' -> 0 fraction digits
+ bool ok = false;
+ double dbl = lexicalValue.toDouble(&ok);
+ if (!ok)
return 0;
- else
- return (trimmedValue.length() - pos - 1);
+ dbl = dbl - qFloor(dbl);
+ return QString::number(dbl).length() - 2;
}
XsdTypeChecker::XsdTypeChecker(const XsdSchemaContext::Ptr &context, const QVector<QXmlName> &namespaceBindings, const QSourceLocation &location)