summaryrefslogtreecommitdiff
path: root/sal/rtl
AgeCommit message (Collapse)Author
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>
2022-04-12loplugin:stringview more o3tl conversionNoel Grandin
look for call sequences that can use string_view and the new o3tl functions in o3tl/string_view.hxx Also add a few more wrappers to said #include file Change-Id: I05d8752cc67a7b55b0b57e8eed803bd06bfcd9ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132840 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-04-10Move impl functions to the only place they are usedMike Kaganski
Change-Id: I6871bfc0ae3d2427a4cd135cb37aad76dac0d7a4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132706 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-04-10loplugin:stringview check for getToken and trimNoel Grandin
since we now have o3tl versions of those that work on string_view. Also improve those o3tl functions to support both string_view and u16string_view Change-Id: Iacab2996becec62aa78a5597c52d983bb784749a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132755 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-04-01Use some more string_viewStephan Bergmann
Change-Id: I630c573eedfcc9d8678fda0466ddcc1902fac0f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132417 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-03-22tdf#145614 Convert #define to enum or constexprDeep17
Change-Id: I3090ae3421ae55b7c546d82aeb49a56e93c9f02c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131913 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-03-21Removed duplicated includesAndrea Gelmini
Change-Id: I22b71580a79500e169ed9cab775501583975d67f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131911 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2022-03-21Move implementation of doubleToString to sal/rtl/strtmpl.hxxMike Kaganski
... to reduce inter-relations between compilation units, and drop *StringTraits from sal/rtl/math.cxx. Change-Id: I0d7544dead03651dc71ec923cab10580f15cf49a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131895 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-03-21Reorganize the code a bit to drop some detail::* helper functionsMike Kaganski
Change-Id: Iee7402f5de7287678e1691b48b6493d3131ef7ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131883 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-03-18tdf#145614 Convert #define to enum or constexprDeep17
Change-Id: Ie039a828b09aacc68ef2f95f495284d554122940 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131510 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
2022-03-11Remove redundant checkStephan Bergmann
The precondition `nIndex >= 0` is already asserted at the top of the function. Change-Id: I7436ce923b19aa81f08d1fb20680308f609d2242
2022-03-09Drop misguided test added in 82a1d32d3d3ac1b4b0a6d4cfaca791c77d9b3c03Mike Kaganski
The documented precondition is that index must not be greater than the length of string. Just assert that, and fix the found misuse. The added test is for in-place replacement, just in case. Change-Id: I3c545a6f0bf913fe93e2bef83ce733359c193065 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131232 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
2022-03-09Simplify getTokenMike Kaganski
It should not attempt to dereference pointers when nIndex is negative. Properly handle too large nIndex. Also it is not necessary to parse the string when nToken is negative. Related to commit be281db569bafaac379feb604c39e220f51b18c4 Author Rüdiger Timm <rt@openoffice.org> Date Mon Sep 20 07:43:20 2004 +0000 INTEGRATION: CWS ause011 (1.18.22); FILE MERGED 2004/08/18 11:47:54 sb 1.18.22.1: #i33153# Made getToken more robust. Change-Id: I6fc77a5b70308ccca08cb2132bd78d024bd7e3e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131221 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-03-05Add checks to avoid finding empty substring / zero characterMike Kaganski
... which changed in commit 281989007fd7dea997ed9a65f513f80b1aff67dd Author Noel Grandin <noel@peralex.com> Date Tue Jul 01 13:17:01 2014 +0200 Use standard library optimised routines for OUString/OString for optimized cases: strchr/wcschr/strrchr/wcsrchr find trailing zero character, and strstr/wcsstr find empty string; previous/unoptimized code does not find these. This introduced inconsistency between char and sal_Unicode functions on non-Windows, and for sal_Unicode between Windows and non-Windows (because on Windows, optimized code is used for sal_Unicode, while on other platforms, unoptimized code is used). Change-Id: I68529c91b26f4113d9bd7777fc5ac4809349864b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131064 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-03-03Deduplicate some char replacement functionsMike Kaganski
Change-Id: Ie65224066941dbab89abb6fc91e6cbfbc45bf201 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130901 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
2022-03-03Use a more conventional begin() / end() syntaxMike Kaganski
Also would potentially enable use in std range algorithms that take different end sentinel type. Change-Id: Ia75005caa7ce44302fc8612f5717a41d11087622 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130902 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-03-02Unify normal/shortened, null-terminated/with-length comparisonsMike Kaganski
Change-Id: Ie154efd1e0d9b49601200ac896d5d5dd0422d504 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130832 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-03-02Drop useless indirection and unused templateMike Kaganski
Change-Id: Icbcf56c30c9d901a4436f56a1648a7c8e7504848 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130817 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-03-02Unify and deduplicate to[U]Int[_WithLength]Mike Kaganski
Change-Id: I05e71b36030da0a91c24b3926ee1d069912849f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130815 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-03-01No need to memset the allocated buffer in new_WithLengthMike Kaganski
Other places that allocate, specifically newFromStr_WithLength and ensureCapacity, don't initialize the memory. Change-Id: Iad5301313312aac24948afefb27925d52fe3c673 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130762 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-28Use 'assert' where appropriateMike Kaganski
Change-Id: Id7ecf874745fb32406bcd2250a954aaf3a345103 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130667 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-28Deduplicate string buffer codeMike Kaganski
Change-Id: Ia23974ad3a827c84bb1a5d633a953625aea2576a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130663 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-27More replacement functions deduplicationMike Kaganski
Change-Id: I700074cddf1be937f5fdaf90e6cc0b533a3c57ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130633 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-27Unify creation of character string copyMike Kaganski
Change-Id: Ifef89cfd98771f247a308fab58da410a7079ecfc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130632 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-27Deduplicate newToAscii*CaseMike Kaganski
Change-Id: I55f4f43375037ad4247f592bc981d8718c12de68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130631 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-27Simplify newTrimMike Kaganski
Change-Id: I36e2f8b0f0f4829fba32e637fe61cebe9e67cf91 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130630 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-27Deduplicate more comparison functionsMike Kaganski
Change-Id: I93aba36b7cde268e358bd96b55183533ddc70b16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130603 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-26Slightly cleanup newReplaceStrAtMike Kaganski
Change-Id: I230aa635aa797038055bdbc9453a5daa98412f93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130465 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-25Slightly optimize newReplaceAllFromIndexMike Kaganski
Change-Id: Ie73a5e8c44458123ef03096e3e8f6c9e41c48814 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130466 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-25Deduplicate rtl_uString_newReplaceFirst*Mike Kaganski
Change-Id: I6e09fd8e8acc06290423c1c44cc0c175b0c47e0a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130547 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-25Make an -fsanitize=undefined workaround conditionalStephan Bergmann
...that had been introduced with b5cb4935c268f12e63b61e035b455b0a59e67aa2 "Work around undef conversion of large double to float" but should no longer be necessary with <https://github.com/llvm/llvm-project/commit/9e52c43090f8cd980167bbd2719878ae36bcf6b5> "Treat the range of representable values of floating-point types as [-inf, +inf] not as [-max, +max]" added towards Clang 9. Thanks to Mike Kaganski for pointing me at this old code and at Richard Smith's comment at <https://cplusplusmusings.wordpress.com/2013/03/26/testing-libc-with-fsanitizeundefined/>. Change-Id: I8ecf115fcf6b1ebf621cb4567f8d31ac9b10ef1c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130531 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-02-25Don't invent another strlenMike Kaganski
Change-Id: I7f7b7029ac03b1f06f4d9c2612b9b008b033baea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130538 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-25Use some rtl functionsMike Kaganski
Change-Id: I12fe2f5fe447e2bc6567e3d0375f1671e781697e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130515 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-25Deduplicate some comparison functionsMike Kaganski
Change-Id: Iffeb4323c99649d45387981ec583fdcff207ec4e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130512 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-24Deduplicate rtl_*String_newConcat*LMike Kaganski
Change-Id: I9712cd8a2798fe5493dffd557e68239d9db3b7aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130501 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-24Deduplicate rtl_*str_valueOf{Float,Double}Mike Kaganski
Change-Id: Ie3254fbf6178f4e623fd8209b58e9f19d2c46d2c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130480 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-24Fix warning textMike Kaganski
Change-Id: I42d0b3a19809a288630cfba6c01bcd5c4fde7702 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130454 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>