summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-03-20 13:04:28 +0100
committerStephan Bergmann <sbergman@redhat.com>2013-03-20 13:05:35 +0100
commit77c87c18697e19cb4606717af0e4b0e5ab2139bc (patch)
treedc6345e65a30c924e7c84487a7da7dfbf10a06eb
parent2d9ce9191da681e4fd9f1d08933ca5117c56601b (diff)
Deprecate confusing rtl::OUString::compareToAscii(asciiStr, maxLength)
Change-Id: I3a41036ec03cdaefea94b19dbedf59e5a5e37dc8
-rw-r--r--sal/inc/rtl/ustring.hxx7
-rw-r--r--sal/qa/rtl/strings/test_oustring_compare.cxx13
2 files changed, 7 insertions, 13 deletions
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index ae0af9eb8be4..4d9650e535c8 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -734,2 +734,7 @@ public:
+ @deprecated This is a confusing overload with unexpectedly different
+ semantics from the one-parameter form, so it is marked as deprecated.
+ Practically all uses compare the return value against zero and can thus
+ be replaced with uses of startsWith.
+
@param asciiStr the 8-Bit ASCII character string to be compared.
@@ -740,2 +745,4 @@ public:
*/
+ SAL_DEPRECATED(
+ "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const SAL_THROW(())
diff --git a/sal/qa/rtl/strings/test_oustring_compare.cxx b/sal/qa/rtl/strings/test_oustring_compare.cxx
index e3ad8dd9d4bf..7f56546df914 100644
--- a/sal/qa/rtl/strings/test_oustring_compare.cxx
+++ b/sal/qa/rtl/strings/test_oustring_compare.cxx
@@ -32,4 +32,2 @@ private:
- void compareToAscii();
-
void compareToIgnoreAsciiCase();
@@ -38,3 +36,2 @@ CPPUNIT_TEST_SUITE(Compare);
CPPUNIT_TEST(equalsIgnoreAsciiCaseAscii);
-CPPUNIT_TEST(compareToAscii);
CPPUNIT_TEST(compareToIgnoreAsciiCase);
@@ -65,12 +62,2 @@ void test::oustring::Compare::equalsIgnoreAsciiCaseAscii()
-void test::oustring::Compare::compareToAscii()
-{
- // The different overloads of compareToAscii exhibit potentially confusing
- // behavior:
- rtl::OUString abc("abc");
- CPPUNIT_ASSERT(abc.compareToAscii("a") > 0);
- CPPUNIT_ASSERT_EQUAL(
- sal_Int32(0), abc.compareToAscii(RTL_CONSTASCII_STRINGPARAM("a")));
-}
-
void test::oustring::Compare::compareToIgnoreAsciiCase()