summaryrefslogtreecommitdiff
path: root/sal/rtl/string.cxx
AgeCommit message (Collapse)Author
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-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>
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-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-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-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-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-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-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-24Deduplicate valueOf*Int*Mike Kaganski
Change-Id: Ib9da148c371f52ee8da2848581bb8a024f97de96 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130479 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-17Deduplicate some codeMike Kaganski
Change-Id: Ib05624739cce31b08fc409f238d447ed8d99bad9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130016 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-02-16Related: tdf#147421: optimize O(U)String's replaceAll*Mike Kaganski
... and underlying low-level C functions. Change-Id: I78c2dd75e272e6d3cdd2cfae007ca0a0ec1635e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129942 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-11-23O[U]String::replaceAt overloads that take string_viewNoel Grandin
which results in lots of nice string_view improvements picked up by the plugins Change-Id: Ib0ec3887816b3d4436d003b739d9814f83e244b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125657 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-09-17Drop this unneeded indirectionMike Kaganski
Change-Id: I6b40642c7574a1863658854d206ed849517dbd0f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122130 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-07-21Use existing rtl_math_stringToDoubleStephan Bergmann
...like it is also already done in LineParser::readDouble in sdext/source/pdfimport/wrapper/wrapper.cxx (esp. since the code should be changed to use C++17 std::from_chars once that is available in all our baselines), reverting again the introduction of rtl_str_toDouble_WithLength in b1df9c67349cf4cc5be4128d797aefb87f50e38f "[API CHANGE] reduce cost of numeric conversion" Change-Id: If7e3a15649f80093d3407157412fd3deb3a38b12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119318 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins
2021-07-21Use existing rtl_str_toInt64_WithLengthStephan Bergmann
...like it is also already done in LineParser::readInt32 in sdext/source/pdfimport/wrapper/wrapper.cxx (esp. since the code should be changed to use C++17 std::from_chars once that is available in all our baselines), reverting again the introduction of rtl_str_toInt32_WithLength in b1df9c67349cf4cc5be4128d797aefb87f50e38f "[API CHANGE] reduce cost of numeric conversion" Change-Id: I2789f8ec55c8d89150d1c68e6b353a1d2e1d1703 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119301 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins
2021-07-17[API CHANGE] reduce cost of numeric conversionNoel Grandin
on a hot path, since we already know the length of these strings. Which requires adding some new variants of our string conversion functions Change-Id: I1877f8f3c72934c07f14eec7e73bbe8d7b0f1808 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119065 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-05-18Replace rtl_string_getTokenView with o3tl::getTokenStephan Bergmann
...to not needlessly extend the sal ABI. At least for now, o3tl::getToken has a simpler interface than its OString::getToken counterpart (driven mainly by how it is used for now): it does not support a `token` argument, and its `position` argument must not be npos. To meet the latter requirement, the check for "subpath" in LineParser::readPath has been reworked slightly. Change-Id: I4428fe2d9aa03ca83a436fc6493fbc34665a8033 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115742 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-05-18update "add OString::getTokenView"Noel Grandin
update commit 3669d4ec43a6aa2d410d8351d631548db45a5302 Date: Fri May 14 15:51:38 2021 +0200 add OString::getTokenView (tdf#42374 related) with suggested changes from gerrit review Change-Id: I861d960deaa010740a4aa964e402c4c76a85cbc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115706 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-05-15add OString::getTokenView (tdf#42374 related)Noel Grandin
small improvement to PDF import no need to construct temporary string objects when we are just to going to convert them into int/double. So use a view and convert the data through the view. Change-Id: I824fe88bf17142b48fe6032e10c0f3a111927e96 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115616 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-04-23Step 1 of removing cargo-cult pragma pack around rtl_[u]StringStephan Bergmann
Following up on f62cb40bdfaf41cf8e989640f9be79f652f30914 "Remove dubious #pragma pack" and 9eba8aa38db3a0dc2f7dfaf24a003c16418aef18 "Remove dubious #pragma pack" for O[U]StringLiteral, which argued that the pragma pack around rtl_[u]String are useless cargo cult (paraphrasing): "All struct member types involved (oslInterlockedCount aka sal_Int32, sal_Int32 itself, sal_Unicode, and char) have size <= 4 resp. < 8, so the member alignment ("on a boundary that's either a multiple of [the pragma pack value], or a multiple of the size of the member, whichever is smaller", according to <https://docs.microsoft.com/en-us/cpp/preprocessor/pack?view=msvc-160>) is not affected. And neither are alignof(rtl_String) and alignof(rtl_uString) affected, which would remain e.g. 4 on x86-64." (Curiously, the pragma pack value had always been 8 for rtl_String but 4 for rtl_uString, ever since at least 9399c662f36c385b0c705eb34e636a9aec450282 "initial import".) The plan is as follows: In step 1, add temporary static_asserts that state the current alignof/sizeof values; keep this for a while to see that all relevant Windows builds actually agree on these status-quo values. In step 2, remove the pragma pack cargo cult; keep the static_asserts for a while to see that the removal has no impact on any of the relevant Windows builds. Finally, in step 3, remove the temporary static_asserts again. Change-Id: I8059ac300cc5b517db4a575f0eaba48678966537 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114540 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-01-10Replace strtmpl.cxx with actual C++ templates in strtmpl.hxxMike Kaganski
This has at least better IDE support, with easier lookup for function implementations. Change-Id: I0e4cfe40df036efa796c057852bd5cb4421507f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108931 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-07-02Upcoming improved loplugin:staticanonymous -> redundantstatic: salStephan Bergmann
Change-Id: I022f5ed37d25f2c8a8870033bab32ff59d4d8da6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97648 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-12-19sal_Char->char in remotebridges..saxNoel Grandin
Change-Id: I6d32942960a5e997f16eb1301c45495661cd4cea Reviewed-on: https://gerrit.libreoffice.org/85514 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-08-02Fix typosAndrea Gelmini
Change-Id: Ie183c445bf8a545f59aac7b0e29f72ab679a6cf3 Reviewed-on: https://gerrit.libreoffice.org/76852 Tested-by: Jenkins Reviewed-by: Andrea Gelmini <andrea.gelmini@gelma.net>
2018-09-17New loplugin:externalStephan Bergmann
...warning about (for now only) functions and variables with external linkage that likely don't need it. The problems with moving entities into unnamed namespacs and breaking ADL (as alluded to in comments in compilerplugins/clang/external.cxx) are illustrated by the fact that while struct S1 { int f() { return 0; } }; int f(S1 s) { return s.f(); } namespace N { struct S2: S1 { int f() { return 1; } }; int f(S2 s) { return s.f(); } } int main() { return f(N::S2()); } returns 1, both moving just the struct S2 into an nunnamed namespace, struct S1 { int f() { return 0; } }; int f(S1 s) { return s.f(); } namespace N { namespace { struct S2: S1 { int f() { return 1; } }; } int f(S2 s) { return s.f(); } } int main() { return f(N::S2()); } as well as moving just the function f overload into an unnamed namespace, struct S1 { int f() { return 0; } }; int f(S1 s) { return s.f(); } namespace N { struct S2: S1 { int f() { return 1; } }; namespace { int f(S2 s) { return s.f(); } } } int main() { return f(N::S2()); } would each change the program to return 0 instead. Change-Id: I4d09f7ac5e8f9bcd6e6bde4712608444b642265c Reviewed-on: https://gerrit.libreoffice.org/60539 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-02-02sal: MSVC: pragma warning: make more specific, remove obsoleteMike Kaganski
Change-Id: Ib7ad23257a966447d627b4f73698d9298790f759 Reviewed-on: https://gerrit.libreoffice.org/49042 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-01-12More loplugin:cstylecast: salStephan Bergmann
auto-rewrite with <https://gerrit.libreoffice.org/#/c/47798/> "Enable loplugin:cstylecast for some more cases" plus solenv/clang-format/reformat-formatted-files Change-Id: I7d89b011464ba5d2dd12e04d5fc9f65cb4daebde
2017-12-15sal: add pre-initialization scheme for allocations.Michael Meeks
This saves several megabytes of dirtied pages for each LOK client of Online. Change-Id: I425a2e7896879f0a64d71fcc0655e9e1fa1256aa
2017-12-11loplugin:salcall fix functionsNoel Grandin
since cdecl is the default calling convention on Windows for such functions, the annotation is redundant. Change-Id: I1a85fa27e5ac65ce0e04a19bde74c90800ffaa2d Reviewed-on: https://gerrit.libreoffice.org/46164 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-10-23loplugin:includeform: salStephan Bergmann
Change-Id: I539ca8b9dee5edc5fc2282a2b9b0ffd78bad8b11
2016-04-20loplugin:salbool: Automatic rewrite of sal_False/TrueStephan Bergmann
Change-Id: I6c656f991999791469015500aff1905fdb16ba65
2015-11-10loplugin:nullptr (automatic rewrite)Stephan Bergmann
Change-Id: I1bc6c87fcd6e5e96362623be94c59be216a3b2b8
2015-04-20Clean up new rtl/surrogates.hStephan Bergmann
Change-Id: Iec781bdbbf216cb14c9ba5be5955123273d7699c
2015-04-20duplicate surrogate codeCaolán McNamara
Change-Id: I9fad024e4b5c8a4ca272f2387df07351198cf5dc
2015-02-05sal: add some argument checking assertions for strings and buffersMichael Stahl
Also remove some now redundant asserts from headers. Some of these actually trigger on unit tests so are commented out. Change-Id: I07c6b2b2bd175361691a141f22eec584e3ab8f0b
2015-01-06-Werror,-Wmacro-redefined (under Clang -fsanitize=*)Stephan Bergmann
Change-Id: Ifd23373b1ac4919793d1b4251ed90cf2dd6f2bda
2014-12-19constants via #define must be integer if used in #if statementChristian Lohmaier
breaks windows build otherwise (fatal erro C1017) Change-Id: Idae78c621bfb8f989eb33220f015e17a7b7fb92f
2014-12-19IMPL_RTL_INTERN -> IMPL_RTL_IS_USTRINGStephan Bergmann
Change-Id: I9793f697f14118340bc6db89540fe50ad0b8ccbd
2014-07-03coverity#1187696 Unintended sign extensionCaolán McNamara
Change-Id: I8e56137ad4422381adbf13b179e2ae6f04edea6e
2014-07-01Clean up surrogates.hxxStephan Bergmann
Change-Id: I0eae089be1bde9db822a77bea482c10650c8a137
2014-02-17sal: sal_Bool -> boolStephan Bergmann
Change-Id: I071a931660dafc1ee5950da527b042fb175255b8
2013-12-02Drop duplicate #includeTakeshi Abe
Change-Id: Ife8ebbb5e46704c5d2ff46cc345b4ed926e7dc12
2013-11-12document the use of the strtmpl.cxx and remove unnecessary macro usageNoel Grandin
Document the "calling" macros for the strtmpl.cxx template file. And remove unnecessary use of those macros in the calling file. Change-Id: I20e0dd74150773363b9fb557884b84692ce22f11 Reviewed-on: https://gerrit.libreoffice.org/6504 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
2013-08-03Add SDT probes for RTL_LOG_STRING_NEW/DELETE.Mark Wielaard
Change-Id: I938259f90aee9d277c9ff5b72c9120b93311cbd3 Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
2013-02-22Bin pointless single-child directory levelTor Lillqvist
Change-Id: I03de46fb6c095bb176fd25fc5f803be6d2d89bcf