summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-17 15:17:13 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-18 12:58:55 +0200
commit7462343cb9c7a61cd28c7eae245f21b6bfc56b40 (patch)
treefef10a16712d4bc070dd0905ebd8ae437d2f947c
parent5c5b058c83e31e798a63a96d0e16b35927ce519f (diff)
update "add OString::getTokenView"
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>
-rw-r--r--include/rtl/string.h51
-rw-r--r--include/rtl/string.hxx2
-rw-r--r--sal/rtl/string.cxx5
-rw-r--r--sal/rtl/strtmpl.hxx9
-rw-r--r--sal/util/sal.map3
-rw-r--r--sdext/source/pdfimport/wrapper/wrapper.cxx10
6 files changed, 16 insertions, 64 deletions
diff --git a/include/rtl/string.h b/include/rtl/string.h
index c0f724245d9e..c86468c7f302 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 an 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 len
- the length of the character array.
-
- @return
- the integer value represented by the string, or 0 if the string does not
- represent an integer.
-
- @since LibreOffice 7.2
- @internal
- */
-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
@@ -1289,7 +1264,7 @@ SAL_DLLPUBLIC void SAL_CALL rtl_string_newTrim(
/** Create a new string by extracting a single token from another string.
- Starting at index, the token's next token is searched for. If there is no
+ Starting at index, the next token is searched for. If there is no
such token, the result is an empty string. Otherwise, all characters from
the start of that token and up to, but not including the next occurrence
of cTok make up the resulting token. The return value is the position of
@@ -1334,33 +1309,19 @@ SAL_DLLPUBLIC void SAL_CALL rtl_string_newTrim(
SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getToken(
rtl_String ** newStr , rtl_String * str, sal_Int32 token, char cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
+/** @cond INTERNAL */
/** Create a new string by extracting a single token from another string.
- Starting at index, the token's next token is searched for. If there is no
+ Starting at index, the next token is searched for. If there is no
such token, the result is an empty string. Otherwise, all characters from
the start of that token and up to, but not including the next occurrence
of cTok make up the resulting token. The return value is the position of
the next token, or -1 if no more tokens follow.
- Example code could look like
- rtl_String * pToken = NULL;
- sal_Int32 nIndex = 0;
- do
- {
- ...
- nIndex = rtl_string_getToken(&pToken, pStr, 0, ';', nIndex);
- ...
- }
- while (nIndex >= 0);
-
- The new string does not necessarily have a reference count of 1, so it
- must not be modified without checking the reference count. This function
- does not handle out-of-memory conditions.
+ This function does not handle out-of-memory conditions.
@param ppViewStr
- pointer to the start of the token. The pointed-to data must be null or a valid
- string. If either token or index is negative, nullptr is stored in
- newStr (and -1 is returned).
+ pointer to the start of the token.
@param pViewLength
length of the token.
@@ -1382,10 +1343,10 @@ SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getToken(
the index of the next token, or -1 if no more tokens follow.
@since LibreOffice 7.2
- @internal
*/
SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getTokenView(
const char ** ppViewStr , sal_Int32* pViewLength, rtl_String * str, sal_Int32 token, char cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
+/** @endcond */
/* ======================================================================= */
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index c16519fa14df..3fc461de0c2c 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -1765,7 +1765,7 @@ public:
index = rtl_string_getToken( &pNew, pData, token, cTok, index );
return OString( pNew, SAL_NO_ACQUIRE );
}
-#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
+#ifdef LIBO_INTERNAL_ONLY
std::string_view getTokenView( sal_Int32 token, char cTok, sal_Int32& index ) const
{
const char* pViewData = nullptr;
diff --git a/sal/rtl/string.cxx b/sal/rtl/string.cxx
index 2eb4654caeb4..ec6b95718b3c 100644
--- a/sal/rtl/string.cxx
+++ b/sal/rtl/string.cxx
@@ -559,11 +559,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/rtl/strtmpl.hxx b/sal/rtl/strtmpl.hxx
index a25e8216d154..855516cec1d4 100644
--- a/sal/rtl/strtmpl.hxx
+++ b/sal/rtl/strtmpl.hxx
@@ -914,15 +914,6 @@ sal_Int32 toInt32 ( const IMPL_RTL_STRCODE* pStr,
}
template <typename IMPL_RTL_STRCODE>
-sal_Int32 toInt32_WithLength ( const IMPL_RTL_STRCODE* pStr,
- sal_Int16 nRadix,
- sal_Int32 nStrLength )
-{
- assert(pStr);
- return toInt_WithLength<sal_Int32, sal_uInt32>(pStr, nRadix, nStrLength);
-}
-
-template <typename IMPL_RTL_STRCODE>
sal_Int64 toInt64 ( const IMPL_RTL_STRCODE* pStr,
sal_Int16 nRadix )
{
diff --git a/sal/util/sal.map b/sal/util/sal.map
index 2f74ceb9150e..bc6e90ec488e 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -753,12 +753,11 @@ PRIVATE_1.6 { # LibreOffice 6.4
PRIVATE_1.7 { # LibreOffice 7.1
global:
rtl_uString_newReplaceAllFromIndexUtf16LUtf16L;
-} PRIVATE_1.6;
+} PRIVATE_1.5;
PRIVATE_1.8 { # LibreOffice 7.2
global:
rtl_string_getTokenView;
- rtl_str_toInt32_WithLength;
} PRIVATE_1.7;
PRIVATE_textenc.1 { # LibreOffice 3.6
diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx
index 5672249c3e15..f2439a5bb83c 100644
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -261,13 +261,19 @@ std::string_view LineParser::readNextToken()
void LineParser::readInt32( sal_Int32& o_Value )
{
std::string_view tok = readNextToken();
- o_Value = rtl_str_toInt32_WithLength(tok.data(), 10, tok.size());
+ sal_Int64 n = rtl_str_toInt64_WithLength(tok.data(), 10, tok.size());
+ if (n < SAL_MIN_INT32 || n > SAL_MAX_INT32)
+ n = 0;
+ o_Value = n;
}
sal_Int32 LineParser::readInt32()
{
std::string_view tok = readNextToken();
- return rtl_str_toInt32_WithLength(tok.data(), 10, tok.size());
+ sal_Int64 n =rtl_str_toInt64_WithLength(tok.data(), 10, tok.size());
+ if (n < SAL_MIN_INT32 || n > SAL_MAX_INT32)
+ n = 0;
+ return n;
}
void LineParser::readInt64( sal_Int64& o_Value )