kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0073-Avoid-inaccurate-floating-point-computations.patch

f0633d
From 7a3eed5eb60d97fec397d3ad5c0bf62c703f8cf9 Mon Sep 17 00:00:00 2001
f0633d
From: Stephan Bergmann <sbergman@redhat.com>
f0633d
Date: Tue, 17 Dec 2013 16:46:17 +0100
f0633d
Subject: [PATCH 073/109] Avoid inaccurate floating-point computations
f0633d
f0633d
...otherwise at least my --disable-dbgutil --disable-debug Linux x86_64 build
f0633d
failed the CppunitTest_sax_cpputest with 8999999 vs. 9000000 nanoseconds.
f0633d
f0633d
(cherry picked from commit 695671eb18674ea58103093b9cf31a31afe8d2fd,
f0633d
incorporating follow-up fixes 71448690d7c5904df45bf98243c5bb05a99245e5
f0633d
"readUnsignedNumberMaxDigits can read more than maxDigits chars" and
f0633d
b9bcc9c5c10841dcdfa9ff5814344ce667678df3 "...and nDigits > 9 is harmless in
f0633d
following for loop and need not be capped")
f0633d
f0633d
Change-Id: I05e0febf413f9f9e01227a0cc4e0f46a5243fe61
f0633d
(cherry picked from commit 5bffe4dffd7496057c1fd70e46af800396f5b346)
f0633d
Reviewed-on: https://gerrit.libreoffice.org/7122
f0633d
Reviewed-by: Michael Stahl <mstahl@redhat.com>
f0633d
Tested-by: Michael Stahl <mstahl@redhat.com>
f0633d
---
f0633d
 sax/source/tools/converter.cxx | 10 +++++++---
f0633d
 1 file changed, 7 insertions(+), 3 deletions(-)
f0633d
f0633d
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
f0633d
index bc8b0c1..429f5e4 100644
f0633d
--- a/sax/source/tools/converter.cxx
f0633d
+++ b/sax/source/tools/converter.cxx
f0633d
@@ -1120,9 +1120,13 @@ bool Converter::convertDuration(util::Duration& rDuration,
f0633d
                     {
f0633d
                         if (-1 != nTemp)
f0633d
                         {
f0633d
-                            const sal_Int32 nDigits = std::min<sal_Int32>(nPos - nStart, 9);
f0633d
-                            OSL_ENSURE(nDigits > 0, "bad code monkey: negative digits");
f0633d
-                            nNanoSeconds=static_cast<double>(nTemp)*(1000000000.0/pow(10.0,nDigits));
f0633d
+                            nNanoSeconds = nTemp;
f0633d
+                            sal_Int32 nDigits = nPos - nStart;
f0633d
+                            assert(nDigits >= 0);
f0633d
+                            for (; nDigits < 9; ++nDigits)
f0633d
+                            {
f0633d
+                                nNanoSeconds *= 10;
f0633d
+                            }
f0633d
                             nTemp=-1;
f0633d
                             if (sal_Unicode('S') == string[nPos])
f0633d
                             {
f0633d
-- 
f0633d
1.8.4.2
f0633d