diff options
-rw-r--r-- | Makefile.fetch | 1 | ||||
-rw-r--r-- | RepositoryExternal.mk | 17 | ||||
-rw-r--r-- | download.lst | 2 | ||||
-rw-r--r-- | external/Module_external.mk | 1 | ||||
-rw-r--r-- | external/dtoa/Module_dtoa.mk | 17 | ||||
-rw-r--r-- | external/dtoa/README | 10 | ||||
-rw-r--r-- | external/dtoa/StaticLibrary_dtoa.mk | 22 | ||||
-rw-r--r-- | external/dtoa/UnpackedTarball_dtoa.mk | 20 | ||||
-rw-r--r-- | external/dtoa/include_header.patch | 37 | ||||
-rw-r--r-- | readlicense_oo/license/license.xml | 19 | ||||
-rw-r--r-- | sc/qa/unit/bugfix-test.cxx | 30 | ||||
-rw-r--r-- | svl/Library_svl.mk | 1 | ||||
-rw-r--r-- | svl/source/numbers/zforfind.cxx | 48 |
13 files changed, 200 insertions, 25 deletions
diff --git a/Makefile.fetch b/Makefile.fetch index 1fe9970f6237..cfa3dc58c3a5 100644 --- a/Makefile.fetch +++ b/Makefile.fetch @@ -112,6 +112,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk $(SRCDIR)/download.lst $(S $(call fetch_Optional,CAIRO,PIXMAN_TARBALL) \ $(call fetch_Optional,CDR,CDR_TARBALL) \ $(call fetch_Optional,CLUCENE,CLUCENE_TARBALL) \ + DTOA_TARBALL \ $(call fetch_Optional,LIBCMIS,LIBCMIS_TARBALL) \ $(call fetch_Optional,COINMP,COINMP_TARBALL) \ $(call fetch_Optional,CPPUNIT,CPPUNIT_TARBALL) \ diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index 1f36dda8f202..a0de7e340de8 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -4206,6 +4206,23 @@ endef endif # SYSTEM_QRCODEGEN +define gb_LinkTarget__use_dtoa +$(call gb_LinkTarget_use_unpacked,$(1),dtoa) +$(call gb_LinkTarget_set_include,$(1),\ + -I$(call gb_UnpackedTarball_get_dir,dtoa/include/)\ + $$(INCLUDE) \ +) +$(call gb_LinkTarget_use_static_libraries,$(1),\ + dtoa \ +) + +endef + +define gb_ExternalProject__use_dtoa +$(call gb_ExternalProject_use_static_libraries,$(1),dtoa) + +endef + $(eval $(call gb_Helper_register_packages_for_install,ucrt_binarytable,\ $(if $(UCRT_REDISTDIR),ucrt) \ )) diff --git a/download.lst b/download.lst index 910e1e09ad47..7141467b9fe3 100644 --- a/download.lst +++ b/download.lst @@ -21,6 +21,8 @@ export CDR_SHA256SUM := 01cd00b04a030977e544433c2d127c997205332cd9b8e35ec0ee1711 export CDR_TARBALL := libcdr-0.1.6.tar.xz export CLUCENE_SHA256SUM := ddfdc433dd8ad31b5c5819cc4404a8d2127472a3b720d3e744e8c51d79732eab export CLUCENE_TARBALL := 48d647fbd8ef8889e5a7f422c1bfda94-clucene-core-2.3.3.4.tar.gz +export DTOA_SHA256SUM := 0082d0684f7db6f62361b76c4b7faba19e0c7ce5cb8e36c4b65fea8281e711b4 +export DTOA_TARBALL := dtoa-20180411.tgz export LIBCMIS_SHA256SUM := d7b18d9602190e10d437f8a964a32e983afd57e2db316a07d87477a79f5000a2 export LIBCMIS_TARBALL := libcmis-0.5.2.tar.xz export COINMP_SHA256SUM := 86c798780b9e1f5921fe4efe651a93cb420623b45aa1fdff57af8c37f116113f diff --git a/external/Module_external.mk b/external/Module_external.mk index 08086c3e2985..286759927781 100644 --- a/external/Module_external.mk +++ b/external/Module_external.mk @@ -31,6 +31,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\ $(call gb_Helper_optional,CPPUNIT,cppunit) \ $(call gb_Helper_optional,CT2N,ct2n) \ $(call gb_Helper_optional,CURL,curl) \ + dtoa \ $(call gb_Helper_optional,EBOOK,libebook) \ $(call gb_Helper_optional,EPM,epm) \ $(call gb_Helper_optional,EPOXY,epoxy) \ diff --git a/external/dtoa/Module_dtoa.mk b/external/dtoa/Module_dtoa.mk new file mode 100644 index 000000000000..c652f97e0b58 --- /dev/null +++ b/external/dtoa/Module_dtoa.mk @@ -0,0 +1,17 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Module_Module,dtoa)) + +$(eval $(call gb_Module_add_targets,dtoa,\ + UnpackedTarball_dtoa \ + StaticLibrary_dtoa \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/external/dtoa/README b/external/dtoa/README new file mode 100644 index 000000000000..9f46b9865d84 --- /dev/null +++ b/external/dtoa/README @@ -0,0 +1,10 @@ +dtoa is available from [ https://www.netlib.org/fp/ ]. + +Used to convert a decimal string to double (until std::from_chars is available on used compilers). +Packaged using + + mkdir dtoa && mkdir dtoa/src && wget https://www.netlib.org/fp/dtoa.c -O dtoa/src/dtoa.c && \ + printf 'd8bab255476f39ea495c8c8ed164f9077da926e6ca7afb9ad3c56d337c4484fe dtoa/src/dtoa.c' | sha256sum -c && \ + tar -c --owner=0 --group=0 --mode=go=r,u=rw --mtime='Wed, 11 Apr 2018 15:59:39 GMT' dtoa/src/dtoa.c | gzip -n > dtoa-20180411.tgz && \ + printf '0082d0684f7db6f62361b76c4b7faba19e0c7ce5cb8e36c4b65fea8281e711b4 dtoa-20180411.tgz' | sha256sum -c +(where the date "Wed, 11 Apr 2018 15:59:39 GMT" is from `wget -S https://www.netlib.org/fp/dtoa.c` "Last-Modified: Wed, 11 Apr 2018 15:59:39 GMT" header). diff --git a/external/dtoa/StaticLibrary_dtoa.mk b/external/dtoa/StaticLibrary_dtoa.mk new file mode 100644 index 000000000000..edb358c21da4 --- /dev/null +++ b/external/dtoa/StaticLibrary_dtoa.mk @@ -0,0 +1,22 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_StaticLibrary_StaticLibrary,dtoa)) + +$(eval $(call gb_StaticLibrary_use_unpacked,dtoa,dtoa)) + +$(eval $(call gb_StaticLibrary_add_cflags,dtoa,-DIEEE_8087)) + +$(eval $(call gb_StaticLibrary_set_warnings_disabled,dtoa)) + +$(eval $(call gb_StaticLibrary_add_generated_cobjects,dtoa,\ + UnpackedTarball/dtoa/src/dtoa \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/external/dtoa/UnpackedTarball_dtoa.mk b/external/dtoa/UnpackedTarball_dtoa.mk new file mode 100644 index 000000000000..c700b485fe8c --- /dev/null +++ b/external/dtoa/UnpackedTarball_dtoa.mk @@ -0,0 +1,20 @@ +#-*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_UnpackedTarball_UnpackedTarball,dtoa)) + +$(eval $(call gb_UnpackedTarball_set_tarball,dtoa,$(DTOA_TARBALL))) + +$(eval $(call gb_UnpackedTarball_set_patchlevel,dtoa,1)) + +$(eval $(call gb_UnpackedTarball_add_patches,dtoa, \ + external/dtoa/include_header.patch \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/external/dtoa/include_header.patch b/external/dtoa/include_header.patch new file mode 100644 index 000000000000..c34c78d3f6aa --- /dev/null +++ b/external/dtoa/include_header.patch @@ -0,0 +1,37 @@ +--- /dev/null ++++ dtoa/include/dtoa.h +@@ -0,0 +1,3 @@ ++extern "C" double strtod_nolocale(const char *s00, char **se); ++extern "C" char *dtoa_nolocale(double d, int mode, int ndigits, ++ int *decpt, int *sign, char **rve); +--- dtoa/src/dtoa.c.orig ++++ dtoa/src/dtoa.c +@@ -1502,8 +1502,8 @@ static unsigned int maxthreads = 0; + #define Kmax 7 + + #ifdef __cplusplus +-extern "C" double strtod(const char *s00, char **se); +-extern "C" char *dtoa(double d, int mode, int ndigits, ++extern "C" double strtod_nolocale(const char *s00, char **se); ++extern "C" char *dtoa_nolocale(double d, int mode, int ndigits, + int *decpt, int *sign, char **rve); + #endif + +@@ -3429,7 +3429,7 @@ retlow1: + #endif /* NO_STRTOD_BIGCOMP */ + + double +-strtod(const char *s00, char **se) ++strtod_nolocale(const char *s00, char **se) + { + int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1; + int esign, i, j, k, nd, nd0, nf, nz, nz0, nz1, sign; +@@ -6185,7 +6185,7 @@ dtoa_r(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve, char + } + + char * +-dtoa(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve) ++dtoa_nolocale(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve) + { + /* Sufficient space is allocated to the return value + to hold the suppressed trailing zeros. diff --git a/readlicense_oo/license/license.xml b/readlicense_oo/license/license.xml index 0d4c93d7e9cd..d032d410be98 100644 --- a/readlicense_oo/license/license.xml +++ b/readlicense_oo/license/license.xml @@ -1849,6 +1849,25 @@ Software.</p> </blockquote> </div> + <h2>dtoa</h2> + <p>The following software may be included in this product: dtoa.</p> + <p>dtoa code is covered by the MIT license:</p> + <blockquote> + <p> The author of this software is David M. Gay.</p> + + <p> Copyright (c) 1991, 2000, 2001 by Lucent Technologies.</p> + + <p>Permission to use, copy, modify, and distribute this software for any + purpose without fee is hereby granted, provided that this entire notice + is included in all copies of any software which is or includes a copy + or modification of this software and in all copies of the supporting + documentation for such software.</p> + + <p>THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY + REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.</p> + </blockquote> <h2>Random123: a Library of Counter-Based Random Number Generators</h2> <p>The following software may be included in this product: Random123: a Library of Counter-Based Random Number Generators. Use of any of this software is governed by the terms of the license below:</p> diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx index d0cf10a74b9b..2b2523319cec 100644 --- a/sc/qa/unit/bugfix-test.cxx +++ b/sc/qa/unit/bugfix-test.cxx @@ -47,6 +47,7 @@ public: void testTdf31231(); void testTdf128951(); void testTdf129789(); + void testTdf130725(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testTdf64229); @@ -64,6 +65,7 @@ public: CPPUNIT_TEST(testTdf31231); CPPUNIT_TEST(testTdf128951); CPPUNIT_TEST(testTdf129789); + CPPUNIT_TEST(testTdf130725); CPPUNIT_TEST_SUITE_END(); private: uno::Reference<uno::XInterface> m_xCalcComponent; @@ -470,6 +472,34 @@ void ScFiltersTest::testTdf129789() xDocSh->DoClose(); } +void ScFiltersTest::testTdf130725() +{ + css::uno::Reference<css::frame::XDesktop2> xDesktop + = css::frame::Desktop::create(comphelper::getProcessComponentContext()); + CPPUNIT_ASSERT(xDesktop.is()); + + // 1. Create spreadsheet + css::uno::Sequence<css::beans::PropertyValue> aHiddenArgList(1); + aHiddenArgList[0].Name = "Hidden"; + aHiddenArgList[0].Value <<= true; + + css::uno::Reference<css::lang::XComponent> xComponent + = xDesktop->loadComponentFromURL("private:factory/scalc", "_blank", 0, aHiddenArgList); + css::uno::Reference<css::sheet::XSpreadsheetDocument> xDoc(xComponent, + css::uno::UNO_QUERY_THROW); + + // 2. Insert 0.0042 into a cell as a formula, to force the conversion from string to double + css::uno::Reference<css::sheet::XCellRangesAccess> xSheets(xDoc->getSheets(), + css::uno::UNO_QUERY_THROW); + css::uno::Reference<css::table::XCell> xCell = xSheets->getCellByPosition(0, 0, 0); + xCell->setFormula("0.0042"); // this assumes en-US locale + + // 3. Check that the value is the nearest double-precision representation of the decimal 0.0042 + // (it was 0.0042000000000000006 instead of 0.0041999999999999997). + CPPUNIT_ASSERT_EQUAL_MESSAGE("Value must be the nearest representation of decimal 0.0042", + 0.0042, xCell->getValue()); // strict equality +} + ScFiltersTest::ScFiltersTest() : ScBootstrapFixture( "sc/qa/unit/data" ) { diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk index c49417d21512..b2ed3f5a6089 100644 --- a/svl/Library_svl.mk +++ b/svl/Library_svl.mk @@ -23,6 +23,7 @@ $(eval $(call gb_Library_use_externals,svl,\ boost_headers \ $(if $(filter LINUX MACOSX ANDROID %BSD SOLARIS HAIKU,$(OS)), \ curl) \ + dtoa \ icu_headers \ icuuc \ mdds_headers \ diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index e56a5cef8502..32b471a5df23 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -18,6 +18,7 @@ */ #include <cstdlib> +#include <dtoa.h> #include <float.h> #include <comphelper/string.hxx> #include <sal/log.hxx> @@ -36,6 +37,8 @@ #include "zforscan.hxx" #include <svl/zformat.hxx> +#include <memory> + #include "zforfind.hxx" #ifndef DBG_UTIL @@ -151,35 +154,30 @@ static void TransformInput( SvNumberFormatter const * pFormatter, OUString& rStr */ double ImpSvNumberInputScan::StringToDouble( const OUString& rStr, bool bForceFraction ) { - double fNum = 0.0; - double fFrac = 0.0; - int nExp = 0; - sal_Int32 nPos = 0; - sal_Int32 nLen = rStr.getLength(); - bool bPreSep = !bForceFraction; - - while (nPos < nLen) + std::unique_ptr<char[]> bufInHeap; + constexpr int bufOnStackSize = 256; + char bufOnStack[bufOnStackSize]; + char* buf = bufOnStack; + const sal_Int32 bufsize = rStr.getLength() + (bForceFraction ? 2 : 1); + if (bufsize > bufOnStackSize) { - if (rStr[nPos] == '.') - { - bPreSep = false; - } - else if (bPreSep) - { - fNum = fNum * 10.0 + static_cast<double>(rStr[nPos] - '0'); - } - else - { - fFrac = fFrac * 10.0 + static_cast<double>(rStr[nPos] - '0'); - --nExp; - } - nPos++; + bufInHeap = std::make_unique<char[]>(bufsize); + buf = bufInHeap.get(); } - if ( fFrac ) + char* p = buf; + if (bForceFraction) + *p++ = '.'; + for (sal_Int32 nPos = 0; nPos < rStr.getLength(); ++nPos) { - return fNum + ::rtl::math::pow10Exp( fFrac, nExp ); + sal_Unicode c = rStr[nPos]; + if (c == '.' || (c >= '0' && c <= '9')) + *p++ = static_cast<char>(c); + else + break; } - return fNum; + *p = '\0'; + + return strtod_nolocale(buf, nullptr); } namespace { |