summaryrefslogtreecommitdiff
path: root/include/rtl/ustrbuf.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-06-25 10:15:34 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-06-25 12:38:32 +0200
commit8007417c318140d74b87ec5abcf835f4a2ba9682 (patch)
tree0ea40500853d78008c0d1aa1083a0e415e457e9a /include/rtl/ustrbuf.hxx
parent707ef3171a096787b2f7a4c221e60962f05e7d01 (diff)
Revert "Revert "Generalize OUStringLiteral1""
This reverts commit 5cba714b4d03ed54debf71534ad8c8edc383a01e, now including a workaround for <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53658> "internal compiler error -- segmentation fault." Change-Id: I31f6d9ddcb0b884134703df2b9dc1800ba0a84be
Diffstat (limited to 'include/rtl/ustrbuf.hxx')
-rw-r--r--include/rtl/ustrbuf.hxx49
1 files changed, 32 insertions, 17 deletions
diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx
index 04ac8a6c00f4..fe64ebe48280 100644
--- a/include/rtl/ustrbuf.hxx
+++ b/include/rtl/ustrbuf.hxx
@@ -132,10 +132,14 @@ public:
template< typename T >
OUStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
: pData(NULL)
- , nCapacity( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
- {
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- rtl_uString_newFromLiteral( &pData, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, 16 );
+ , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
+ {
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ rtl_uString_newFromLiteral(
+ &pData,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length, 16);
#ifdef RTL_STRING_UNITTEST
rtl_string_unittest_const_literal = true;
#endif
@@ -470,9 +474,12 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type append( T& literal )
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ rtl_uStringbuffer_insert_ascii(
+ &pData, &nCapacity, getLength(),
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
return *this;
}
@@ -813,9 +820,12 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, offset, literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ rtl_uStringbuffer_insert_ascii(
+ &pData, &nCapacity, offset,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
return *this;
}
@@ -1199,11 +1209,13 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
- pData->buffer + fromIndex, pData->length - fromIndex, literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
- return ret < 0 ? ret : ret + fromIndex;
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
+ pData->buffer + fromIndex, pData->length - fromIndex,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
+ return n < 0 ? n : n + fromIndex;
}
/**
@@ -1263,9 +1275,12 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf( T& literal ) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
return rtl_ustr_lastIndexOfAscii_WithLength(
- pData->buffer, pData->length, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
+ pData->buffer, pData->length,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
}
/**