[Libreoffice-commits] core.git: sal/rtl solenv/clang-format
sal/rtl/math.cxx| 259 solenv/clang-format/excludelist |1 2 files changed, 108 insertions(+), 152 deletions(-) New commits: commit 8b327dd75caf3fd3374ad92f84a70c276678a046 Author: Mike Kaganski AuthorDate: Sat Oct 21 11:44:17 2023 +0300 Commit: Mike Kaganski CommitDate: Sat Oct 21 12:46:44 2023 +0200 clang-format sal/rtl/math.cxx Change-Id: I0e807118e6a2196d2f2858ed195782a90572a2e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158303 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx index 32507b619ff7..68068eaf979f 100644 --- a/sal/rtl/math.cxx +++ b/sal/rtl/math.cxx @@ -102,8 +102,8 @@ static double getN10Exp(int nExp) return n10s[nExp - minExp]; } -namespace { - +namespace +{ /** If value (passed as absolute value) is an integer representable as double, which we handle explicitly at some places. */ @@ -113,8 +113,8 @@ bool isRepresentableInteger(double fAbsValue) && std::numeric_limits::digits == 53); assert(fAbsValue >= 0.0); if (fAbsValue >= 0x1p53) - return false; -sal_Int64 nInt = static_cast< sal_Int64 >(fAbsValue); +return false; +sal_Int64 nInt = static_cast(fAbsValue); return nInt == fAbsValue; } @@ -138,7 +138,7 @@ int getBitsInFracPart(double fAbsValue) assert(std::isfinite(fAbsValue) && fAbsValue >= 0.0); if (fAbsValue == 0.0) return 0; -auto pValParts = reinterpret_cast< const sal_math_Double * >(); +auto pValParts = reinterpret_cast(); int nExponent = pValParts->inf_parts.exponent - 1023; if (nExponent >= 52) return 0; // All bits in fraction are in integer part of the number @@ -156,61 +156,49 @@ int getBitsInFracPart(double fAbsValue) return std::max(nBitsInFracPart, 0); } - } -void SAL_CALL rtl_math_doubleToString(rtl_String ** pResult, - sal_Int32 * pResultCapacity, +void SAL_CALL rtl_math_doubleToString(rtl_String** pResult, sal_Int32* pResultCapacity, sal_Int32 nResultOffset, double fValue, - rtl_math_StringFormat eFormat, - sal_Int32 nDecPlaces, - char cDecSeparator, - sal_Int32 const * pGroups, - char cGroupSeparator, - sal_Bool bEraseTrailingDecZeros) + rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, + char cDecSeparator, sal_Int32 const* pGroups, + char cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C() { -rtl::str::doubleToString( -pResult, pResultCapacity, nResultOffset, fValue, eFormat, nDecPlaces, -cDecSeparator, pGroups, cGroupSeparator, bEraseTrailingDecZeros); +rtl::str::doubleToString(pResult, pResultCapacity, nResultOffset, fValue, eFormat, nDecPlaces, + cDecSeparator, pGroups, cGroupSeparator, bEraseTrailingDecZeros); } -void SAL_CALL rtl_math_doubleToUString(rtl_uString ** pResult, - sal_Int32 * pResultCapacity, +void SAL_CALL rtl_math_doubleToUString(rtl_uString** pResult, sal_Int32* pResultCapacity, sal_Int32 nResultOffset, double fValue, - rtl_math_StringFormat eFormat, - sal_Int32 nDecPlaces, - sal_Unicode cDecSeparator, - sal_Int32 const * pGroups, - sal_Unicode cGroupSeparator, - sal_Bool bEraseTrailingDecZeros) + rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, + sal_Unicode cDecSeparator, sal_Int32 const* pGroups, + sal_Unicode cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C() { -rtl::str::doubleToString( -pResult, pResultCapacity, nResultOffset, fValue, eFormat, nDecPlaces, -cDecSeparator, pGroups, cGroupSeparator, bEraseTrailingDecZeros); +rtl::str::doubleToString(pResult, pResultCapacity, nResultOffset, fValue, eFormat, nDecPlaces, + cDecSeparator, pGroups, cGroupSeparator, bEraseTrailingDecZeros); } -namespace { - -template< typename CharT > -double stringToDouble(CharT const * pBegin, CharT const * pEnd, - CharT cDecSeparator, CharT cGroupSeparator, - rtl_math_ConversionStatus * pStatus, - CharT
[Libreoffice-commits] core.git: sal/rtl solenv/clang-format
sal/rtl/string.cxx | 372 +++-- sal/rtl/strtmpl.hxx | 846 +++- sal/rtl/ustring.cxx | 392 -- solenv/clang-format/excludelist |2 4 files changed, 1113 insertions(+), 499 deletions(-) New commits: commit c5c0f8df855dfd4478c57170e251e4a9bcff1c10 Author: Mike Kaganski AuthorDate: Wed Jan 6 21:17:56 2021 +0300 Commit: Mike Kaganski CommitDate: Sun Jan 10 10:05:27 2021 +0100 Replace strtmpl.cxx with actual C++ templates in strtmpl.hxx 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 diff --git a/sal/rtl/string.cxx b/sal/rtl/string.cxx index aa6e2f58f3ae..a649406f68ad 100644 --- a/sal/rtl/string.cxx +++ b/sal/rtl/string.cxx @@ -35,10 +35,17 @@ /* === */ +#if USE_SDT_PROBES +#define RTL_LOG_STRING_BITS 8 +#endif + +#include "strtmpl.hxx" + /* static data to be referenced by all empty strings * the refCount is predefined to 1 and must never become 0 ! */ -rtl_String const aImplEmpty_rtl_String = +template<> +rtl_String rtl::str::EmptyStringImpl::data = { SAL_STRING_STATIC_FLAG|1, /* sal_Int32refCount; */ @@ -47,39 +54,6 @@ rtl_String const aImplEmpty_rtl_String = }; /* === */ -/* These macros are for the "poor-man templates" included from - * the strtmpl.cxx just below, used to share code between here and - * ustring.cxx - */ - -#define IMPL_RTL_IS_USTRING 0 - -#define IMPL_RTL_STRCODEchar -#define IMPL_RTL_USTRCODE( c ) (static_cast(c)) -#define IMPL_RTL_STRNAME( n ) rtl_str_ ## n - -#define IMPL_RTL_STRINGNAME( n )rtl_string_ ## n -#define IMPL_RTL_STRINGDATA rtl_String -#define IMPL_RTL_EMPTYSTRINGaImplEmpty_rtl_String - -#if USE_SDT_PROBES -#define RTL_LOG_STRING_BITS 8 -#endif - -/* === */ - -/* Include String/UString template code */ - -#include "strtmpl.cxx" - -#undef IMPL_RTL_EMPTYSTRING -#undef IMPL_RTL_IS_USTRING -#undef IMPL_RTL_STRCODE -#undef IMPL_RTL_STRINGDATA -#undef IMPL_RTL_STRINGNAME -#undef IMPL_RTL_STRNAME -#undef IMPL_RTL_USTRCODE -#undef RTL_LOG_STRING_BITS sal_Int32 SAL_CALL rtl_str_valueOfFloat(char * pStr, float f) SAL_THROW_EXTERN_C() @@ -293,7 +267,7 @@ static bool rtl_impl_convertUStringToString(rtl_String ** pTarget, { rtl_String* pTemp2 = rtl_string_ImplAlloc( nDestBytes ); OSL_ASSERT(pTemp2 != nullptr); -rtl_str_ImplCopy( pTemp2->buffer, pTemp->buffer, nDestBytes ); +rtl::str::Copy(pTemp2->buffer, pTemp->buffer, nDestBytes); rtl_freeString( pTemp ); pTemp = pTemp2; } @@ -391,4 +365,332 @@ void rtl_string_newReplaceAll( } } +sal_Int32 SAL_CALL rtl_str_getLength(const char* pStr) SAL_THROW_EXTERN_C() +{ +return rtl::str::getLength(pStr); +} + +sal_Int32 SAL_CALL rtl_str_compare(const char* pStr1, const char* pStr2) SAL_THROW_EXTERN_C() +{ +return rtl::str::compare(pStr1, pStr2); +} + +sal_Int32 SAL_CALL rtl_str_compare_WithLength(const char* pStr1, sal_Int32 nStr1Len, + const char* pStr2, sal_Int32 nStr2Len) +SAL_THROW_EXTERN_C() +{ +return rtl::str::compare_WithLength(pStr1, nStr1Len, pStr2, nStr2Len); +} + +sal_Int32 SAL_CALL rtl_str_shortenedCompare_WithLength(const char* pStr1, sal_Int32 nStr1Len, + const char* pStr2, sal_Int32 nStr2Len, + sal_Int32 nShortenedLength) +SAL_THROW_EXTERN_C() +{ +return rtl::str::shortenedCompare_WithLength(pStr1, nStr1Len, pStr2, nStr2Len, nShortenedLength); +} + +sal_Int32 SAL_CALL rtl_str_reverseCompare_WithLength(const char* pStr1, sal_Int32 nStr1Len, + const char* pStr2, sal_Int32 nStr2Len) +SAL_THROW_EXTERN_C() +{ +return rtl::str::reverseCompare_WithLength(pStr1, nStr1Len, pStr2, nStr2Len); +} + +sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase(const char* pStr1, const char* pStr2) +SAL_THROW_EXTERN_C() +{ +return rtl::str::compareIgnoreAsciiCase(pStr1, pStr2); +} + +sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase_WithLength(const char* pStr1, sal_Int32 nStr1Len, + const char* pStr2, sal_Int32 nStr2Len) +SAL_THROW_EXTERN_C() +{ +return rtl::str::compareIgnoreAsciiCase_WithLength(pStr1, nStr1Len, pStr2, nStr2Len); +} + +sal_Int32 SAL_CALL