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

Michael Meeks michael.meeks at suse.com
Tue Mar 19 09:59:22 PDT 2013


Hi there,

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 ?

	Anyhow - thanks for chasing this Stephan - no doubt I've made the same
mistake elsewhere.

	ATB,

		Michael.

-- 
michael.meeks at suse.com  <><, Pseudo Engineer, itinerant idiot



More information about the LibreOffice mailing list