diff options
author | Noel Grandin <noel@peralex.com> | 2013-10-31 11:26:25 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-11-12 16:16:46 +0000 |
commit | 1db1d9ecadf10788f5b310942e0128344ad2c8aa (patch) | |
tree | 4c705e9f5c0191abc159796198e44a61521c72f6 /sal/rtl | |
parent | svtools.filter -> vcl.filter (diff) | |
download | core-1db1d9ecadf10788f5b310942e0128344ad2c8aa.tar.gz core-1db1d9ecadf10788f5b310942e0128344ad2c8aa.zip |
document the use of the strtmpl.cxx and remove unnecessary macro usage
Document the "calling" macros for the strtmpl.cxx template file.
And remove unnecessary use of those macros in the calling file.
Change-Id: I20e0dd74150773363b9fb557884b84692ce22f11
Reviewed-on: https://gerrit.libreoffice.org/6504
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sal/rtl')
-rw-r--r-- | sal/rtl/string.cxx | 19 | ||||
-rw-r--r-- | sal/rtl/ustring.cxx | 32 |
2 files changed, 29 insertions, 22 deletions
diff --git a/sal/rtl/string.cxx b/sal/rtl/string.cxx index 313706d797e8..ce7fa3174af0 100644 --- a/sal/rtl/string.cxx +++ b/sal/rtl/string.cxx @@ -52,7 +52,10 @@ static 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_STRCODE sal_Char #define IMPL_RTL_USTRCODE( c ) ((unsigned char)c) #define IMPL_RTL_STRNAME( n ) rtl_str_ ## n @@ -205,10 +208,10 @@ sal_Bool SAL_CALL rtl_impl_convertUStringToString(rtl_String ** pTarget, the buffer faster */ if ( nNewLen == (sal_Size)nLength ) { - IMPL_RTL_STRCODE* pBuffer; + sal_Char* pBuffer; if ( *pTarget ) - IMPL_RTL_STRINGNAME( release )( *pTarget ); - *pTarget = IMPL_RTL_STRINGNAME( ImplAlloc )( nLength ); + rtl_string_release( *pTarget ); + *pTarget = rtl_string_ImplAlloc( nLength ); OSL_ASSERT(*pTarget != NULL); pBuffer = (*pTarget)->buffer; do @@ -217,7 +220,7 @@ sal_Bool SAL_CALL rtl_impl_convertUStringToString(rtl_String ** pTarget, OSL_ENSURE( *pSource <= 127, "rtl_uString2String() - UTF8 test is encoding is wrong" ); - *pBuffer = (IMPL_RTL_STRCODE)(unsigned char)*pSource; + *pBuffer = (sal_Char)(unsigned char)*pSource; pBuffer++; pSource++; nLength--; @@ -247,7 +250,7 @@ sal_Bool SAL_CALL rtl_impl_convertUStringToString(rtl_String ** pTarget, for (;;) { - pTemp = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); + pTemp = rtl_string_ImplAlloc( nNewLen ); OSL_ASSERT(pTemp != NULL); nDestBytes = rtl_convertUnicodeToText( hConverter, 0, pSource, nLength, @@ -277,7 +280,7 @@ sal_Bool SAL_CALL rtl_impl_convertUStringToString(rtl_String ** pTarget, much overhead, reallocate to the correct size */ if ( nNewLen > nDestBytes+8 ) { - rtl_String* pTemp2 = IMPL_RTL_STRINGNAME( ImplAlloc )( nDestBytes ); + rtl_String* pTemp2 = rtl_string_ImplAlloc( nDestBytes ); OSL_ASSERT(pTemp2 != NULL); rtl_str_ImplCopy( pTemp2->buffer, pTemp->buffer, nDestBytes ); rtl_freeMemory( pTemp ); @@ -291,7 +294,7 @@ sal_Bool SAL_CALL rtl_impl_convertUStringToString(rtl_String ** pTarget, rtl_destroyUnicodeToTextConverter( hConverter ); if ( *pTarget ) - IMPL_RTL_STRINGNAME( release )( *pTarget ); + rtl_string_release( *pTarget ); *pTarget = pTemp; /* Results the conversion in an empty buffer - diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx index e27a1dda96a7..7b266edc0e06 100644 --- a/sal/rtl/ustring.cxx +++ b/sal/rtl/ustring.cxx @@ -58,6 +58,10 @@ static rtl_uString const aImplEmpty_rtl_uString = }; /* ======================================================================= */ +/* These macros are for the "poor-man templates" included from + * the strtmpl.cxx just below, used to share code between here and + * string.cxx + */ #define IMPL_RTL_STRCODE sal_Unicode #define IMPL_RTL_USTRCODE( c ) (c) @@ -467,18 +471,18 @@ void SAL_CALL rtl_uString_newFromAscii( rtl_uString** ppThis, if ( !nLen ) { - IMPL_RTL_STRINGNAME( new )( ppThis ); + rtl_uString_new( ppThis ); return; } if ( *ppThis ) - IMPL_RTL_STRINGNAME( release )( *ppThis ); + rtl_uString_release( *ppThis ); - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + *ppThis = rtl_uString_ImplAlloc( nLen ); OSL_ASSERT(*ppThis != NULL); if ( (*ppThis) ) { - IMPL_RTL_STRCODE* pBuffer = (*ppThis)->buffer; + sal_Unicode* pBuffer = (*ppThis)->buffer; do { /* Check ASCII range */ @@ -603,13 +607,13 @@ static void rtl_string2UString_status( rtl_uString** ppThis, else { if ( *ppThis ) - IMPL_RTL_STRINGNAME( release )( *ppThis ); + rtl_uString_release( *ppThis ); /* Optimization for US-ASCII */ if ( eTextEncoding == RTL_TEXTENCODING_ASCII_US ) { - IMPL_RTL_STRCODE* pBuffer; - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + sal_Unicode* pBuffer; + *ppThis = rtl_uString_ImplAlloc( nLen ); if (*ppThis == NULL) { if (pInfo != NULL) { *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | @@ -654,8 +658,8 @@ static void rtl_string2UString_status( rtl_uString** ppThis, the buffer faster */ if ( nNewLen == (sal_Size)nLen ) { - IMPL_RTL_STRCODE* pBuffer; - *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + sal_Unicode* pBuffer; + *ppThis = rtl_uString_ImplAlloc( nLen ); if (*ppThis == NULL) { if (pInfo != NULL) { @@ -690,7 +694,7 @@ static void rtl_string2UString_status( rtl_uString** ppThis, nCvtFlags |= RTL_TEXTTOUNICODE_FLAGS_FLUSH; hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); - pTemp = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); + pTemp = rtl_uString_ImplAlloc( nNewLen ); if (pTemp == NULL) { if (pInfo != NULL) { *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | @@ -712,7 +716,7 @@ static void rtl_string2UString_status( rtl_uString** ppThis, { rtl_freeMemory( pTemp ); nNewLen += 8; - pTemp = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); + pTemp = rtl_uString_ImplAlloc( nNewLen ); if (pTemp == NULL) { if (pInfo != NULL) { *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | @@ -734,7 +738,7 @@ static void rtl_string2UString_status( rtl_uString** ppThis, much overhead, reallocate to the correct size */ if ( nNewLen > nDestChars+8 ) { - pTemp2 = IMPL_RTL_STRINGNAME( ImplAlloc )( nDestChars ); + pTemp2 = rtl_uString_ImplAlloc( nDestChars ); } if (pTemp2 != NULL) { @@ -892,7 +896,7 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr, int i; rtl_uString *pScratch; pScratch = static_cast< rtl_uString * >( - alloca(sizeof (rtl_uString) + len * sizeof (IMPL_RTL_STRCODE))); + alloca(sizeof (rtl_uString) + len * sizeof (sal_Unicode))); for (i = 0; i < len; i++) { /* Check ASCII range */ @@ -913,7 +917,7 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr, pScratch = static_cast< rtl_uString * >( alloca( - sizeof (rtl_uString) + ulen * sizeof (IMPL_RTL_STRCODE))); + sizeof (rtl_uString) + ulen * sizeof (sal_Unicode))); hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); rtl_convertTextToUnicode( |