[Libreoffice-commits] core.git: use startsWith() instead of compareToAscii()
Stephan Bergmann
sbergman at redhat.com
Mon Mar 11 04:05:40 PDT 2013
On 03/11/2013 11:10 AM, Thomas Arnhold wrote:
> commit 937b63af3322f7f8b5e869b2c7431a2deaec3113
> Author: Thomas Arnhold <thomas at arnhold.org>
> Date: Sat Mar 9 22:47:20 2013 +0100
>
> use startsWith() instead of compareToAscii()
>
> brain damage...
>
> Change-Id: I4dc63c7346f724eded9ac7b82cda25c2bb60beff
[...]
> diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx
> index 3f2a96b..d58c8f5 100644
> --- a/connectivity/source/drivers/hsqldb/HDriver.cxx
> +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx
> @@ -399,7 +399,7 @@ namespace connectivity
> {
> sal_Bool bEnabled = sal_False;
> OSL_VERIFY_EQUALS( jfw_getEnabled( &bEnabled ), JFW_E_NONE, "error in jfw_getEnabled" );
> - return bEnabled && url.compareToAscii("sdbc:embedded:hsqldb",sizeof("sdbc:embedded:hsqldb")) == 0;
> + return bEnabled && url.startsWith("sdbc:embedded:hsqldb");
Note that sizeof("...") == strlen("...") + 1, so the call to
compareToAscii included the terminating NUL of the string literal in the
comparison, so would never have returned zero (unless url contained
embedded NUL characters, which is unlikely).
Not sure about the details of that sdbc URL scheme, whether what one
wants there is url.startsWith("sdbc:embedded:hsqldb") or
url.startsWith("sdbc:embedded:hsqldb:") or url=="sdbc:embedded:hsqld"
(and, while we are at it, at least for the initial "sdbc" part, URI
syntax would mandated case-insensitive comparison anyway, unless the
given url is known to be normalized to lowercase), but maybe Lionel
knows more.
Stephan
More information about the LibreOffice
mailing list