summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-03-20 12:04:28 (GMT)
committerStephan Bergmann <sbergman@redhat.com>2013-03-20 12:05:35 (GMT)
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 ae0af9e..4d9650e 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -732,12 +732,19 @@ public:
127. The ASCII string must be NULL-terminated.
This function can't be used for language specific sorting.
+ @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.
@param maxLength the maximum count of characters to be compared.
@return 0 - if both strings are equal
< 0 - if this string is less than the string argument
> 0 - if this string is greater than the string argument
*/
+ 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(())
{
return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
diff --git a/sal/qa/rtl/strings/test_oustring_compare.cxx b/sal/qa/rtl/strings/test_oustring_compare.cxx
index e3ad8dd..7f56546 100644
--- a/sal/qa/rtl/strings/test_oustring_compare.cxx
+++ b/sal/qa/rtl/strings/test_oustring_compare.cxx
@@ -30,13 +30,10 @@ class Compare: public CppUnit::TestFixture
private:
void equalsIgnoreAsciiCaseAscii();
- void compareToAscii();
-
void compareToIgnoreAsciiCase();
CPPUNIT_TEST_SUITE(Compare);
CPPUNIT_TEST(equalsIgnoreAsciiCaseAscii);
-CPPUNIT_TEST(compareToAscii);
CPPUNIT_TEST(compareToIgnoreAsciiCase);
CPPUNIT_TEST_SUITE_END();
};
@@ -63,16 +60,6 @@ void test::oustring::Compare::equalsIgnoreAsciiCaseAscii()
equalsIgnoreAsciiCaseAscii("abcd"));
}
-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()
{
CPPUNIT_ASSERT_EQUAL(