From b6feccc9a2154336ff4a83fcc62def322cfcbe84 Mon Sep 17 00:00:00 2001
From: Mike Kaganski
Date: Sun, 21 Sep 2025 03:11:25 +0500
Subject: [PATCH] Replace dtoa with fast_float for faster string-to-float
parsing
fast_float implements C++17 from_chars for floating-point types, which
is still unavailable even in the latest versions of compilers e.g. for
macOS. It is maintained, unlike dtoa; it is said to be adopted as the
from_chars implementation for gcc. It is header-only, which simplifies
many things.
Change-Id: I6b597d4d35a076930e6e35f4f8cff3ca84f48ba1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191248
Tested-by: Jenkins
Reviewed-by: Mike Kaganski
---
Makefile.fetch | 2 +-
RepositoryExternal.mk | 26 +++--
bin/oss-fuzz-setup.sh | 1 -
codemaker/Executable_cppumaker.mk | 6 --
codemaker/Executable_javamaker.mk | 6 --
config_host.mk.in | 2 +
configure.ac | 29 +++++
download.lst | 4 +-
external/Module_external.mk | 2 +-
external/dtoa/C6011.patch.0 | 10 --
external/dtoa/README | 10 --
external/dtoa/StaticLibrary_dtoa.mk | 30 ------
external/dtoa/UnpackedTarball_dtoa.mk | 22 ----
external/dtoa/const.patch | 56 ----------
external/dtoa/coverity.patch | 51 ---------
external/dtoa/include_header.patch | 100 ------------------
external/dtoa/source/dtoa.cxx | 15 ---
external/dtoa/ubsan.patch.0 | 11 --
.../Module_fast_float.mk} | 6 +-
external/fast_float/README | 3 +
.../UnpackedTarball_fast_float.mk} | 9 +-
idl/Executable_svidl.mk | 6 --
jurt/Library_jpipe.mk | 8 --
jurt/source/pipe/staticsalhack.cxx | 5 -
readlicense_oo/license/license.xml | 42 ++++++--
sal/CppunitTest_sal_osl_file_details.mk | 1 -
sal/Library_sal.mk | 2 +-
sal/rtl/math.cxx | 34 +++---
solenv/flatpak-manifest.in | 6 +-
svl/Library_svl.mk | 2 +-
svl/source/numbers/zforfind.cxx | 8 +-
unoidl/Executable_unoidl-check.mk | 6 --
unoidl/Executable_unoidl-write.mk | 6 --
vcl/commonfuzzer.mk | 1 -
34 files changed, 114 insertions(+), 414 deletions(-)
delete mode 100644 external/dtoa/C6011.patch.0
delete mode 100644 external/dtoa/README
delete mode 100644 external/dtoa/StaticLibrary_dtoa.mk
delete mode 100644 external/dtoa/UnpackedTarball_dtoa.mk
delete mode 100644 external/dtoa/const.patch
delete mode 100644 external/dtoa/coverity.patch
delete mode 100644 external/dtoa/include_header.patch
delete mode 100644 external/dtoa/source/dtoa.cxx
delete mode 100644 external/dtoa/ubsan.patch.0
rename external/{dtoa/Makefile => fast_float/Module_fast_float.mk} (74%)
create mode 100644 external/fast_float/README
rename external/{dtoa/Module_dtoa.mk => fast_float/UnpackedTarball_fast_float.mk} (55%)
diff --git a/Makefile.fetch b/Makefile.fetch
index 09e9cd930681..f5c005c89a97 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -112,7 +112,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk $(SRCDIR)/download.lst $(S
$(call fetch_Optional,CDR,CDR_TARBALL) \
$(call fetch_Optional,CLUCENE,CLUCENE_TARBALL) \
$(call fetch_Optional,DRAGONBOX,DRAGONBOX_TARBALL) \
- DTOA_TARBALL \
+ $(call fetch_Optional,FAST_FLOAT,FAST_FLOAT_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 ce5a2ee5f75b..83c4a5cc1406 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -4297,22 +4297,26 @@ endef
endif
-define gb_LinkTarget__use_dtoa
-$(call gb_LinkTarget_use_unpacked,$(1),dtoa)
+ifneq ($(SYSTEM_FAST_FLOAT),)
+
+define gb_LinkTarget__use_fast_float
$(call gb_LinkTarget_set_include,$(1),\
- -I$(gb_UnpackedTarball_workdir)/dtoa/include/\
+ $$(INCLUDE) \
+ $$(FAST_FLOAT_CFLAGS) \
+)
+endef
+
+else
+
+define gb_LinkTarget__use_fast_float
+$(call gb_LinkTarget_use_unpacked,$(1),fast_float)
+$(call gb_LinkTarget_set_include,$(1),\
+ -I$(gb_UnpackedTarball_workdir)/fast_float/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
+endif
ifneq ($(SYSTEM_BOX2D),)
diff --git a/bin/oss-fuzz-setup.sh b/bin/oss-fuzz-setup.sh
index 8dbe7cbde4c3..7e0822063783 100755
--- a/bin/oss-fuzz-setup.sh
+++ b/bin/oss-fuzz-setup.sh
@@ -22,7 +22,6 @@ curl --no-progress-meter -S \
-C - -O https://dev-www.libreoffice.org/src/$REDLAND_TARBALL \
-C - -O https://dev-www.libreoffice.org/src/$BOOST_TARBALL \
-C - -O https://dev-www.libreoffice.org/src/$BOX2D_TARBALL \
- -C - -O https://dev-www.libreoffice.org/src/$DTOA_TARBALL \
-C - -O https://dev-www.libreoffice.org/src/$EXPAT_TARBALL \
-C - -O https://dev-www.libreoffice.org/src/$LIBJPEG_TURBO_TARBALL \
-C - -O https://dev-www.libreoffice.org/src/$LCMS2_TARBALL \
diff --git a/codemaker/Executable_cppumaker.mk b/codemaker/Executable_cppumaker.mk
index 9b8581356738..41ca490718d7 100644
--- a/codemaker/Executable_cppumaker.mk
+++ b/codemaker/Executable_cppumaker.mk
@@ -11,12 +11,6 @@ $(eval $(call gb_Executable_Executable,cppumaker))
$(eval $(call gb_Executable_use_external,cppumaker,boost_headers))
-ifeq ($(DISABLE_DYNLOADING),TRUE)
-$(eval $(call gb_Executable_use_externals,cppumaker,\
- dtoa \
-))
-endif
-
$(eval $(call gb_Executable_use_libraries,cppumaker,\
unoidl \
$(if $(filter TRUE,$(DISABLE_DYNLOADING)),reg) \
diff --git a/codemaker/Executable_javamaker.mk b/codemaker/Executable_javamaker.mk
index 0cb237c4b6fc..febfe9a71c29 100644
--- a/codemaker/Executable_javamaker.mk
+++ b/codemaker/Executable_javamaker.mk
@@ -11,12 +11,6 @@ $(eval $(call gb_Executable_Executable,javamaker))
$(eval $(call gb_Executable_use_external,javamaker,boost_headers))
-ifeq ($(DISABLE_DYNLOADING),TRUE)
-$(eval $(call gb_Executable_use_externals,javamaker,\
- dtoa \
-))
-endif
-
$(eval $(call gb_Executable_use_libraries,javamaker,\
unoidl \
$(if $(filter TRUE,$(DISABLE_DYNLOADING)),reg) \
diff --git a/config_host.mk.in b/config_host.mk.in
index 143576c3aa9a..6ed0726fdf55 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -144,6 +144,7 @@ DOTNET_ROOT=@DOTNET_ROOT@
export DOXYGEN=@DOXYGEN@
export DO_FETCH_TARBALLS=@DO_FETCH_TARBALLS@
export DRAGONBOX_CFLAGS=@DRAGONBOX_CFLAGS@
+export FAST_FLOAT_CFLAGS=@FAST_FLOAT_CFLAGS@
export FROZEN_CFLAGS=@FROZEN_CFLAGS@
export DPKG=@DPKG@
export EBOOK_CFLAGS=$(gb_SPACE)@EBOOK_CFLAGS@
@@ -179,6 +180,7 @@ export ENABLE_DEBUG=@ENABLE_DEBUG@
ENABLE_DOTNET=@ENABLE_DOTNET@
ENABLE_RUST_UNO=@ENABLE_RUST_UNO@
SYSTEM_DRAGONBOX=@SYSTEM_DRAGONBOX@
+SYSTEM_FAST_FLOAT=@SYSTEM_FAST_FLOAT@
SYSTEM_FROZEN=@SYSTEM_FROZEN@
ENABLE_EMBINDTEST_UNO=@ENABLE_EMBINDTEST_UNO@
export ENABLE_EMSCRIPTEN_JSPI=@ENABLE_EMSCRIPTEN_JSPI@
diff --git a/configure.ac b/configure.ac
index d81afa10bef7..3af7dbd1ba1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2724,6 +2724,11 @@ AC_ARG_WITH(system-dragonbox,
[Use dragonbox already on system.]),,
[with_system_dragonbox="$with_system_headers"])
+AC_ARG_WITH(system-fast-float,
+ AS_HELP_STRING([--with-system-fast-float],
+ [Use fast_float already on system.]),,
+ [with_system_fast_float="$with_system_headers"])
+
AC_ARG_WITH(system-frozen,
AS_HELP_STRING([--with-system-frozen],
[Use frozen already on system.]),,
@@ -6324,6 +6329,7 @@ if test "$cross_compiling" = "yes"; then
DYNLOADING
EPOXY
EXPAT
+ FAST_FLOAT
FROZEN
GLM
GRAPHITE
@@ -11303,6 +11309,29 @@ fi
AC_SUBST([SYSTEM_DRAGONBOX])
AC_SUBST([DRAGONBOX_CFLAGS])
+dnl ===================================================================
+dnl Check for system fast_float
+dnl ===================================================================
+AC_MSG_CHECKING([which fast_float to use])
+if test "$with_system_fast_float" = "yes"; then
+ AC_MSG_RESULT([external])
+ SYSTEM_FAST_FLOAT=TRUE
+ AC_LANG_PUSH([C++])
+ save_CPPFLAGS=$CPPFLAGS
+ FAST_FLOAT_CFLAGS=-I/usr/include
+ CPPFLAGS="$CPPFLAGS $FAST_FLOAT_CFLAGS"
+ AC_CHECK_HEADER([fast_float/fast_float.h], [],
+ [AC_MSG_ERROR([fast_float/fast_float.h not found. install fast_float])], [])
+ AC_LANG_POP([C++])
+ CPPFLAGS=$save_CPPFLAGS
+else
+ AC_MSG_RESULT([internal])
+ BUILD_TYPE="$BUILD_TYPE FAST_FLOAT"
+ SYSTEM_FAST_FLOAT=
+fi
+AC_SUBST([SYSTEM_FAST_FLOAT])
+AC_SUBST([FAST_FLOAT_CFLAGS])
+
dnl ===================================================================
dnl Check for system frozen
dnl ===================================================================
diff --git a/download.lst b/download.lst
index 65a6298daa32..f241467cc5c3 100644
--- a/download.lst
+++ b/download.lst
@@ -60,8 +60,8 @@ DRAGONBOX_TARBALL := dragonbox-1.1.3.tar.gz
# three static lines
# so that git cherry-pick
# will not run into conflicts
-DTOA_SHA256SUM := 0082d0684f7db6f62361b76c4b7faba19e0c7ce5cb8e36c4b65fea8281e711b4
-DTOA_TARBALL := dtoa-20180411.tgz
+FAST_FLOAT_SHA256SUM := 4bfabb5979716995090ce68dce83f88f99629bc17ae280eae79311c5340143e1
+FAST_FLOAT_TARBALL := fast_float-8.1.0.tar.gz
# three static lines
# so that git cherry-pick
# will not run into conflicts
diff --git a/external/Module_external.mk b/external/Module_external.mk
index 69e3c63fa5ee..dd681d4359c3 100644
--- a/external/Module_external.mk
+++ b/external/Module_external.mk
@@ -27,7 +27,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\
$(call gb_Helper_optional,CPPUNIT,cppunit) \
$(call gb_Helper_optional,CURL,curl) \
$(call gb_Helper_optional,DRAGONBOX,dragonbox) \
- dtoa \
+ $(call gb_Helper_optional,FAST_FLOAT,fast_float) \
$(call gb_Helper_optional,EBOOK,libebook) \
$(call gb_Helper_optional,EPM,epm) \
$(call gb_Helper_optional,EPOXY,epoxy) \
diff --git a/external/dtoa/C6011.patch.0 b/external/dtoa/C6011.patch.0
deleted file mode 100644
index a5e55e34f179..000000000000
--- a/external/dtoa/C6011.patch.0
+++ /dev/null
@@ -1,10 +0,0 @@
---- src/dtoa.c 2024-05-01 10:10:49.702762020 +0100
-+++ src/dtoa.c 2024-05-01 10:11:45.308831303 +0100
-@@ -1606,6 +1606,7 @@
- else
- rv = (Bigint*)MALLOC(len*sizeof(double));
- #endif
-+ assert(rv && "Don't handle OOM conditions");
- rv->k = k;
- rv->maxwds = x;
- }
diff --git a/external/dtoa/README b/external/dtoa/README
deleted file mode 100644
index 9f46b9865d84..000000000000
--- a/external/dtoa/README
+++ /dev/null
@@ -1,10 +0,0 @@
-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
deleted file mode 100644
index b309da0a0378..000000000000
--- a/external/dtoa/StaticLibrary_dtoa.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# -*- 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))
-
-# A place that duplicates these settings is jurt/Library_jpipe.mk
-$(eval $(call gb_StaticLibrary_add_defs,dtoa,\
- $(if $(filter little,$(ENDIANNESS)),-DIEEE_8087,-DIEEE_MC68k)\
-))
-
-$(eval $(call gb_StaticLibrary_set_warnings_disabled,dtoa))
-
-$(eval $(call gb_StaticLibrary_set_include,dtoa,\
- -I$(gb_UnpackedTarball_workdir)/dtoa/src/\
- $$(INCLUDE)\
-))
-
-$(eval $(call gb_StaticLibrary_add_exception_objects,dtoa,\
- external/dtoa/source/dtoa \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/external/dtoa/UnpackedTarball_dtoa.mk b/external/dtoa/UnpackedTarball_dtoa.mk
deleted file mode 100644
index 538710839915..000000000000
--- a/external/dtoa/UnpackedTarball_dtoa.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-#-*- 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_add_patches,dtoa, \
- external/dtoa/include_header.patch \
- external/dtoa/coverity.patch \
- external/dtoa/ubsan.patch.0 \
- external/dtoa/C6011.patch.0 \
- external/dtoa/const.patch \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/external/dtoa/const.patch b/external/dtoa/const.patch
deleted file mode 100644
index 26de2a829ad6..000000000000
--- a/external/dtoa/const.patch
+++ /dev/null
@@ -1,56 +0,0 @@
---- dtoa/src/dtoa.c.const
-+++ dtoa/src/dtoa.c
-@@ -371,7 +371,7 @@
- #ifdef SET_INEXACT
- #define dtoa_divmax 27
- #else
--int dtoa_divmax = 2; /* Permit experimenting: on some systems, 64-bit integer */
-+const int dtoa_divmax = 2; /* Permit experimenting: on some systems, 64-bit integer */
- /* division is slow enough that we may sometimes want to */
- /* avoid using it. We assume (but do not check) that */
- /* dtoa_divmax <= 27.*/
-@@ -382,7 +382,7 @@
- int e; /* number represented = b * 2^e, with .5 <= b < 1 */
- } BF96;
-
-- static BF96 pten[667] = {
-+ static const BF96 pten[667] = {
- { 0xeef453d6, 0x923bd65a, 0x113faa29, -1136 },
- { 0x9558b466, 0x1b6565f8, 0x4ac7ca59, -1132 },
- { 0xbaaee17f, 0xa23ebf76, 0x5d79bcf0, -1129 },
-@@ -1262,7 +1262,7 @@
- 641, 642, 642, 642, 643, 643, 643, 644, 644, 644,
- 644, 645, 645, 645, 646, 646, 646, 647, 647, 647,
- 647, 648, 648, 648, 649, 649, 649, 650, 650 };
-- static ULLong pfive[27] = {
-+ static const ULLong pfive[27] = {
- 5ll,
- 25ll,
- 125ll,
-@@ -1928,7 +1928,7 @@
- ThInfo *TI;
- #endif
- int i;
-- static int p05[3] = { 5, 25, 125 };
-+ static const int p05[3] = { 5, 25, 125 };
-
- if ((i = k & 3))
- b = multadd(b, p05[i-1], 0 MTa);
-@@ -2500,7 +2500,7 @@
- htinit(hexdig, USC "ABCDEF", 0x10 + 10);
- }
- #else
--static unsigned char hexdig[256] = {
-+static const unsigned char hexdig[256] = {
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-@@ -5013,7 +5013,7 @@
- int inexact, oldinexact;
- #endif
- #ifdef USE_BF96 /*{{*/
-- BF96 *p10;
-+ const BF96 *p10;
- ULLong dbhi, dbits, dblo, den, hb, rb, rblo, res, res0, res3, reslo, sres,
- sulp, tv0, tv1, tv2, tv3, ulp, ulplo, ulpmask, ures, ureslo, zb;
- int eulp, k1, n2, ulpadj, ulpshift;
diff --git a/external/dtoa/coverity.patch b/external/dtoa/coverity.patch
deleted file mode 100644
index 8fb1765315af..000000000000
--- a/external/dtoa/coverity.patch
+++ /dev/null
@@ -1,51 +0,0 @@
---- dtor/src/dtoa.c.coverity
-+++ dtor/src/dtoa.c
-@@ -216,14 +216,14 @@
- typedef unsigned Long ULong;
- #endif
-
--#ifdef DEBUG
- #include
-+
-+#ifdef DEBUG
- #include "stdio.h"
- #define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
- #define Debug(x) x
- int dtoa_stats[7]; /* strtod_{64,96,bigcomp},dtoa_{exact,64,96,bigcomp} */
- #else
--#define assert(x) /*nothing*/
- #define Debug(x) /*nothing*/
- #endif
-
-@@ -2301,6 +2301,7 @@
- if ((y = d1)) {
- if ((k = lo0bits(&y))) {
- x[0] = y | z << (32 - k);
-+ assert(k < 32); /* https://bugs.python.org/issue23999 */
- z >>= k;
- }
- else
-@@ -3029,6 +3030,7 @@
- || ((n = nbits & kmask) !=0
- && hi0bits(x[k-1]) < 32-n)) {
- rshift(b,1);
-+ /* coverity[dead_error_line] - not worth investigating */
- if (++e > Emax)
- goto ovfl;
- }
-@@ -3345,6 +3347,7 @@
- if ((dd = s0[j++] - '0' - dig))
- goto ret;
- if (!b->x[0] && b->wds == 1) {
-+ /* coverity[copy_paste_error : FALSE] */
- if (i < nd)
- dd = 1;
- goto ret;
-@@ -3607,6 +3610,7 @@
- switch(c = *++s) {
- case '-':
- esign = 1;
-+ /* fall through */
- case '+':
- c = *++s;
- }
diff --git a/external/dtoa/include_header.patch b/external/dtoa/include_header.patch
deleted file mode 100644
index 7cf0a8a21471..000000000000
--- a/external/dtoa/include_header.patch
+++ /dev/null
@@ -1,100 +0,0 @@
---- /dev/null
-+++ dtoa/include/dtoa.h
-@@ -0,0 +1,1 @@
-+extern "C" double strtod_nolocale(const char *s00, char **se);
---- dtoa/src/dtoa.c.orig
-+++ dtoa/src/dtoa.c
-@@ -268,7 +268,7 @@ #ifndef PRIVATE_MEM
- #define PRIVATE_MEM 2304
- #endif
- #define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
--static double private_mem[PRIVATE_mem], *pmem_next = private_mem;
-+static thread_local double private_mem[PRIVATE_mem], *pmem_next = private_mem;
- #endif
-
- #undef IEEE_Arith
-@@ -1502,9 +1502,7 @@ 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,
-- int *decpt, int *sign, char **rve);
-+extern "C" double strtod_nolocale(const char *s00, char **se);
- #endif
-
- struct
-@@ -1521,7 +1519,7 @@ ThInfo {
- Bigint *P5s;
- } ThInfo;
-
-- static ThInfo TI0;
-+ static thread_local ThInfo TI0;
-
- #ifdef MULTIPLE_THREADS
- static ThInfo *TI1;
-@@ -1529,7 +1527,7 @@ #ifdef MULTIPLE_THREADS
- static ThInfo *TI1;
- static int TI0_used;
-
-- void
-+ static void
- set_max_dtoa_threads(unsigned int n)
- {
- size_t L;
-@@ -2717,7 +2715,7 @@ enum { /* rounding values: same as FLT_ROUNDS */
- Round_down = 3
- };
-
-- void
-+ static void
- gethex( const char **sp, U *rvp, int rounding, int sign MTd)
- {
- Bigint *b;
-@@ -3429,7 +3427,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;
-@@ -4851,7 +4849,7 @@ strtod_nolocale(const char *s00, char **se)
- }
-
- #ifndef MULTIPLE_THREADS
-- static char *dtoa_result;
-+ static thread_local char *dtoa_result;
- #endif
-
- static char *
-@@ -4902,7 +4900,7 @@ nrv_alloc(const char *s, char *s0, size_t s0len, char **rve, int n MTd)
- * when MULTIPLE_THREADS is not defined.
- */
-
-- void
-+ static void
- freedtoa(char *s)
- {
- #ifdef MULTIPLE_THREADS
-@@ -4951,7 +4949,7 @@ freedtoa(char *s)
- * calculation.
- */
-
-- char *
-+ static char *
- dtoa_r(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve, char *buf, size_t blen)
- {
- /* Arguments ndigits, decpt, sign are similar to those
-@@ -6184,8 +6182,8 @@ dtoa_r(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve, char
- return buf;
- }
-
-- char *
--dtoa(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve)
-+ static char *
-+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/external/dtoa/source/dtoa.cxx b/external/dtoa/source/dtoa.cxx
deleted file mode 100644
index d3c8b8211bc8..000000000000
--- a/external/dtoa/source/dtoa.cxx
+++ /dev/null
@@ -1,15 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
-/*
- * 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/.
- */
-
-#include
-
-// build this as C++ code, to allow e.g. thread_local keyword in MSVC
-#include
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/external/dtoa/ubsan.patch.0 b/external/dtoa/ubsan.patch.0
deleted file mode 100644
index de39d41aca68..000000000000
--- a/external/dtoa/ubsan.patch.0
+++ /dev/null
@@ -1,11 +0,0 @@
---- src/dtoa.c
-+++ src/dtoa.c
-@@ -3618,7 +3618,7 @@
- while(c == '0')
- c = *++s;
- if (c > '0' && c <= '9') {
-- L = c - '0';
-+ ULong L = c - '0';
- s1 = s;
- while((c = *++s) >= '0' && c <= '9')
- L = 10*L + c - '0';
diff --git a/external/dtoa/Makefile b/external/fast_float/Module_fast_float.mk
similarity index 74%
rename from external/dtoa/Makefile
rename to external/fast_float/Module_fast_float.mk
index 6427d44e3790..5a67f51e7ef7 100644
--- a/external/dtoa/Makefile
+++ b/external/fast_float/Module_fast_float.mk
@@ -7,8 +7,10 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+$(eval $(call gb_Module_Module,fast_float))
-include $(module_directory)/../../solenv/gbuild/partial_build.mk
+$(eval $(call gb_Module_add_targets,fast_float,\
+ UnpackedTarball_fast_float \
+))
# vim: set noet sw=4 ts=4:
diff --git a/external/fast_float/README b/external/fast_float/README
new file mode 100644
index 000000000000..aa321c165023
--- /dev/null
+++ b/external/fast_float/README
@@ -0,0 +1,3 @@
+fast_float is available from [ https://github.com/fastfloat/fast_float ].
+
+Provides fast header-only implementations for the C++ from_chars functions for float and double types.
diff --git a/external/dtoa/Module_dtoa.mk b/external/fast_float/UnpackedTarball_fast_float.mk
similarity index 55%
rename from external/dtoa/Module_dtoa.mk
rename to external/fast_float/UnpackedTarball_fast_float.mk
index c652f97e0b58..5c6c9af3209a 100644
--- a/external/dtoa/Module_dtoa.mk
+++ b/external/fast_float/UnpackedTarball_fast_float.mk
@@ -1,4 +1,4 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*-
#
# This file is part of the LibreOffice project.
#
@@ -7,11 +7,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-$(eval $(call gb_Module_Module,dtoa))
+$(eval $(call gb_UnpackedTarball_UnpackedTarball,fast_float))
-$(eval $(call gb_Module_add_targets,dtoa,\
- UnpackedTarball_dtoa \
- StaticLibrary_dtoa \
-))
+$(eval $(call gb_UnpackedTarball_set_tarball,fast_float,$(FAST_FLOAT_TARBALL)))
# vim: set noet sw=4 ts=4:
diff --git a/idl/Executable_svidl.mk b/idl/Executable_svidl.mk
index ffce1cdab285..05baac62ccf0 100644
--- a/idl/Executable_svidl.mk
+++ b/idl/Executable_svidl.mk
@@ -21,12 +21,6 @@ $(eval $(call gb_Executable_Executable,svidl))
$(eval $(call gb_Executable_use_external,svidl,boost_headers))
-ifeq ($(DISABLE_DYNLOADING),TRUE)
-$(eval $(call gb_Executable_use_externals,svidl,\
- dtoa \
-))
-endif
-
$(eval $(call gb_Executable_set_include,svidl,\
$$(INCLUDE) \
-I$(SRCDIR)/idl/inc \
diff --git a/jurt/Library_jpipe.mk b/jurt/Library_jpipe.mk
index 1048c61fda3f..13d716256961 100644
--- a/jurt/Library_jpipe.mk
+++ b/jurt/Library_jpipe.mk
@@ -46,11 +46,6 @@ $(eval $(call gb_Library_add_cobjects,jpipe, \
jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection \
))
-# see external/dtoa/StaticLibrary_dtoa.mk
-$(eval $(call gb_Library_add_defs,jpipe,\
- $(if $(filter little,$(ENDIANNESS)),-DIEEE_8087,-DIEEE_MC68k)\
-))
-
$(eval $(call gb_Library_add_exception_objects,jpipe, \
jurt/source/pipe/staticsalhack \
))
@@ -67,8 +62,6 @@ $(eval $(call gb_Library_set_include,jpipe, \
-I$(SRCDIR)/sal/osl/unx \
-I$(SRCDIR)/sal/rtl \
-I$(SRCDIR)/sal/textenc \
- -I$(gb_UnpackedTarball_workdir)/dtoa \
- -I$(gb_UnpackedTarball_workdir)/dtoa/include \
))
$(eval $(call gb_Library_use_externals,jpipe, \
@@ -82,7 +75,6 @@ $(eval $(call gb_Library_use_system_darwin_frameworks,jpipe, \
))
endif
-$(call gb_Library_get_linktarget_target,jpipe): $(call gb_UnpackedTarball_get_target,dtoa)
$(call gb_Library_get_linktarget_target,jpipe): gb_CC := $(filter-out -fsanitize%,$(gb_CC))
$(call gb_Library_get_linktarget_target,jpipe): gb_CXX := $(filter-out -fsanitize%,$(gb_CXX))
diff --git a/jurt/source/pipe/staticsalhack.cxx b/jurt/source/pipe/staticsalhack.cxx
index 9e021b399ecf..9c92fb7f4a47 100644
--- a/jurt/source/pipe/staticsalhack.cxx
+++ b/jurt/source/pipe/staticsalhack.cxx
@@ -97,9 +97,4 @@ void sal_detail_log(sal_detail_LogLevel, char const*, char const*, char const*,
unsigned char sal_detail_log_report(sal_detail_LogLevel, char const*) { std::abort(); }
-#pragma clang diagnostic ignored "-Weverything"
-extern "C" {
-#include // workdir/UnpackedTarball/dtoa/src/dtoa.c
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/readlicense_oo/license/license.xml b/readlicense_oo/license/license.xml
index 5707744d7cad..ba1dfc848530 100644
--- a/readlicense_oo/license/license.xml
+++ b/readlicense_oo/license/license.xml
@@ -224,16 +224,6 @@
the terms of the license below:
Jump to Common Public License Version 1.0 (CPL)
- dtoa.c
- The following software may be included in this product: dtoa.c, which provides a function to convert a decimal
- string to double. Use of any of this software is governed by the terms of the license below:
- Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
- 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.
- 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.
Dragonbox
The following software may be included in this product: Dragonbox.
@@ -257,6 +247,38 @@
Software.
+
+
fast_float
+
The following software may be included in this product: fast_float.
+
fast_float code is covered by the MIT license:
+
+ Copyright (c) 2021 The fast_float authors
+
+ Permission is hereby granted, free of charge, to any
+ person obtaining a copy of this software and associated
+ documentation files (the "Software"), to deal in the
+ Software without restriction, including without
+ limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of
+ the Software, and to permit persons to whom the Software
+ is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+
Epoxy
The following software may be included in this product: epoxy.
diff --git a/sal/CppunitTest_sal_osl_file_details.mk b/sal/CppunitTest_sal_osl_file_details.mk
index 64b1392a9b34..dbd493109529 100644
--- a/sal/CppunitTest_sal_osl_file_details.mk
+++ b/sal/CppunitTest_sal_osl_file_details.mk
@@ -34,7 +34,6 @@ $(eval $(call gb_CppunitTest_set_include,sal_osl_file_details, \
))
$(eval $(call gb_CppunitTest_use_externals,sal_osl_file_details, \
- dtoa \
zlib \
))
diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk
index b22ea22f1414..dae08b235a41 100644
--- a/sal/Library_sal.mk
+++ b/sal/Library_sal.mk
@@ -44,7 +44,7 @@ $(eval $(call gb_Library_use_libraries,sal,\
$(eval $(call gb_Library_use_externals,sal,\
dragonbox \
- dtoa \
+ fast_float \
valgrind \
zlib \
))
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 767e38883d60..860b5a4a727c 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -35,7 +35,7 @@
#include "strtmpl.hxx"
-#include
+#include
constexpr int minExp = -323, maxExp = 308;
constexpr double n10s[] = {
@@ -358,34 +358,24 @@ double stringToDouble(CharT const* pBegin, CharT const* pEnd, CharT cDecSeparato
if (!bDone)
{
buf.insert('\0', p);
- char* pCharParseEnd;
- errno = 0;
- fVal = strtod_nolocale(buf.string, &pCharParseEnd);
- if (errno == ERANGE)
+ const auto fmt(fast_float::chars_format::general | fast_float::chars_format::no_infnan);
+ auto result = fast_float::from_chars(buf.string, buf.string + buf.pos, fVal, fmt);
+ if (result.ec == std::errc::result_out_of_range)
{
- // This happens with overflow and underflow (including subnormals!)
- if (std::isinf(fVal))
+ // Check for the dreaded rounded to 15 digits max value
+ // 1.79769313486232e+308 for 1.7976931348623157e+308 we wrote
+ // everywhere, accept with or without plus sign in exponent.
+ std::string_view num_view(buf.string, result.ptr);
+ if (num_view == "1.79769313486232E308")
{
- // Check for the dreaded rounded to 15 digits max value
- // 1.79769313486232e+308 for 1.7976931348623157e+308 we wrote
- // everywhere, accept with or without plus sign in exponent.
- std::string_view num_view(buf.string, pCharParseEnd);
- if (num_view == "1.79769313486232E308")
- {
- fVal = DBL_MAX;
- }
- else
- {
- eStatus = rtl_math_ConversionStatus_OutOfRange;
- }
+ fVal = DBL_MAX;
}
- else if (fVal == 0)
+ else
{
eStatus = rtl_math_ConversionStatus_OutOfRange;
}
- // else it's subnormal: allow it
}
- p = buf.map[pCharParseEnd - buf.string];
+ p = buf.map[result.ptr - buf.string];
}
}
diff --git a/solenv/flatpak-manifest.in b/solenv/flatpak-manifest.in
index 579b5c737950..1a50bc9781bf 100644
--- a/solenv/flatpak-manifest.in
+++ b/solenv/flatpak-manifest.in
@@ -789,11 +789,11 @@
"dest-filename": "@DRAGONBOX_TARBALL@"
},
{
- "url": "https://dev-www.libreoffice.org/src/@DTOA_TARBALL@",
- "sha256": "@DTOA_SHA256SUM@",
+ "url": "https://dev-www.libreoffice.org/src/@FAST_FLOAT_TARBALL@",
+ "sha256": "@FAST_FLOAT_SHA256SUM@",
"type": "file",
"dest": "external/tarballs",
- "dest-filename": "@DTOA_TARBALL@"
+ "dest-filename": "@FAST_FLOAT_TARBALL@"
},
{
"url": "https://dev-www.libreoffice.org/src/@BOX2D_TARBALL@",
diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk
index afb64aca110d..fd48601e5182 100644
--- a/svl/Library_svl.mk
+++ b/svl/Library_svl.mk
@@ -23,7 +23,7 @@ $(eval $(call gb_Library_use_externals,svl,\
boost_headers \
$(if $(filter LINUX MACOSX ANDROID iOS %BSD SOLARIS HAIKU,$(OS)), \
curl) \
- dtoa \
+ fast_float \
icu_headers \
icui18n \
icuuc \
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index be587e23c6aa..4eee2ad9b14f 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -18,7 +18,7 @@
*/
#include
-#include
+#include
#include
#include
#include
@@ -174,9 +174,11 @@ double ImpSvNumberInputScan::StringToDouble( std::u16string_view aStr, bool bFor
else
break;
}
- *p = '\0';
- return strtod_nolocale(buf, nullptr);
+ double result = 0;
+ (void)fast_float::from_chars(
+ buf, p, result, fast_float::chars_format::general | fast_float::chars_format::no_infnan);
+ return result;
}
namespace {
diff --git a/unoidl/Executable_unoidl-check.mk b/unoidl/Executable_unoidl-check.mk
index cdf9f5aa28ff..36dfc44de635 100644
--- a/unoidl/Executable_unoidl-check.mk
+++ b/unoidl/Executable_unoidl-check.mk
@@ -21,10 +21,4 @@ $(eval $(call gb_Executable_use_libraries,unoidl-check, \
sal \
))
-ifeq ($(DISABLE_DYNLOADING),TRUE)
-$(eval $(call gb_Executable_use_externals,unoidl-check,\
- dtoa \
-))
-endif
-
# vim: set noet sw=4 ts=4:
diff --git a/unoidl/Executable_unoidl-write.mk b/unoidl/Executable_unoidl-write.mk
index e7ec3ba23c21..9accb31ac14d 100644
--- a/unoidl/Executable_unoidl-write.mk
+++ b/unoidl/Executable_unoidl-write.mk
@@ -21,10 +21,4 @@ $(eval $(call gb_Executable_use_libraries,unoidl-write, \
sal \
))
-ifeq ($(DISABLE_DYNLOADING),TRUE)
-$(eval $(call gb_Executable_use_externals,unoidl-write,\
- dtoa \
-))
-endif
-
# vim: set noet sw=4 ts=4:
diff --git a/vcl/commonfuzzer.mk b/vcl/commonfuzzer.mk
index a1df43ab435d..0892fbb5891a 100644
--- a/vcl/commonfuzzer.mk
+++ b/vcl/commonfuzzer.mk
@@ -16,7 +16,6 @@ fuzzer_externals = \
boost_filesystem \
boost_iostreams \
curl \
- dtoa \
harfbuzz \
graphite \
cairo \