summaryrefslogtreecommitdiff
path: root/sal/rtl
AgeCommit message (Collapse)Author
2024-05-15Resolves: tdf#160985 Max integer representation for rtl_math_StringFormat_GEike Rathke
Same as for rtl_math_StringFormat_Automatic we want to preserve the highest accuracy of integer values also with rtl_math_StringFormat_G if nDecPlaces is large enough, instead of possibly rounding into 15 digits. This occurred with FastSaxSerializer::write(double) but rtl::OString::number(double) and rtl::OUString::number(double) and rtl_math_doubleToString() and rtl::str::valueOfFP() and rtl_str_valueOfDouble() and all places calling with rtl_math_StringFormat_G are similar affected. Question might remain why those places use rtl_math_StringFormat_G with fixed nDecimalPlaces calculated from RTL_STR_MAX_VALUEOFDOUBLE - SAL_N_ELEMENTS("-x.E-xxx") + 1 instead of rtl_math_StringFormat_Automatic with rtl_math_DecimalPlaces_Max. Change-Id: Ib388b119faed441c9020dca803649a4089da5b07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167647 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
2024-05-08drop requirement for rtl_random_getBytes to have "Pool" argCaolán McNamara
Seeing as since: commit e9531b792ddf0cfc2db11713b574c5fc7ae09e2c Date: Tue Feb 6 14:39:47 2024 +0100 sal: rtlRandomPool: require OS random device, abort if not present Both rtl_random_createPool() and rtl_random_getBytes() first try to get random data from the OS, via /dev/urandom or rand_s() (documented to call RtlGenRandom(), see [1]). we don't use the initial arg to rtl_random_getBytes anymore, drop the requirement to have one. Then simplify our usages of that, and addtionally deprecate rtl_random_createPool and rtl_random_destroyPool. Change-Id: I13dcc067714a8a741a4e8f2bfcf2006373f832c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167067 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-04-30WaE: C6011 Dereferencing NULL pointer warnings from unchecked mallocCaolán McNamara
upgrade OSL_ASSERT to assert and add a few more Change-Id: Ib52ca573d9e0878fef94dec40410f71bc94dea04 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166914 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-04-26loplugin:ostr in salNoel Grandin
Change-Id: I7732a77fc5ac8d1f5c53052e0f4b6c7e7d70f054 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166739 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
2024-03-05Missing include (for free)Stephan Bergmann
Change-Id: I2dbf6d8894368d93bbed8c2bdf09f978196c6aa5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164427 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-02-29Simplify a bitMike Kaganski
Change-Id: I90e26030cb7a002bfd76cbc7aa73a5d3ea7a7f1b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164132 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-29Use <bit> instead of platform-specific intrinsicsMike Kaganski
Change-Id: I79636ff9c3b2fe601b0b3c94a111b36af0011775 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164131 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-29Drop redundant code: this is handled belowMike Kaganski
And use standard functions in the rtl_math_RoundingMode_HalfEven handler. Change-Id: If9f29aa63423db9457a02ed003cfc27cf3df5585 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164104 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-27tdf#158190 Fix Calc ROUND in floating-point calculate result very close to X.5Po-Yen Huang
Location: if (nDecPlaces == 0) { switch (eMode) { case rtl_math_RoundingMode_Corrected: return std::round(fValue); Because the functions are the same as the following related codes, they are respectively: if (nDecPlaces >= 0 && (fValue >= 0x1p52 || isRepresentableInteger(fValue))) return fOrigValue; as well as: if (fValue < 0x1p52) { switch(eMode) { case rtl_math_RoundingMode_Corrected: fValue = rtl::math::approxFloor(fValue + 0.5); break; : : : Because some double-precision floating point numbers cause std::round(fValue) and rtl::math::approxFloor(fValue + 0.5) to produce different results. For example, enter 10614.4999999999876 in Calc's A1 cell (or any operation that will produce a long decimal number such as .499999999999xyz after the decimal point). We expected it to be 10614.4999999999876, but it was automatically rounded to 10614.5 (note: this result is also the result of ubiquitous handheld computers, OpenOffice.org and Excel) Then, entering =ROUND(A1,0) in B1, we will see 10614, A1 and B1 clearly don't meet expectations. (My boss or tax collector might be unhappy :-p) Although A1's 10614.4999999999876 is still faithfully recorded, the rendering of 10614.5 is confusing. Now, there are two views: 1. According to the established convention, B2 displays the expected answer 10615. or 2. True to the laws of mathematics, A1 displays 10614.4999999999876 or at least 10614.49 Although the second point of view is correct (and I completely agree with it), when opening spreadsheets generated by other software (such as OpenOffice.org or Excel), the results will be different, which people do not like to see. So when nDecPlaces == 0 is removed, use std::round(fValue) and let the existing code below it do the rounding: if (fValue < 0x1p52) { switch(eMode) { case rtl_math_RoundingMode_Corrected: fValue = rtl::math::approxFloor(fValue + 0.5); This is consistent with the first point. By the way, in nDecPlaces == 0 case rtl_math_RoundingMode_HalfEven: This piece of code can be checked to see if it is really necessary, because rtl_math_round() also has the same purpose code. If it is not needed, the entire nDecPlaces == 0 can be removed. Co-authored-by: Firefly <firefly@ossii.com.tw> Co-authored-by: Franklin Weng <franklin@goodhorse.idv.tw> Change-Id: If32cdb18c70ec0025c83ba25a99e5d135d66aec9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159193 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-13Fix mis-merge from 8b53fa726e0d496f18228b0ca9ce2f61196f6a57Stephan Bergmann
"Introduce a fundamental.override.ini for bootstrap variables" Change-Id: I88f11e422d98100bafd6fd9a7ab5e892dcc3fb46 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163292 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-02-12Log uses of fundamental.override.iniStephan Bergmann
Change-Id: I36fa44b063a439edf5411a89f76ec342b1388351 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162601 Tested-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> (cherry picked from commit 6d553405101090ef7a7ff5270e5ef32aa41bd9b3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163254 Tested-by: Jenkins
2024-02-12Introduce a fundamental.override.ini for bootstrap variablesStephan Bergmann
...that is looked for next to the application and, when present, overrides all the other ways of setting bootstrap variables. LibreOffice itself does not bring along such a fundamental.override.ini, but it can be convenient for an administrator to place one in the installation (which can then not be modified or overridden by end users). (For convenience, the naming of this ini-file starts to deviate from the old and rather pointless tradition of naming our ini-files *rc vs. *.ini on different platforms.) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162187 Tested-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> (cherry picked from commit f4d376e9a10a8c66f7f6ecfe6a1f4763c1927b52) Conflicts: sal/rtl/bootstrap.cxx Change-Id: I057cc67b1af1d806587c3a4dc0bc31c28e79d22b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163251 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-02-07sal: rtlRandomPool: require OS random device, abort if not presentMichael Stahl
Both rtl_random_createPool() and rtl_random_getBytes() first try to get random data from the OS, via /dev/urandom or rand_s() (documented to call RtlGenRandom(), see [1]). In case this does not succeed, there is a fallback to a custom implementation of a PRNG of unknown design that has never been substantially changed since initial CVS import, and is presumably not what would be considered state of the art today, particularly if there's no actual entropy available to seed it. Except for a few miscellaneous usages in URE (presumably to avoid dependencies on non-URE libs), rtlRandomPool is almost always used to generate material for encryption of documents, which is demanding and probably beyond what a pure user-space PRNG implementation without entropy from the OS can provide. So remove the custom PRNG and instead abort() if reading from the OS random device fails for whatever reason. rtl_random_addBytes() becomes a no-op and is therefore deprecated. Presumably the only kind of environment where random device would be unavailable in practice is running in some sort of chroot or container that is missing the device or has incorrect permissions on it; better to fail hard than to produce encrypted documents of questionable security. [1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/rand-s?view=msvc-170 Change-Id: I3f020c2d11570f8351381d70188ce59bfec9f720 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163056 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2024-02-05sal: Re-add missing includesHeiko Becker
They were removed as unused in [1], but it turn out that's not entirely accurate, at least if LIBO_CIPHER_OPENSSL_BACKEND is defined. assert(), o3tl::..., std::numeric_limits<T> and std::memcpy are all used inside that block. [1] 2e71c439057c8d31b6af191ef38607600cb996f0 Change-Id: I2805dc4edf1d05bec5ec203772af73dd93da12bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162967 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-12-24Silence new GCC 14 trunk -Werror=alloc-sizeStephan Bergmann
> sal/rtl/byteseq.cxx: In function ‘void rtl_byte_sequence_reference2One(sal_Sequence**)’: > sal/rtl/byteseq.cxx:63:20: error: allocation of insufficient size ‘8’ for type ‘sal_Sequence’ {aka ‘_sal_Sequence’} with size ‘12’ [-Werror=alloc-size] > 63 | pNew = static_cast<sal_Sequence *>(malloc( SAL_SEQUENCE_HEADER_SIZE )); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: I9d4081ed2938fffdf282c852250a3eed5f0d9e25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161269 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2023-12-24-Werror=calloc-transposed-argsStephan Bergmann
Change-Id: I7b8b020bdbcd5b4db4cb478cc5fe1225f19ae0cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161268 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2023-12-11Step 3 of removing cargo-cult pragma pack around rtl_[u]StringStephan Bergmann
see 8ae3ae4bf75fdd0aaa132c956d9da029baa3adc6 "Step 1 of removing cargo-cult pragma pack around rtl_[u]String" Change-Id: If6c2ea0ab2e7e61cdbc880d7b27d2af7f816e66d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158568 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2023-11-03Make ExternalReferenceUriTranslator more robust against broken UTF-8Stephan Bergmann
<https://lists.freedesktop.org/archives/libreoffice/2023-November/091151.html> "CppunitTest_stoc_uriproc failed on Windows" reports that translateToExternal("file:///abc/%feef") produces an empty string (indicating failure) instead of "file:///abc/%FEef" (as expected in stoc/test/uriproc/test_uriproc.cxx) when osl_getThreadTextEncoding() is Shift JIS. This was due to how the call to rtl::Uri::encode in Translator::translateToExternal (in stoc/source/uriproc/ExternalUriReferenceTranslator.cxx) behaved: It internally interpreted its input "%FE" as the single-byte Shift JIS character 0xFE. Which gets mapped to U+2122 as an extension (see "APPLE additions over SJIS, we convert this like Apple, because I think, this gives better result, then [sic] we take a replacement char" in sal/textenc/tcvtjp6.tab) in readUcs4, but which in turn doesn't get mapped back to any Shift JIS character in writeEscapeChar. Translator::translateToExternal is the only user of rtl_UriEncodeStrictKeepEscapes, as introduced by 6ff5d3341dbc5df3f0cb5368ccb0e1089338916c "INTEGRATION: CWS c07v013_SRC680 (1.4.40); FILE MERGED: 2007/06/21 13:00:56 sb 1.4.40.1: #b6550116# Made XExternalUriReferenceTranslator.translateToExternal more robust when the input URL contains spurious non--UTF-8 octets like %FE (which are now copied verbatim, instead of signalling error)." To make the claim true that such "spurious non--UTF-8 octets like %FE" are always "copied verbatim", regardless of text encoding being used, repurpose rtl_UriEncodeStrictKeepEscapes to always treat any escape sequences that are present as (potentially broken) UTF-8. Change-Id: I0fa0b14d3e3d44e4b5514e1b73c84c407a947ce9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158888 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-24Use requires-clausesStephan Bergmann
Change-Id: I27c990f27023aba5e77c6b406d7dbdcc898054ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158405 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-21clang-format sal/rtl/math.cxxMike Kaganski
Change-Id: I0e807118e6a2196d2f2858ed195782a90572a2e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158303 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-09-24Drop some newly obsolete __clang_major__ version checksStephan Bergmann
...after 6ef2d358ac053ce0f6de9cf0f8f25e8bae66d441 "Adapt Clang and GCC minimum version checks" Change-Id: Ib25fbb76211d1bda1d230de771f207960e645421 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157204 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-09-19tdf#146619 Remove unused includes from sal/ [cpp files]Gabor Kelemen
Change-Id: I11a54c1ddf73c16ce46a0d1c375bf43157870db7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155856 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-08-14tdf#146619 Remove unused includes from sal/ [headers]Gabor Kelemen
Change-Id: I8fae71e5053950441a2e0920590264c2cb858924 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155546 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-07-21tdf#139306 Incorrect nDecPlaces value after clampingVladislav Tarakanov
nDecPlaces clamping diap changed from +-20 to +-309 and buffer is resized for new value Change-Id: Icb2130891598cf02623bbf5bd0273edab529d124 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153815 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
2023-07-12Simplify a bitMike Kaganski
Change-Id: Idd3e96d99f13b1e87e2a01de9c9392ead0864de7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154323 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-05-07Revert a thinko from commit 876010cbc4584249e919c694b8b977fd4e83084eMike Kaganski
Indeed, the cDecSeparator and cGroupSeparator require that the buffer uses the proper character type, otherwise it won't be possible to use Unicode separators in rtl_math_doubleToUString. Change-Id: Id26bed72776475c1be5b092e3ffcff0e75ffe557 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151451 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-05-06update loplugin:stringview* for o3tl::iterateCodePointsNoel Grandin
And change o3tl::iterateCodePoints to use sal_Int32 for its second param, to integrate better with places where the parameter comes from an UNO API, which cannot use std::size_t Change-Id: I7b9dd2c9bc7f48e6c4a912f039f1b5dae7beae69 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151421 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-05-06Simplify rtl_(u)string_newReplace implementationMike Kaganski
and unify with *ToAscii(Lower/Upper)Case Change-Id: I06999b4f5f34abc8da2860b7f9e279608edb40dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151381 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-05-06Simplify a bitMike Kaganski
No need to use different temporary objects here Change-Id: I1b47cae8b80adea5426c780003bddf68310a0060 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151380 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-05-04Provide std::u16string_view based o3tl::iterateCodePointsStephan Bergmann
...as requested in the comments of <https://gerrit.libreoffice.org/c/core/+/151303> "a11y: Fix returning unpaired surrogates when retrieving characters" (incl. the additional preAdjustIndex parameter). The type of the indexUtf16 parameter obviously needed to be adapted to std::u16string_view's std::size_t. But there is no obvious best choice for the type of the incrementCodePoints parameter (int? std::ssize_t?), so lets leave it as sal_Int32. For simplicity of avoiding a Library_o3tl, and to allow o3tl::iterateCodePoints to be used in the implementation of rtl_uString_iterateCodePoints now, o3tl::iterateCodePoints is provided as an inline function defined in the include file. Change-Id: I8280ca11d2a943bd2b7150a266807b358f321a72 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151366 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-04-29Simplify strtmpl.hxxMike Kaganski
Replace bulky and difficult-to-read template argument names with clearer ones; remove excessive whitespaces; reorder to avoid forward declarations (these are remnants from the refactor from macros to templates, when I tried to keep the old structure as close to the original as possible). And also a small code simplification in doubleToString. Change-Id: I901cfb86daf410e85269538f36ebb6b553a4be76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151125 Tested-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-04-12Use o3tl::trim in strtmpl.hxxMike Kaganski
Change-Id: I4de8658c36c21fe07fa45f697cf3145c567a95c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150210 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-04-02Simplify a bitMike Kaganski
Change-Id: Iae784d3ae40cd237c768413c067a2067c608238d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149885 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-03-25loplugin:stringadd in registry..salNoel Grandin
after my patch to merge the bufferadd loplugin into stringadd Change-Id: I1658b960d44780f7d9c447246b1178cb70be5e66 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149581 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-03-20rtl_allocateString takes a size_t parameterStephan Bergmann
Change-Id: Ibfdc0e7e3af243f157d5d14e3fbe5ab204c0b8df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149140 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-03-20Shrink rtl_[u]String allocation size to what's actually neededStephan Bergmann
Change-Id: Ib39caf31b5d2fb06cc81cdeb14578794b35d8ed4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149120 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-02-01Finally drop undocumented rtl_[u]String_newFromStr null argument supportStephan Bergmann
...executing on the TODO left by 4f0c70fb5554325e0cc2129741175bf07de22029 "Avoid calling OString ctor with null pointer" in late 2020. Change-Id: I3db6e2df61ca290948affc5e02ae74757441471d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146428 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-12-28Introduce lo_get_app_data_dir() for Emscripten, tooTor Lillqvist
And not just Android. Hardcoded to return "/instdir" to match what is in the emscripten_fs_image. Change-Id: I26d4ec5e02ec9900e35ca47f1565a13ad2b723b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144849 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
2022-12-13Fix the "Found char > 127" warning to check the correct charactersMike Kaganski
Change-Id: Ia4a713c8a5ddda11e9802cbc317dde9ff48b8fd3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144026 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-12-04rtl bootsratp : use enum classArnaud VERSINI
Change-Id: Iea433a2a7be9b62f04b57883dbefaf25586f21d6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143616 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-27rtl uuid : remove useless endian conversionArnaud VERSINI
Change-Id: I65a4dad0aceb83f2449c86c438cb478937c8b90a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138229 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-08-16rtl : use a local std::mutex instead of the global mutexArnaud VERSINI
Change-Id: I95a35fe451e459276dcb8c9b90d515d0a34fe36c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138318 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-05Fix typoStephan Bergmann
...introduced in f59136a2ed1e3eb01cc5b62c5a7da07c34cbdfae "tdf#91794 remove OSL_DEBUG_LEVEL > 1 conditionals" Change-Id: I4ead69b3fac4ab51602c3cbd25c8481e749a3e75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137835 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-06-24Let rtl_[u]stringbuffer_insert throw std::bad_alloc on overflowStephan Bergmann
Prior to a95c585433246813096e8890b7ed6ef4fe30c621 "Pump XInputStream into an SvMemoryStream rather than an OStringBuffer", this change would have caused > $ truncate -s 3G test.xml > $ instdir/program/soffice test.xml to open an effectively empty draw document (after apparently catching the std::bad_alloc now thrown from within OrcusFormatDetect::detect; see that commit's commit message for details) rather than crashing. This works because rtl_[u]stringbuffer_insert happen not to be decorated with SAL_THROW_EXTERN_C(). But even if they were (or when they are called from an external C program), it wouldn't be worse to let the process terminate due to the unexpected C++ std::bad_alloc exception than to let it crash due to an overflown signed integer computation and out-of-bounds memory write. Change-Id: I21e353367e2b978e8893a2886ac875367a75abd9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136352 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-17clang-tidy modernize-pass-by-value in salNoel Grandin
Change-Id: If05c5cf0e333d0dbba31475af69c517486bf8923 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134472 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-13Use calloc instead of malloc and memsetdante
Change-Id: I591ee7f5360a30779f831f6492cdbe71ab94099e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134165 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-11Revert "Disable -fsanitize=float-divide-by-zero in rtl_math_atanh"Stephan Bergmann
This reverts commit 6a4504bba84dcbaeb71869ec5c9ed6dfdc090619, which is no longer necessary after 6f75ec6115f0152517be634070607bc61bf96dd0 "tdf#148430 Use atanh from <cmath> instead of our own" changed the implementation of rtl_math_atanh. Change-Id: I11094f8c9fb0bb7b635541e7360e460816d3c171 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134161 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-11tdf#148430 Use atanh from <cmath> instead of our ownofftkp
Change wrapper in rtl::math::atanh to use atanh from <cmath>. Also changed all occurrences of rtl::math::atanh on files that use this function to directly use the standard atanh instead. Change-Id: Idc5c456f67291f5816756f023b61afde844b5ceb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133965 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
2022-05-03add o3tl::matchIgnoreAsciiCaseNoel Grandin
Change-Id: Iad8e1ed256d84808404bf20ed7a16b05b3db5818 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133753 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-04-15Introduce rtl::createUriCharClassStephan Bergmann
...to make those char class array initializations more readable. (Making the corresponding variables constexpr is mostly done so that failures in the provided `unencoded` arguments, like non-ASCII characters or duplicate character typos, would lead to compile-time errors also for !HAVE_CPP_CONSTEVAL. And assigning to a sal_Bool std::array needs another hack to avoid false loplugin:implicitboolconversion warnings.) Change-Id: Ieb8827f69f55f1212a9428817d5331fcb18ef1d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133058 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>