fix failing unit test

f41
David Tardon 9 years ago
parent 824672b445
commit 02d32318c8

@ -0,0 +1,57 @@
From fd94964ad6611d7f20523272fe6752d38e3aec88 Mon Sep 17 00:00:00 2001
From: David Tardon <dtardon@redhat.com>
Date: Mon, 14 Dec 2015 21:17:43 +0100
Subject: [PATCH] don't be creative and use a simple lookup table
The original code breaks at least in optimized build on Fedora x86,
because there nBits for 256 is computed as 9, not 8.
Change-Id: Ib157c415bc9e231bf7fd544349810e6bc83c8fcc
---
oox/source/ole/vbaexport.cxx | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 2cb2fea..2041d50 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -9,6 +9,7 @@
#include <sal/config.h>
+#include <cassert>
#include <cmath>
#include <random>
@@ -324,8 +325,26 @@ void VBACompressionChunk::CopyTokenHelp(sal_uInt16& rLengthMask, sal_uInt16& rOf
sal_uInt16& rBitCount, sal_uInt16& rMaximumLength)
{
sal_uInt16 nDifference = mnDecompressedCurrent;
- sal_uInt16 nBitCount = std::ceil(std::log(nDifference)/std::log(2));
- rBitCount = std::max<sal_uInt16>(nBitCount, 4);
+ assert(nDifference <= 4096);
+ assert(nDifference >= 1);
+ if (nDifference >= 2049)
+ rBitCount = 12;
+ else if (nDifference >= 1025)
+ rBitCount = 11;
+ else if (nDifference >= 513)
+ rBitCount = 10;
+ else if (nDifference >= 257)
+ rBitCount = 9;
+ else if (nDifference >= 129)
+ rBitCount = 8;
+ else if (nDifference >= 65)
+ rBitCount = 7;
+ else if (nDifference >= 33)
+ rBitCount = 6;
+ else if (nDifference >= 17)
+ rBitCount = 5;
+ else
+ rBitCount = 4;
rLengthMask = 0xffff >> rBitCount;
rOffsetMask = ~rLengthMask;
rMaximumLength = rLengthMask + 3;
--
2.5.0

@ -257,6 +257,7 @@ Patch18: 0003-lokdocview-Set-a-default-path-for-LOK-init.patch
Patch19: 0001-tdf-96317-Add-API-for-copy-paste-from-to-the-widget.patch
Patch20: 0001-tdf-96384-Add-a-new-signal-text-selection-to-lokdocv.patch
Patch21: 0001-Resolves-rhbz-1289394-gtk3-implement-tooltips-native.patch
Patch22: 0001-don-t-be-creative-and-use-a-simple-lookup-table.patch
%define instdir %{_libdir}
%define baseinstdir %{instdir}/libreoffice
@ -950,8 +951,6 @@ git commit -q -a -m 'add Red Hat colors to palette'
git am %{patches}
sed -i -e /CppunitTest_sw_ooxmlimport/d sw/Module_sw.mk
# fails on i686
sed -i -e /CppunitTest_oox_vba_compression/d oox/Module_oox.mk
# fails on all secondary platforms
sed -i -e /CppunitTest_vcl_outdev/d vcl/Module_vcl.mk
sed -i -e /CppunitTest_vcl_bitmap_test/d vcl/Module_vcl.mk

Loading…
Cancel
Save