[Libreoffice-commits] .: sal/inc sal/qa
sal/inc/rtl/string.hxx |1 + sal/inc/rtl/ustring.hxx|1 + sal/qa/rtl/strings/test_strings_valuex.cxx |1 - 3 files changed, 2 insertions(+), 1 deletion(-) New commits: commit c881b1b50e3be023efd4dfdebddd002545ed71b3 Author: LuboÅ¡ LuÅák l.lu...@suse.cz Date: Fri Jan 18 19:43:17 2013 +0100 long and long long can be the same size (and thus also sal_Int64) Change-Id: I3961ec27d23915b038c3a803dc71e7d937ca331c diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 325fe28..c04cd13 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -1522,6 +1522,7 @@ public: */ static OString number( unsigned long ll, sal_Int16 radix = 10 ) { +assert( ll = SAL_MAX_INT64 ); // valueOfInt64 may not be able to handle the highest bit sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64]; rtl_String* pNewData = 0; rtl_string_newFromStr_WithLength( pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) ); diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index c87978f..c0370ff 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -2156,6 +2156,7 @@ public: */ static OUString number( unsigned long ll, sal_Int16 radix = 10 ) { +assert( ll = SAL_MAX_INT64 ); // valueOfInt64 may not be able to handle the highest bit sal_Unicode aBuf[RTL_STR_MAX_VALUEOFINT64]; rtl_uString* pNewData = 0; rtl_uString_newFromStr_WithLength( pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) ); diff --git a/sal/qa/rtl/strings/test_strings_valuex.cxx b/sal/qa/rtl/strings/test_strings_valuex.cxx index d350b0f..9573b19 100644 --- a/sal/qa/rtl/strings/test_strings_valuex.cxx +++ b/sal/qa/rtl/strings/test_strings_valuex.cxx @@ -70,7 +70,6 @@ void testInt() { assert( sizeof( long ) = sizeof( sal_Int64 )); assert( sizeof( long long ) = sizeof( sal_Int64 )); assert( sizeof( unsigned int ) sizeof( sal_Int64 )); -assert( sizeof( unsigned long ) sizeof( sal_Int64 )); } void test::strings::valueX::testOUInt() { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] .: sal/inc sal/qa
sal/inc/rtl/ustring.hxx | 13 + sal/qa/rtl/strings/test_oustring_stringliterals.cxx |1 + 2 files changed, 14 insertions(+) New commits: commit c075b8068bff1b3c6025638aaf0acab5bbebab4d Author: LuboÅ¡ LuÅák l.lu...@suse.cz Date: Mon Dec 17 16:27:22 2012 +0100 OUString::reverseCompareTo() string literal overload to match the AsciiL one Change-Id: Id5ca706aa3fd1831990db2310933c6b94ca376cb diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 5760914..c9fe25e 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -528,6 +528,19 @@ public: } /** + @overload + This function accepts an ASCII string literal as its argument. + @since LibreOffice 4.1 +*/ +template typename T +typename internal::ConstCharArrayDetector T, sal_Int32 ::Type reverseCompareTo( T literal ) const SAL_THROW(()) +{ +assert( strlen( literal ) == internal::ConstCharArrayDetector T ::size - 1 ); +return rtl_ustr_asciil_reverseCompare_WithLength( pData-buffer, pData-length, +literal, internal::ConstCharArrayDetector T, void ::size - 1 ); +} + +/** Perform a comparison of two strings. The result is true if and only if second string diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx index a6d7145..873b536 100644 --- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx +++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx @@ -145,6 +145,7 @@ void test::oustring::StringLiterals::checkUsage() CPPUNIT_ASSERT( foobarfoo.replaceFirst( foo, test ) == testbarfoo ); CPPUNIT_ASSERT( foobarfoo.replaceAll( foo, test ) == testbartest ); CPPUNIT_ASSERT( foobarfoo.replaceAll( foo, test ) == testbartest ); +CPPUNIT_ASSERT( foo.reverseCompareTo( foo ) == 0 ); // if this is not true, some of the calls above converted to OUString CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false ); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] .: sal/inc sal/qa
sal/inc/rtl/string.hxx |7 +-- sal/inc/rtl/ustring.hxx |9 ++--- sal/qa/rtl/strings/test_ostring_concat.cxx |1 + sal/qa/rtl/strings/test_oustring_concat.cxx |1 + 4 files changed, 13 insertions(+), 5 deletions(-) New commits: commit 4e593d047b9c10de085dffa3fa3dd4602361c407 Author: Stephan Bergmann sberg...@redhat.com Date: Tue Dec 4 11:20:22 2012 +0100 Fix fast concat of empty strings Change-Id: Ice9c6974f44be3bc4c9b3533de2a9beb5b146ca5 diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 2c7a43d..aeb7528 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -262,8 +262,11 @@ public: const int l = c.length(); rtl_String* buffer = NULL; rtl_string_new_WithLength( buffer, l ); -char* end = c.addData( buffer-buffer ); -buffer-length = end - buffer-buffer; +if (l != 0) +{ +char* end = c.addData( buffer-buffer ); +buffer-length = end - buffer-buffer; +} pData = buffer; } #endif diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 534bd88..ec9f90e 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -330,9 +330,12 @@ public: const int l = c.length(); rtl_uString* buffer = NULL; rtl_uString_new_WithLength( buffer, l ); // TODO this clears, not necessary -sal_Unicode* end = c.addData( buffer-buffer ); -buffer-length = end - buffer-buffer; -// TODO realloc in case buffer-length is noticeably smaller than l ? +if (l != 0) +{ +sal_Unicode* end = c.addData( buffer-buffer ); +buffer-length = end - buffer-buffer; +// TODO realloc in case buffer-length is noticeably smaller than l? +} pData = buffer; } #endif diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx index a79b2da..46457dd 100644 --- a/sal/qa/rtl/strings/test_ostring_concat.cxx +++ b/sal/qa/rtl/strings/test_ostring_concat.cxx @@ -47,6 +47,7 @@ CPPUNIT_TEST_SUITE_END(); void test::ostring::StringConcat::check() { // All the extra () are to protect commas againsts being treated as separators of macro arguments. +CPPUNIT_ASSERT_EQUAL( OString(), OString(OString() + OString()) ); CPPUNIT_ASSERT_EQUAL( OString( foobar ), OString( OString( foo ) + OString( bar ))); TYPES_ASSERT_EQUAL(( typeid( OStringConcat OString, OString )), typeid( OString( foo ) + OString( bar ))); CPPUNIT_ASSERT_EQUAL( OString( foobar ), OString( OString( foo ) + bar )); diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx index 0cc2512..4f650dc 100644 --- a/sal/qa/rtl/strings/test_oustring_concat.cxx +++ b/sal/qa/rtl/strings/test_oustring_concat.cxx @@ -47,6 +47,7 @@ CPPUNIT_TEST_SUITE_END(); void test::oustring::StringConcat::check() { // All the extra () are to protect commas againsts being treated as separators of macro arguments. +CPPUNIT_ASSERT_EQUAL( OUString(), OUString(OUString() + OUString()) ); CPPUNIT_ASSERT_EQUAL( OUString( foobar ), OUString( OUString( foo ) + OUString( bar ))); TYPES_ASSERT_EQUAL(( typeid( OUStringConcat OUString, OUString )), typeid( OUString( foo ) + OUString( bar ))); CPPUNIT_ASSERT_EQUAL( OUString( foobar ), OUString( OUString( foo ) + bar )); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] .: sal/inc sal/qa
sal/inc/rtl/ustrbuf.hxx |2 +- sal/qa/rtl/strings/test_oustring_stringliterals.cxx |1 - 2 files changed, 1 insertion(+), 2 deletions(-) New commits: commit 10cecb81dbd897aaea5188c9249770877ac20771 Author: Norbert Thiebaud nthieb...@gmail.com Date: Fri Nov 30 20:24:18 2012 -0600 OUStringBuffer constructor from OUStringBuffer should use const arg Change-Id: I9f9e072c0a7ebde2de9be811f2378143b2b7abc6 Reviewed-on: https://gerrit.libreoffice.org/1209 Reviewed-by: LuboÅ¡ LuÅák l.lu...@suse.cz Tested-by: LuboÅ¡ LuÅák l.lu...@suse.cz diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx index d8db905..6338dd1 100644 --- a/sal/inc/rtl/ustrbuf.hxx +++ b/sal/inc/rtl/ustrbuf.hxx @@ -409,7 +409,7 @@ public: @since LibreOffice 4.0 */ -OUStringBuffer append(OUStringBuffer str) +OUStringBuffer append(const OUStringBuffer str) { if(str.getLength() 0) { diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx index e02bd93..09b55c6 100644 --- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx +++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx @@ -181,7 +181,6 @@ void test::oustring::StringLiterals::checkBuffer() buf.insert( 3, baz ); CPPUNIT_ASSERT_EQUAL( rtl::OUString( foobazbar ), buf.toString()); char d[] = d; -CPPUNIT_ASSERT( !VALID_CONVERSION( buf.append( d ))); CPPUNIT_ASSERT( !VALID_CONVERSION( buf.insert( 0, d ))); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] .: sal/inc sal/qa
sal/inc/rtl/string.hxx |1 + sal/qa/rtl/strings/test_strings_replace.cxx |3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) New commits: commit 4c4a95946b5c067f8e1ebdd3589f282380cc430f Author: Stephan Bergmann sberg...@redhat.com Date: Wed Nov 14 12:26:08 2012 +0100 Include clean-up Change-Id: Ice3b97269640c0d739e5b4f4b27a0e07fc854f9f diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index e45b837..a2aacb2 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -32,6 +32,7 @@ #include sal/config.h #include cassert +#include ostream #include osl/diagnose.h #include rtl/memory.h diff --git a/sal/qa/rtl/strings/test_strings_replace.cxx b/sal/qa/rtl/strings/test_strings_replace.cxx index a46245f..101dc67 100644 --- a/sal/qa/rtl/strings/test_strings_replace.cxx +++ b/sal/qa/rtl/strings/test_strings_replace.cxx @@ -26,7 +26,8 @@ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable * instead of those above. */ -#include ostream + +#include sal/config.h #include sal/types.h #include cppunit/TestAssert.h ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] .: sal/inc sal/qa sdext/source unodevtools/source
sal/inc/rtl/string.hxx | 14 +++ sal/qa/rtl/strings/test_strings_replace.cxx | 12 -- sdext/source/pdfimport/test/tests.cxx | 10 -- unodevtools/source/skeletonmaker/cppcompskeleton.cxx|1 unodevtools/source/skeletonmaker/cpptypemaker.cxx |1 unodevtools/source/skeletonmaker/javacompskeleton.cxx |1 unodevtools/source/skeletonmaker/javatypemaker.cxx |1 unodevtools/source/skeletonmaker/ostringostreaminserter.hxx | 49 unodevtools/source/skeletonmaker/skeletoncommon.cxx |1 unodevtools/source/skeletonmaker/skeletonmaker.cxx |1 10 files changed, 14 insertions(+), 77 deletions(-) New commits: commit 26364f4fd346c36f2c3ba4c2228d62de845fe13e Author: Miklos Vajna vmik...@suse.cz Date: Sat Nov 10 10:48:15 2012 +0100 deduplicate OString std::basic_ostream operators I wanted to add one, based on OUString one, and Stephan on IRC agreed it's a good idea. Then it turned out we already had it in sal unit tests, sdext and unodevtools as well. Get rid of all these, and have a single implementation in string.hxx, so it can be used everywhere. Change-Id: Ibb820f20a138d055fd87036253c627fb862a31fe diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index a135d4e..e45b837 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -1479,6 +1479,20 @@ struct OStringHash /* === */ +/** +Support for rtl::OString in std::ostream (and thus in +CPPUNIT_ASSERT or SAL_INFO macros, for example). + +@since LibreOffice 3.7 + */ +template typename charT, typename traits std::basic_ostreamcharT, traits +operator ( +std::basic_ostreamcharT, traits stream, rtl::OString const string) +{ +return stream string.getStr(); +// best effort; potentially loses data due to embedded null characters +} + } /* Namespace */ #ifdef RTL_USING diff --git a/sal/qa/rtl/strings/test_strings_replace.cxx b/sal/qa/rtl/strings/test_strings_replace.cxx index 5e1b0cf..a46245f 100644 --- a/sal/qa/rtl/strings/test_strings_replace.cxx +++ b/sal/qa/rtl/strings/test_strings_replace.cxx @@ -37,18 +37,6 @@ #include rtl/ustring.h #include rtl/ustring.hxx -namespace rtl { - -template typename charT, typename traits std::basic_ostreamcharT, traits -operator ( -std::basic_ostreamcharT, traits stream, rtl::OString const string) -{ -return stream string.getStr(); -// best effort; potentially loses data due to embedded null characters -} - -} - namespace { class Test: public CppUnit::TestFixture { diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index a452ba0..5475619 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -72,16 +72,6 @@ using namespace ::pdfparse; using namespace ::pdfi; using namespace ::com::sun::star; -namespace rtl -{ -template typename charT, typename traits std::basic_ostreamcharT, traits -operator ( -std::basic_ostreamcharT, traits stream, rtl::OString const string) -{ -return stream string.getStr(); -} -} - namespace { diff --git a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx index f274456..21dec5f 100644 --- a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx +++ b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx @@ -19,7 +19,6 @@ #include codemaker/commoncpp.hxx -#include ostringostreaminserter.hxx #include skeletoncommon.hxx #include skeletoncpp.hxx diff --git a/unodevtools/source/skeletonmaker/cpptypemaker.cxx b/unodevtools/source/skeletonmaker/cpptypemaker.cxx index 61f91d3..b66a049 100644 --- a/unodevtools/source/skeletonmaker/cpptypemaker.cxx +++ b/unodevtools/source/skeletonmaker/cpptypemaker.cxx @@ -19,7 +19,6 @@ #include codemaker/commoncpp.hxx -#include ostringostreaminserter.hxx #include skeletoncommon.hxx #include skeletoncpp.hxx diff --git a/unodevtools/source/skeletonmaker/javacompskeleton.cxx b/unodevtools/source/skeletonmaker/javacompskeleton.cxx index 4f09fc7..772a55a 100644 --- a/unodevtools/source/skeletonmaker/javacompskeleton.cxx +++ b/unodevtools/source/skeletonmaker/javacompskeleton.cxx @@ -19,7 +19,6 @@ #include codemaker/commonjava.hxx -#include ostringostreaminserter.hxx #include skeletoncommon.hxx #include skeletonjava.hxx diff --git a/unodevtools/source/skeletonmaker/javatypemaker.cxx b/unodevtools/source/skeletonmaker/javatypemaker.cxx index c60f621..96870f5 100644 --- a/unodevtools/source/skeletonmaker/javatypemaker.cxx +++ b/unodevtools/source/skeletonmaker/javatypemaker.cxx @@ -19,7 +19,6 @@ #include codemaker/commonjava.hxx -#include ostringostreaminserter.hxx #include skeletoncommon.hxx
[Libreoffice-commits] .: sal/inc sal/qa sal/rtl
sal/inc/rtl/strbuf.hxx | 54 +++ sal/inc/rtl/string.h|3 sal/inc/rtl/string.hxx |4 - sal/inc/rtl/ustrbuf.hxx | 69 sal/inc/rtl/ustring.h | 15 +--- sal/inc/rtl/ustring.hxx | 12 +-- sal/qa/rtl/strings/test_ostring_stringliterals.cxx |6 + sal/qa/rtl/strings/test_oustring_stringliterals.cxx | 21 +++--- sal/rtl/source/strtmpl.cxx | 11 ++- 9 files changed, 162 insertions(+), 33 deletions(-) New commits: commit 066dbfd1970b8ea58ba16b07b2a57f61c0cb8e36 Author: LuboÅ¡ LuÅák l.lu...@suse.cz Date: Fri Apr 6 13:45:47 2012 +0200 string literal O(U)StringBuffer ctors too, after all diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx index 122eb4b..4500cf0 100644 --- a/sal/inc/rtl/strbuf.hxx +++ b/sal/inc/rtl/strbuf.hxx @@ -155,6 +155,60 @@ public: } /** +@overload +@since LibreOffice 3.6 + */ +#ifdef HAVE_SFINAE_ANONYMOUS_BROKEN // see the OString ctors +OStringBuffer( const char* value ) +: pData(NULL) +{ +sal_Int32 length = rtl_str_getLength( value ); +nCapacity = length + 16; +rtl_stringbuffer_newFromStr_WithLength( pData, value, length ); +} +#else +template typename T +OStringBuffer( const T value, typename internal::CharPtrDetector T, internal::Dummy ::Type = internal::Dummy()) +: pData(NULL) +{ +sal_Int32 length = rtl_str_getLength( value ); +nCapacity = length + 16; +rtl_stringbuffer_newFromStr_WithLength( pData, value, length ); +} + +template typename T +OStringBuffer( T value, typename internal::NonConstCharArrayDetector T, internal::Dummy ::Type = internal::Dummy()) +: pData(NULL) +{ +sal_Int32 length = rtl_str_getLength( value ); +nCapacity = length + 16; +rtl_stringbuffer_newFromStr_WithLength( pData, value, length ); +} + +/** + Constructs a string buffer so that it represents the same +sequence of characters as the string literal. + + If there are any embedded \0's in the string literal, the result is undefined. + Use the overload that explicitly accepts length. + + @since LibreOffice 3.6 + + @paramliteral a string literal +*/ +template typename T +OStringBuffer( T literal, typename internal::ConstCharArrayDetector T, internal::Dummy ::Type = internal::Dummy()) +: pData(NULL) +, nCapacity( internal::ConstCharArrayDetector T, void ::size - 1 + 16 ) +{ +rtl_string_newFromLiteral( pData, literal, internal::ConstCharArrayDetector T, void ::size - 1, 16 ); +#ifdef RTL_STRING_UNITTEST +rtl_string_unittest_const_literal = true; +#endif +} +#endif // HAVE_SFINAE_ANONYMOUS_BROKEN + +/** Constructs a string buffer so that it represents the same sequence of characters as the string argument. diff --git a/sal/inc/rtl/string.h b/sal/inc/rtl/string.h index f695c12..f326abe 100644 --- a/sal/inc/rtl/string.h +++ b/sal/inc/rtl/string.h @@ -888,8 +888,9 @@ SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromStr_WithLength( rtl_String ** newS /** @internal + @since LibreOffice 3.6 */ -SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromLiteral( rtl_String ** newStr, const sal_Char * value, sal_Int32 len ) SAL_THROW_EXTERN_C(); +SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromLiteral( rtl_String ** newStr, const sal_Char * value, sal_Int32 len, sal_Int32 allocExtra ) SAL_THROW_EXTERN_C(); /** Assign a new value to a string. diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 0f6246b..9791a8c 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -206,7 +206,7 @@ public: OString( T literal, typename internal::ConstCharArrayDetector T, internal::Dummy ::Type = internal::Dummy() ) SAL_THROW(()) { pData = 0; -rtl_string_newFromLiteral( pData, literal, internal::ConstCharArrayDetector T, void ::size - 1 ); +rtl_string_newFromLiteral( pData, literal, internal::ConstCharArrayDetector T, void ::size - 1, 0 ); #ifdef RTL_STRING_UNITTEST rtl_string_unittest_const_literal = true; #endif @@ -285,7 +285,7 @@ public: typename internal::ConstCharArrayDetector T, OString ::Type operator=( T literal ) SAL_THROW(()) { RTL_STRING_CONST_FUNCTION -rtl_string_newFromLiteral( pData, literal, internal::ConstCharArrayDetector T, void ::size - 1 ); +rtl_string_newFromLiteral( pData, literal, internal::ConstCharArrayDetector T, void ::size - 1, 0 ); return *this; } diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx index 02a507c..17deadd 100644 --- a/sal/inc/rtl/ustrbuf.hxx +++ b/sal/inc/rtl/ustrbuf.hxx @@ -149,6 +149,75 @@
[Libreoffice-commits] .: sal/inc sal/qa sw/source
sal/inc/rtl/stringutils.hxx|9 + sal/qa/rtl/strings/test_ostring_stringliterals.cxx | 19 --- sw/source/filter/ww8/rtfexport.cxx |4 ++-- sw/source/filter/ww8/rtfexport.hxx |4 ++-- 4 files changed, 29 insertions(+), 7 deletions(-) New commits: commit 8aa60b51a9e48b33ba6f0cb27132c6a415de2358 Author: LuboÅ¡ LuÅák l.lu...@suse.cz Date: Thu Mar 29 11:03:47 2012 +0200 (const) char[] (i.e. size unknown) cannot be used with O(U)String msvc can't handle the necessary template overload (and maybe it's right, I'm not sure) diff --git a/sal/inc/rtl/stringutils.hxx b/sal/inc/rtl/stringutils.hxx index 19c1bf4..3ed36a7 100644 --- a/sal/inc/rtl/stringutils.hxx +++ b/sal/inc/rtl/stringutils.hxx @@ -65,6 +65,12 @@ There are 2 cases: cast to const char*. Additionally (non-const) char[N] needs to be handled, but with the reference being const, it would also match const char[N], so another overload with a reference to non-const and NonConstCharArrayDetector are used to ensure the function is called only with (non-const) char[N]. +Additionally, char[] and const char[] (i.e. size unknown) are rather tricky. Their usage with 'T' would +mean it would be 'char()[]', which seems to be invalid. But gcc and clang somehow manage when it is +a template. while msvc complains about no conversion from char[] to char[1]. And the reference cannot +be avoided, because 'const char[]' as argument type would match also 'const char[N]' +So char[] and const char[] should always be used with their contents specified (which automatically +turns them into char[N] or const char[N]), or char* and const char* should be used. */ struct Dummy {}; template typename T1, typename T2 @@ -91,6 +97,8 @@ struct NonConstCharArrayDetector char[ N ], T { typedef T Type; }; +#ifdef RTL_STRING_UNITTEST +// never use, until all compilers handle this template typename T struct NonConstCharArrayDetector char[], T { @@ -101,6 +109,7 @@ struct NonConstCharArrayDetector const char[], T { typedef T Type; }; +#endif template typename T1, typename T2 struct ConstCharArrayDetector diff --git a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx index 0d5036a..d7e3cf5 100644 --- a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx +++ b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx @@ -66,6 +66,9 @@ private: void testcall( const char str[] ); +static const char bad5[]; +static char bad6[]; + CPPUNIT_TEST_SUITE(StringLiterals); CPPUNIT_TEST(checkCtors); CPPUNIT_TEST(checkUsage); @@ -100,13 +103,20 @@ void test::ostring::StringLiterals::checkCtors() const char* bad4[] = { test1 }; CPPUNIT_ASSERT( !CONST_CTOR_USED( bad4[ 0 ] )); testcall( good1 ); +#ifndef _MSC_VER +// this is actually not supposed to work (see discussion in stringutils.hxx), +// but gcc and clang somehow manage, so keep it used, just in case some other problem +// shows up somewhen in the future +CPPUNIT_ASSERT( !CONST_CTOR_USED( bad5 )); // size is not known here +CPPUNIT_ASSERT( !CONST_CTOR_USED( bad6 )); +#endif // This one is technically broken, since the first element is 6 characters test\0\0, // but there does not appear a way to detect this by compile time (runtime will complain). // RTL_CONSTASCII_USTRINGPARAM() has the same flaw. -const char bad5[][ 6 ] = { test, test2 }; -CPPUNIT_ASSERT( CONST_CTOR_USED( bad5[ 0 ] )); -CPPUNIT_ASSERT( CONST_CTOR_USED( bad5[ 1 ] )); +const char bad7[][ 6 ] = { test, test2 }; +CPPUNIT_ASSERT( CONST_CTOR_USED( bad7[ 0 ] )); +CPPUNIT_ASSERT( CONST_CTOR_USED( bad7[ 1 ] )); // Check that contents are correct and equal to the case when const char* ctor is used. CPPUNIT_ASSERT( rtl::OString( (const char*) ) == rtl::OString( )); @@ -128,6 +138,9 @@ void test::ostring::StringLiterals::checkCtors() #endif } +const char test::ostring::StringLiterals::bad5[] = test; +char test::ostring::StringLiterals::bad6[] = test; + void test::ostring::StringLiterals::testcall( const char str[] ) { #ifndef _MSC_VER diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index dda8b81..00b8e18 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -79,10 +79,10 @@ using rtl::OUStringBuffer; using sw::mark::IMark; -#if defined(UNX) +#if defined(UNX22) const sal_Char RtfExport::sNewLine = '\012'; #else -const sal_Char RtfExport::sNewLine[] = \015\012; +const sal_Char* const RtfExport::sNewLine = \015\012; #endif // the default text encoding for the export, if it doesn't fit unicode will diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx index 3759f31..9d395de 100644 --- a/sw/source/filter/ww8/rtfexport.hxx +++ b/sw/source/filter/ww8/rtfexport.hxx @@
[Libreoffice-commits] .: sal/inc sal/qa
sal/inc/rtl/string.hxx |7 +++ sal/qa/rtl/strings/test_ostring_stringliterals.cxx |2 ++ 2 files changed, 9 insertions(+) New commits: commit 86a1e6de4fc3af897271bc5f7f04506261d4f286 Author: LuboÅ¡ LuÅák l.lu...@suse.cz Date: Wed Mar 28 17:37:19 2012 +0200 SFINAE workarounds for gcc-4.0.1 diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 39414e6..68f41bd 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -551,6 +551,12 @@ public: @return sal_True if the strings are equal; sal_False, otherwise. */ +#ifdef HAVE_SFINAE_ANONYMOUS_BROKEN +sal_Bool equalsIgnoreAsciiCase( const sal_Char * asciiStr ) const SAL_THROW(()) +{ +return rtl_str_compareIgnoreAsciiCase( pData-buffer, asciiStr ) == 0; +} +#else template typename T typename internal::CharPtrDetector T, bool ::Type equalsIgnoreAsciiCase( const T asciiStr ) const SAL_THROW(()) { @@ -577,6 +583,7 @@ public: return rtl_str_compareIgnoreAsciiCase_WithLength( pData-buffer, pData-length, literal, internal::ConstCharArrayDetector T, void ::size - 1 ) == 0; } +#endif /** Perform a ASCII lowercase comparison of two strings. diff --git a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx index 4af152c..930b038 100644 --- a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx +++ b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx @@ -152,9 +152,11 @@ void test::ostring::StringLiterals::checkUsage() rtl_string_unittest_const_literal_function = false; CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = foo ); CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true ); +#ifndef HAVE_SFINAE_ANONYMOUS_BROKEN rtl_string_unittest_const_literal_function = false; CPPUNIT_ASSERT( FoO.equalsIgnoreAsciiCase( fOo )); CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true ); +#endif rtl_string_unittest_const_literal_function = false; CPPUNIT_ASSERT( foobarfoo.match( bar, 3 )); CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true ); ___ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] .: sal/inc sal/qa
sal/inc/rtl/strbuf.hxx | 14 ++ sal/qa/rtl/strings/test_ostring_stringliterals.cxx |4 2 files changed, 18 insertions(+) New commits: commit c9167bac18e1cca061d91f65d2dc91b9d09ef587 Author: LuboÅ¡ LuÅák l.lu...@suse.cz Date: Wed Mar 28 23:38:58 2012 +0200 gcc-4.0.1 SFINAE workarounds diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx index 54428d3..122eb4b 100644 --- a/sal/inc/rtl/strbuf.hxx +++ b/sal/inc/rtl/strbuf.hxx @@ -373,6 +373,12 @@ public: @param str the characters to be appended. @return this string buffer. */ +#ifdef HAVE_SFINAE_ANONYMOUS_BROKEN +OStringBuffer append( const sal_Char * str ) +{ +return append( str, rtl_str_getLength( str ) ); +} +#else template typename T typename internal::CharPtrDetector T, OStringBuffer ::Type append( const T str ) { @@ -397,6 +403,7 @@ public: rtl_stringbuffer_insert( pData, nCapacity, getLength(), literal, internal::ConstCharArrayDetector T, void ::size - 1 ); return *this; } +#endif /** Appends the string representation of the codechar/code array @@ -555,6 +562,12 @@ public: @param str a character array. @return this string buffer. */ +#ifdef HAVE_SFINAE_ANONYMOUS_BROKEN +OStringBuffer insert( sal_Int32 offset, const sal_Char * str ) +{ +return insert( offset, str, rtl_str_getLength( str ) ); +} +#else template typename T typename internal::CharPtrDetector T, OStringBuffer ::Type insert( sal_Int32 offset, const T str ) { @@ -579,6 +592,7 @@ public: rtl_stringbuffer_insert( pData, nCapacity, offset, literal, internal::ConstCharArrayDetector T, void ::size - 1 ); return *this; } +#endif /** Inserts the string representation of the codechar/code array diff --git a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx index 3f2ed84..494c1da 100644 --- a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx +++ b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx @@ -257,6 +257,7 @@ void test::ostring::StringLiterals::checkNonConstUsage() void test::ostring::StringLiterals::checkBuffer() { rtl::OStringBuffer buf; +#ifndef HAVE_SFINAE_ANONYMOUS_BROKEN rtl_string_unittest_const_literal_function = false; buf.append( foo ); CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true ); @@ -269,6 +270,9 @@ void test::ostring::StringLiterals::checkBuffer() buf.insert( 3, baz ); CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true ); CPPUNIT_ASSERT_EQUAL( buf.toString(), rtl::OString( foobazbar )); +#else +buf.append( foobazbar ); +#endif rtl::OString foobazbard( foobazbard ); rtl::OString foodbazbard( foodbazbard ); ___ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits