]> git.pld-linux.org Git - packages/grantlee-qt5.git/blame - x87fix.patch
- added x87fix.patch from https://github.com/steveire/grantlee/commit/7e34ffaff40fc08...
[packages/grantlee-qt5.git] / x87fix.patch
CommitLineData
652225d7
WF
1From 7e34ffaff40fc085a15bb0ffabb5f247795581fd Mon Sep 17 00:00:00 2001
2From: Fabian Vogt <fabian@ritter-vogt.de>
3Date: Sun, 13 Nov 2022 14:01:21 +0100
4Subject: [PATCH] Fix formatting of some larger file sizes on 32bit x86
5
6With the x87 FPU available, GCC uses long double precision for some variables.
7Due to the function call passing a double, some comparisons break down.
8That resulted in "1.00 YB" being printed as "1000.00 ZB" instead.
9
10Fixes #85
11---
12 templates/lib/util.cpp | 7 +++++++
13 1 file changed, 7 insertions(+)
14
15diff --git a/templates/lib/util.cpp b/templates/lib/util.cpp
16index 504674a7..5924cdf5 100644
17--- a/templates/lib/util.cpp
18+++ b/templates/lib/util.cpp
19@@ -23,6 +23,7 @@
20 #include "metaenumvariable_p.h"
21 #include "metatype.h"
22
23+#include <cfloat>
24 #include <QtCore/QStringList>
25
26 QString Grantlee::unescapeStringLiteral(const QString &input)
27@@ -212,7 +213,13 @@ std::pair<qreal, QString> Grantlee::calcFileSize(qreal size, int unitSystem,
28 bool found = false;
29 int count = 0;
30 const qreal baseVal = (_unitSystem == 10) ? 1000.0F : 1024.0F;
31+#if FLT_EVAL_METHOD == 2
32+ // Avoid that this is treated as long double, as the increased
33+ // precision breaks the comparison below.
34+ volatile qreal current = 1.0F;
35+#else
36 qreal current = 1.0F;
37+#endif
38 int units = decimalUnits.size();
39 while (!found && (count < units)) {
40 current *= baseVal;
This page took 0.395807 seconds and 4 git commands to generate.