[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sal/qa sal/rtl

Stephan Bergmann sbergman at redhat.com
Thu Jun 25 02:54:24 PDT 2015


 sal/qa/rtl/strings/test_strings_replace.cxx |   13 +++++++++++++
 sal/rtl/ustring.cxx                         |    4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)

New commits:
commit 24bc22fcb0550c3ebf74db3642ab32b8e818205c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Jun 25 08:52:08 2015 +0200

    Do not forget to actually set newStr to an empty string
    
    (cherry picked from commit f7a7a9dd84d1cd8b49d59e1fb1853ea7e9f40edf)
    Conflicts:
    	sal/qa/rtl/strings/test_strings_replace.cxx
    	sal/rtl/ustring.cxx
    (cherry picked from commit e36ca8d3c69d0c08ad28ceea278b05a0af81e102)
    Conflicts:
    	sal/qa/rtl/strings/test_strings_replace.cxx
    
    Change-Id: I745b09d8a248f08afdd3387f4cfcf69d71ec3c39
    Reviewed-on: https://gerrit.libreoffice.org/16465
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sal/qa/rtl/strings/test_strings_replace.cxx b/sal/qa/rtl/strings/test_strings_replace.cxx
index 2065078..d26c308 100644
--- a/sal/qa/rtl/strings/test_strings_replace.cxx
+++ b/sal/qa/rtl/strings/test_strings_replace.cxx
@@ -186,6 +186,10 @@ void Test::ustringReplaceFirstAsciiL() {
                  rtl::OUString("other"), &n)));
         CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n);
     }
+
+    CPPUNIT_ASSERT_EQUAL(
+        rtl::OUString(),
+        rtl::OUString("xa").replaceFirst("xa", rtl::OUString()));
 }
 
 void Test::ustringReplaceFirstAsciiLAsciiL() {
@@ -225,6 +229,9 @@ void Test::ustringReplaceFirstAsciiLAsciiL() {
              replaceFirst("bar", "other", &n)));
         CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n);
     }
+
+    CPPUNIT_ASSERT_EQUAL(
+        rtl::OUString(), rtl::OUString("xa").replaceFirst("xa", ""));
 }
 
 void Test::ustringReplaceAll() {
@@ -265,6 +272,9 @@ void Test::ustringReplaceAllAsciiL() {
         rtl::OUString("xaa").replaceAll(
             "xa",
             rtl::OUString("xx")));
+
+    CPPUNIT_ASSERT_EQUAL(
+        rtl::OUString(), rtl::OUString("xa").replaceAll("xa", rtl::OUString()));
 }
 
 void Test::ustringReplaceAllAsciiLAsciiL() {
@@ -282,6 +292,9 @@ void Test::ustringReplaceAllAsciiLAsciiL() {
         rtl::OUString("xxa"),
         (rtl::OUString("xaa").
          replaceAll("xa", "xx")));
+
+    CPPUNIT_ASSERT_EQUAL(
+        rtl::OUString(), rtl::OUString("xa").replaceAll("xa", ""));
 }
 
 }
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index 5f1c12a..2df10fc 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -1118,8 +1118,8 @@ void rtl_uString_newReplaceFirstAsciiL(
         }
         sal_Int32 n = str->length - fromLength + to->length;
         rtl_uString_acquire(str); // in case *newStr == str
+        rtl_uString_new_WithLength(newStr, n);
         if (n != 0) {
-            rtl_uString_new_WithLength(newStr, n);
             (*newStr)->length = n;
             assert(i >= 0 && i < str->length);
             memcpy(
@@ -1161,8 +1161,8 @@ void rtl_uString_newReplaceFirstAsciiLAsciiL(
         }
         sal_Int32 n = str->length - fromLength + toLength;
         rtl_uString_acquire(str); // in case *newStr == str
+        rtl_uString_new_WithLength(newStr, n);
         if (n != 0) {
-            rtl_uString_new_WithLength(newStr, n);
             (*newStr)->length = n;
             assert(i >= 0 && i < str->length);
             memcpy(


More information about the Libreoffice-commits mailing list