connectivity/source/drivers/postgresql/pq_xkeys.cxx: compareToAscii -> operator== sound?

Stephan Bergmann sbergman at redhat.com
Tue Mar 19 10:11:39 PDT 2013


On 03/19/2013 05:59 PM, Michael Meeks wrote:
> On Tue, 2013-03-19 at 15:13 +0100, Stephan Bergmann wrote:
>>> -    if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "r" ) ) == 0 )
>>> +    if( rule == "r" )
> ...
>> smells like an incorrect conversion from
>> rtl::OUString::compareToAscii(asciiStr,maxLength) to operator== rather
>> than rtl::OUString::startsWith, but then again, given the preceeding
>
> 	So I've fallen for this as well - if indeed compareToAscii just
> compares the first few characters that are in asciiStr - then the
> documentation in the header:
>
>      /**
>        Compares two strings.
>
>        The comparison is based on the numeric value of each character in
>        the strings and return a value indicating their relationship.
> ...
>        @param  asciiStr      the 8-Bit ASCII character string 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_Int32 compareToAscii( const sal_Char* asciiStr ) const SAL_THROW(())
>
> 	I took 'both strings are equal' at face value ;-)
>
> 	Does it really not do that ?

No.  Note that there is another overload of compareToAscii with two 
parameters, with is the subject here.

Stephan


More information about the LibreOffice mailing list