rtl::OUString::compareToAscii is dangerous

Stephan Bergmann sbergman at redhat.com
Wed Mar 20 06:07:47 PDT 2013


On 03/19/2013 06:37 PM, Stephan Bergmann wrote:
> On 03/19/2013 06:29 PM, Noel Grandin wrote:
>> On Tue, Mar 19, 2013 at 6:54 PM, Stephan Bergmann
>> <sbergman at redhat.com> wrote:
>>> * compareToAscii(char cosnt * asciiStr, sal_Int32 maxLength) does a
>>> shortened comparison of only up to maxLength characters of *this and the
>>> given asciiStr.
>>>
>>
>> Maybe this one should be renamed to something like "compareLeftToAscii" ?
>
> I was musing about marking it as
>
>    SAL_DEPRECATED_INTERNAL("use startsWith")
>
> but that would only apply for the cases where the return value is
> compared against zero, so dismissed it.
>
> But then again, there are hopefully no legitimate cases that do not
> compare the return value against zero anyway, so this might still be the
> most attractive approach.  I'll give it a try.

So I did (using SAL_DEPRECATED rather than SAL_DEPRECATED_INTERNAL): 
replaced lots of occurrences in 
0555481e50d7d8c1b59fb608a4e3eea1e39aeac9^..2d9ce9191da681e4fd9f1d08933ca5117c56601b, 
then enabled the deprecation in 
<http://cgit.freedesktop.org/libreoffice/core/commit/?id=77c87c18697e19cb4606717af0e4b0e5ab2139bc> 
"Deprecate confusing rtl::OUString::compareToAscii(asciiStr, maxLength)."

I apologize in advance for any remaining occurrences that my build 
didn't catch.  (Where is the gerrit tinderbox trigger when one needs them?)

Stephan


More information about the LibreOffice mailing list