diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-07-21 09:11:40 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-07-21 13:20:18 +0200 |
commit | 9230c189ebc5bcfd6303bfa7eebcd35488037d00 (patch) | |
tree | a6b63ef022535b20ed7747a26dbc95853d18faed | |
parent | 5baa40802960eac5c6df897fdbbd59c5e479fca4 (diff) |
Use existing rtl_str_toInt64_WithLength
...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
-rw-r--r-- | include/rtl/string.h | 25 | ||||
-rw-r--r-- | sal/rtl/string.cxx | 6 | ||||
-rw-r--r-- | sal/util/sal.map | 1 | ||||
-rw-r--r-- | sax/source/tools/fastattribs.cxx | 12 |
4 files changed, 10 insertions, 34 deletions
diff --git a/include/rtl/string.h b/include/rtl/string.h index 62fc7ecfb2d0..155c1d46126c 100644 --- a/include/rtl/string.h +++ b/include/rtl/string.h @@ -747,31 +747,6 @@ SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_str_toBoolean( SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_toInt32( const char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C(); -/** Interpret a string as a integer. - - This function cannot be used for language-specific conversion. The string - must be null-terminated. - - @param str - a null-terminated string. - - @param radix - the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX - (36), inclusive. - - @param nStrLength - number of chars to process - - @return - the integer value represented by the string, or 0 if the string does - not represent a integer. - - @internal - @since LibreOffice 7.3 -*/ -SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_toInt32_WithLength( - const char * str, sal_Int16 radix, sal_Int32 nStrLength ) SAL_THROW_EXTERN_C(); - /** Interpret a string as an unsigned integer. This function cannot be used for language-specific conversion. The string diff --git a/sal/rtl/string.cxx b/sal/rtl/string.cxx index 6fc2df75698d..660f22552b0c 100644 --- a/sal/rtl/string.cxx +++ b/sal/rtl/string.cxx @@ -567,12 +567,6 @@ sal_Int32 SAL_CALL rtl_str_toInt32(const char* pStr, sal_Int16 nRadix) SAL_THROW return rtl::str::toInt32(pStr, nRadix); } -sal_Int32 SAL_CALL rtl_str_toInt32_WithLength(const char* pStr, sal_Int16 nRadix, - sal_Int32 nStrLength) SAL_THROW_EXTERN_C() -{ - return rtl::str::toInt32_WithLength(pStr, nRadix, nStrLength); -} - sal_Int64 SAL_CALL rtl_str_toInt64(const char* pStr, sal_Int16 nRadix) SAL_THROW_EXTERN_C() { return rtl::str::toInt64(pStr, nRadix); diff --git a/sal/util/sal.map b/sal/util/sal.map index e2339bdc13ac..e33dde55b8da 100644 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -757,7 +757,6 @@ PRIVATE_1.7 { # LibreOffice 7.1 PRIVATE_1.8 { # LibreOffice 7.3 global: - rtl_str_toInt32_WithLength; rtl_str_toDouble_WithLength; } PRIVATE_1.7; diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx index 9cec32318108..2512f6296aee 100644 --- a/sax/source/tools/fastattribs.cxx +++ b/sax/source/tools/fastattribs.cxx @@ -196,7 +196,11 @@ bool FastAttributeList::getAsInteger( sal_Int32 nToken, sal_Int32 &rInt) const for (size_t i = 0; i < maAttributeTokens.size(); ++i) if (maAttributeTokens[i] == nToken) { - rInt = rtl_str_toInt32_WithLength( getFastAttributeValue(i), 10, AttributeValueLength(i) ); + sal_Int64 n = rtl_str_toInt64_WithLength( getFastAttributeValue(i), 10, AttributeValueLength(i) ); + if (n < SAL_MIN_INT32 || n > SAL_MAX_INT32) { + n = 0; + } + rInt = n; return true; } return false; @@ -204,7 +208,11 @@ bool FastAttributeList::getAsInteger( sal_Int32 nToken, sal_Int32 &rInt) const sal_Int32 FastAttributeList::getAsIntegerByIndex( sal_Int32 nTokenIndex ) const { - return rtl_str_toInt32_WithLength( getFastAttributeValue(nTokenIndex), 10, AttributeValueLength(nTokenIndex) ); + sal_Int64 n = rtl_str_toInt64_WithLength( getFastAttributeValue(nTokenIndex), 10, AttributeValueLength(nTokenIndex) ); + if (n < SAL_MIN_INT32 || n > SAL_MAX_INT32) { + n = 0; + } + return n; } bool FastAttributeList::getAsDouble( sal_Int32 nToken, double &rDouble) const |