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 <mike.kaganski@collabora.com>
This commit is contained in:
+1
-1
@@ -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) \
|
||||
|
||||
+15
-11
@@ -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),)
|
||||
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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) \
|
||||
|
||||
@@ -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) \
|
||||
|
||||
@@ -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@
|
||||
|
||||
@@ -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 ===================================================================
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
Vendored
+1
-1
@@ -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) \
|
||||
|
||||
Vendored
-10
@@ -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;
|
||||
}
|
||||
Vendored
-10
@@ -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).
|
||||
Vendored
-30
@@ -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:
|
||||
-22
@@ -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:
|
||||
Vendored
-56
@@ -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;
|
||||
Vendored
-51
@@ -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 <assert.h>
|
||||
+
|
||||
+#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;
|
||||
}
|
||||
Vendored
-100
@@ -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.
|
||||
Vendored
-15
@@ -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 <sal/config.h>
|
||||
|
||||
// build this as C++ code, to allow e.g. thread_local keyword in MSVC
|
||||
#include <dtoa.c>
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
Vendored
-11
@@ -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';
|
||||
@@ -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:
|
||||
Vendored
+3
@@ -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.
|
||||
+3
-6
@@ -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:
|
||||
@@ -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 \
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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 <src/dtoa.c> // workdir/UnpackedTarball/dtoa/src/dtoa.c
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -224,16 +224,6 @@
|
||||
the terms of the license below:</p>
|
||||
<p><a href="#a__CPL_version_1_0">Jump to Common Public License Version 1.0 (CPL)</a></p>
|
||||
</div>
|
||||
<h2>dtoa.c</h2>
|
||||
<p>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:</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>
|
||||
<div class="DRAGONBOX">
|
||||
<h2>Dragonbox</h2>
|
||||
<p>The following software may be included in this product: Dragonbox.</p>
|
||||
@@ -257,6 +247,38 @@
|
||||
Software.</p>
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="FAST_FLOAT">
|
||||
<h2>fast_float</h2>
|
||||
<p>The following software may be included in this product: fast_float.</p>
|
||||
<p>fast_float code is covered by the MIT license:</p>
|
||||
<blockquote>
|
||||
<p>Copyright (c) 2021 The fast_float authors</p>
|
||||
|
||||
<p>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:</p>
|
||||
|
||||
<p>The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.</p>
|
||||
|
||||
<p>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.</p>
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="EPOXY">
|
||||
<h2>Epoxy</h2>
|
||||
<p>The following software may be included in this product: epoxy.</p>
|
||||
|
||||
@@ -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 \
|
||||
))
|
||||
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ $(eval $(call gb_Library_use_libraries,sal,\
|
||||
|
||||
$(eval $(call gb_Library_use_externals,sal,\
|
||||
dragonbox \
|
||||
dtoa \
|
||||
fast_float \
|
||||
valgrind \
|
||||
zlib \
|
||||
))
|
||||
|
||||
+12
-22
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "strtmpl.hxx"
|
||||
|
||||
#include <dtoa.h>
|
||||
#include <fast_float/fast_float.h>
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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@",
|
||||
|
||||
+1
-1
@@ -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 \
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <dtoa.h>
|
||||
#include <fast_float/fast_float.h>
|
||||
#include <float.h>
|
||||
#include <comphelper/string.hxx>
|
||||
#include <o3tl/string_view.hxx>
|
||||
@@ -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 {
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -16,7 +16,6 @@ fuzzer_externals = \
|
||||
boost_filesystem \
|
||||
boost_iostreams \
|
||||
curl \
|
||||
dtoa \
|
||||
harfbuzz \
|
||||
graphite \
|
||||
cairo \
|
||||
|
||||
Reference in New Issue
Block a user