diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-03-07 15:07:07 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-03-12 13:35:56 +0100 |
commit | 53fb5f774e262e6dbe364c9da06ae5e0db11b5d7 (patch) | |
tree | 45a625f1a34774dbd03668c78516588a7d48a22a /sal/rtl | |
parent | 2f5f802bcf197c5c65aa4453ad2097d5642b80aa (diff) |
OString ctor for string literals without RTL_CONSTASCII stuff
Diffstat (limited to 'sal/rtl')
-rw-r--r-- | sal/rtl/source/strtmpl.cxx | 38 | ||||
-rw-r--r-- | sal/rtl/source/ustring.cxx | 35 |
2 files changed, 38 insertions, 35 deletions
diff --git a/sal/rtl/source/strtmpl.cxx b/sal/rtl/source/strtmpl.cxx index f8220b239d65..a3ef1facdadf 100644 --- a/sal/rtl/source/strtmpl.cxx +++ b/sal/rtl/source/strtmpl.cxx @@ -32,6 +32,7 @@ /* ======================================================================= */ #include <string.h> +#include <sal/log.hxx> /* inline void rtl_str_ImplCopy( IMPL_RTL_STRCODE* pDest, @@ -1187,6 +1188,43 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromStr_WithLength )( IMPL_RTL_STRINGDATA* /* ----------------------------------------------------------------------- */ +// Used when creating from string literals. +// Intentionally copies also embedded \0's if present. +void SAL_CALL IMPL_RTL_STRINGNAME( newFromLiteral)( IMPL_RTL_STRINGDATA** ppThis, + const sal_Char* pCharStr, + sal_Int32 nLen ) + SAL_THROW_EXTERN_C() +{ + if ( !nLen ) + { + IMPL_RTL_STRINGNAME( new )( ppThis ); + return; + } + + if ( *ppThis ) + IMPL_RTL_STRINGNAME( release )( *ppThis ); + + *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + OSL_ASSERT(*ppThis != NULL); + if ( (*ppThis) ) + { + IMPL_RTL_STRCODE* pBuffer = (*ppThis)->buffer; + 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" ); + + *pBuffer = *pCharStr; + pBuffer++; + pCharStr++; + } + } +} + +/* ----------------------------------------------------------------------- */ + void SAL_CALL IMPL_RTL_STRINGNAME( assign )( IMPL_RTL_STRINGDATA** ppThis, IMPL_RTL_STRINGDATA* pStr ) SAL_THROW_EXTERN_C() diff --git a/sal/rtl/source/ustring.cxx b/sal/rtl/source/ustring.cxx index 649cb82b9013..7c99758a9b6c 100644 --- a/sal/rtl/source/ustring.cxx +++ b/sal/rtl/source/ustring.cxx @@ -499,41 +499,6 @@ void SAL_CALL rtl_uString_newFromAscii( rtl_uString** ppThis, } } -// Used when creating from string literals. -// Intentionally copies also embedded \0's if present. -void SAL_CALL rtl_uString_newFromLiteral( rtl_uString** ppThis, - const sal_Char* pCharStr, - sal_Int32 nLen ) - SAL_THROW_EXTERN_C() -{ - if ( !nLen ) - { - IMPL_RTL_STRINGNAME( new )( ppThis ); - return; - } - - if ( *ppThis ) - IMPL_RTL_STRINGNAME( release )( *ppThis ); - - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - OSL_ASSERT(*ppThis != NULL); - if ( (*ppThis) ) - { - IMPL_RTL_STRCODE* pBuffer = (*ppThis)->buffer; - 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" ); - - *pBuffer = *pCharStr; - pBuffer++; - pCharStr++; - } - } -} - void SAL_CALL rtl_uString_newFromCodePoints( rtl_uString ** newString, sal_uInt32 const * codePoints, sal_Int32 codePointCount) SAL_THROW_EXTERN_C() |