[Libreoffice-commits] core.git: 3 commits - sal/rtl unoidl/source
Stephan Bergmann
sbergman at redhat.com
Fri Dec 19 08:20:13 PST 2014
sal/rtl/string.cxx | 3 +++
sal/rtl/strtmpl.cxx | 32 ++++++++++++--------------------
sal/rtl/ustring.cxx | 9 ++++-----
unoidl/source/sourceprovider-parser.y | 4 ++--
4 files changed, 21 insertions(+), 27 deletions(-)
New commits:
commit c54c276d09dae5472363fd433fe64c8424608e90
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Dec 19 17:19:28 2014 +0100
unoidl: Use appropriate OUString functions on string constants
Change-Id: I6ff256e091770d67f98b1b6b8d447a22fd720d4e
diff --git a/unoidl/source/sourceprovider-parser.y b/unoidl/source/sourceprovider-parser.y
index 133f131..de3f8e9 100644
--- a/unoidl/source/sourceprovider-parser.y
+++ b/unoidl/source/sourceprovider-parser.y
@@ -135,7 +135,7 @@ void convertToCurrentName(
void clearCurrentState(unoidl::detail::SourceProviderScannerData * data) {
assert(data != 0);
- data->currentName = "";
+ data->currentName.clear();
data->publishedContext = false;
}
@@ -542,7 +542,7 @@ Found findEntity(
break;
}
n = "." + typeNucleus;
- typeNucleus = "",
+ typeNucleus.clear();
e = findEntity_(data, &n);
continue;
}
commit 2171c3dd49694b4928b0a04b76d3c42a2b18f6cc
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Dec 19 15:44:25 2014 +0100
Assert ASCII precond of rtl_uString_newFromAscii/Literal
...and there is no reason for such a precond for rtl_string_newFromLiteral
Change-Id: I27f7217c8db17cef860c37886d0f7e561dc852f8
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx
index 07258b6..1a1e74f 100644
--- a/sal/rtl/strtmpl.cxx
+++ b/sal/rtl/strtmpl.cxx
@@ -1374,9 +1374,9 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromLiteral )( IMPL_RTL_STRINGDATA** ppThi
sal_Int32 nCount;
for( nCount = nLen; nCount > 0; --nCount )
{
- /* Check ASCII range */
- SAL_WARN_IF( ((unsigned char)*pCharStr) > 127, "rtl.string",
- "rtl_uString_newFromLiteral - Found char > 127" );
+#if IMPL_RTL_IS_USTRING
+ assert(static_cast<unsigned char>(*pCharStr) < 0x80); // ASCII range
+#endif
SAL_WARN_IF( ((unsigned char)*pCharStr) == '\0', "rtl.string",
"rtl_uString_newFromLiteral - Found embedded \\0 character" );
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index 26aa5d9..0fc9e06 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -501,10 +501,7 @@ void SAL_CALL rtl_uString_newFromAscii( rtl_uString** ppThis,
sal_Unicode* pBuffer = (*ppThis)->buffer;
do
{
- /* Check ASCII range */
- SAL_WARN_IF( ((unsigned char)*pCharStr) > 127, "rtl.string",
- "rtl_uString_newFromAscii - Found char > 127" );
-
+ assert(static_cast<unsigned char>(*pCharStr) < 0x80); // ASCII range
*pBuffer = *pCharStr;
pBuffer++;
pCharStr++;
commit 80131c795f1f9e9fcfb5a85243fb8585b083f8b1
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Dec 19 15:36:50 2014 +0100
IMPL_RTL_INTERN -> IMPL_RTL_IS_USTRING
Change-Id: I9793f697f14118340bc6db89540fe50ad0b8ccbd
diff --git a/sal/rtl/string.cxx b/sal/rtl/string.cxx
index 07e3e94..259906c 100644
--- a/sal/rtl/string.cxx
+++ b/sal/rtl/string.cxx
@@ -55,6 +55,9 @@ static rtl_String const aImplEmpty_rtl_String =
* the strtmpl.cxx just below, used to share code between here and
* ustring.cxx
*/
+
+#define IMPL_RTL_IS_USTRING false
+
#define IMPL_RTL_STRCODE sal_Char
#define IMPL_RTL_USTRCODE( c ) ((unsigned char)c)
#define IMPL_RTL_STRNAME( n ) rtl_str_ ## n
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx
index 71a2fb2..07258b6 100644
--- a/sal/rtl/strtmpl.cxx
+++ b/sal/rtl/strtmpl.cxx
@@ -62,8 +62,7 @@ static inline void rtl_str_ImplCopy( IMPL_RTL_STRCODE* _pDest,
sal_Int32 SAL_CALL IMPL_RTL_STRNAME( getLength )( const IMPL_RTL_STRCODE* pStr )
SAL_THROW_EXTERN_C()
{
-// same as "if sal_Char mode"
-#ifndef IMPL_RTL_INTERN
+#if !IMPL_RTL_IS_USTRING
// take advantage of builtin optimisations
return strlen( pStr);
#else
@@ -88,8 +87,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare )( const IMPL_RTL_STRCODE* pStr1,
const IMPL_RTL_STRCODE* pStr2 )
SAL_THROW_EXTERN_C()
{
-// same as "if sal_Char mode"
-#ifndef IMPL_RTL_INTERN
+#if !IMPL_RTL_IS_USTRING
// take advantage of builtin optimisations
return strcmp( pStr1, pStr2);
#else
@@ -122,8 +120,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare_WithLength )( const IMPL_RTL_STRCOD
sal_Int32 nStr2Len )
SAL_THROW_EXTERN_C()
{
-// same as "if sal_Char mode"
-#ifndef IMPL_RTL_INTERN
+#if !IMPL_RTL_IS_USTRING
// take advantage of builtin optimisations
sal_Int32 nMin = std::min(nStr1Len, nStr2Len);
sal_Int32 nRet = strncmp(pStr1, pStr2, nMin);
@@ -163,8 +160,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( shortenedCompare_WithLength )( const IMPL_R
sal_Int32 nShortenedLength )
SAL_THROW_EXTERN_C()
{
-// same as "if sal_Char mode"
-#ifndef IMPL_RTL_INTERN
+#if !IMPL_RTL_IS_USTRING
// take advantage of builtin optimisations
sal_Int32 nMin = std::min(std::min(nStr1Len, nStr2Len), nShortenedLength);
sal_Int32 nRet = strncmp(pStr1, pStr2, nMin);
@@ -336,8 +332,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfChar )( const IMPL_RTL_STRCODE* pStr
IMPL_RTL_STRCODE c )
SAL_THROW_EXTERN_C()
{
-// same as "if sal_Char mode"
-#ifndef IMPL_RTL_INTERN
+#if !IMPL_RTL_IS_USTRING
// take advantage of builtin optimisations
const IMPL_RTL_STRCODE* p = strchr(pStr, c);
return p ? p - pStr : -1;
@@ -371,8 +366,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfChar_WithLength )( const IMPL_RTL_ST
IMPL_RTL_STRCODE c )
SAL_THROW_EXTERN_C()
{
-// same as "if sal_Char mode"
-#ifndef IMPL_RTL_INTERN
+#if !IMPL_RTL_IS_USTRING
// take advantage of builtin optimisations
IMPL_RTL_STRCODE* p = (IMPL_RTL_STRCODE*) memchr(pStr, c, nLen);
return p ? p - pStr : -1;
@@ -397,8 +391,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfChar )( const IMPL_RTL_STRCODE*
IMPL_RTL_STRCODE c )
SAL_THROW_EXTERN_C()
{
-// same as "if sal_Char mode"
-#ifndef IMPL_RTL_INTERN
+#if !IMPL_RTL_IS_USTRING
// take advantage of builtin optimisations
const IMPL_RTL_STRCODE* p = strrchr(pStr, c);
return p ? p - pStr : -1;
@@ -442,8 +435,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfStr )( const IMPL_RTL_STRCODE* pStr,
const IMPL_RTL_STRCODE* pSubStr )
SAL_THROW_EXTERN_C()
{
-// same as "if sal_Char mode"
-#ifndef IMPL_RTL_INTERN
+#if !IMPL_RTL_IS_USTRING
// take advantage of builtin optimisations
const IMPL_RTL_STRCODE* p = strstr(pStr, pSubStr);
return p ? p - pStr : -1;
@@ -1177,7 +1169,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( release )( IMPL_RTL_STRINGDATA* pThis )
return;
/* OString doesn't have an 'intern' */
-#ifdef IMPL_RTL_INTERN
+#if IMPL_RTL_IS_USTRING
if (SAL_STRING_IS_INTERN (pThis))
{
internRelease (pThis);
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index b3eeac1..26aa5d9 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -62,6 +62,8 @@ static rtl_uString const aImplEmpty_rtl_uString =
* string.cxx
*/
+#define IMPL_RTL_IS_USTRING true
+
#define IMPL_RTL_STRCODE sal_Unicode
#define IMPL_RTL_USTRCODE( c ) (c)
#define IMPL_RTL_STRNAME( n ) rtl_ustr_ ## n
@@ -69,7 +71,7 @@ static rtl_uString const aImplEmpty_rtl_uString =
#define IMPL_RTL_STRINGNAME( n ) rtl_uString_ ## n
#define IMPL_RTL_STRINGDATA rtl_uString
#define IMPL_RTL_EMPTYSTRING aImplEmpty_rtl_uString
-#define IMPL_RTL_INTERN
+
static void internRelease (rtl_uString *pThis);
#if USE_SDT_PROBES
More information about the Libreoffice-commits
mailing list