The attached patch is not in logerrit (I've yet to set that up), and there's an error in it so I'm hoping someone can help. It does a TODO in the file, but I can't get my argument casting right - in the original code, matchIgnoreAsciiCaseAsciiL wraps its argument in RTL_CONSTASCII_STRINGPARAM. This is defined in sal/inc/rtl/string.h and passes both the string and its length. So me removing it is obviously a mistake, but it's got some integrity checking in there and I just can't get it to pass that.
Cheers, Wol
>From ee4544575c7bff0727e978a0d435b31e69bd6c2d Mon Sep 17 00:00:00 2001 From: Wol <anth...@youngman.org.uk> Date: Tue, 16 Apr 2013 13:30:30 +0100 Subject: [PATCH] Rewrite as a static table of keywords and loop over these keywords This patch creates a static list of keywords which can easily be added to. It currently contains a compile error - the call the matchIgnoreAsciiCaseAsciiL fails. It also needs testing as I don't have PostgreSQL on this machine. Change-Id: Ib581b3e834a57e0dfa9d139bcb4ae7a0a52a5472 --- .../source/drivers/postgresql/pq_connection.cxx | 58 ++++++++++------------ 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx index 4bc15e4..b17ad9f 100644 --- a/connectivity/source/drivers/postgresql/pq_connection.cxx +++ b/connectivity/source/drivers/postgresql/pq_connection.cxx @@ -482,44 +482,31 @@ static void properties2arrays( const Sequence< PropertyValue > & args, // I.e. they are prefiltered to have only relevant ones? // Else, at least support all keywords from // http://www.postgresql.org/docs/9.0/interactive/libpq-connect.html + + static const char* keyword_list[] = { + "password", + "user", + "port", + "dbname", + "connect_timeout", + "options", + "requiressl" + }; + for( int i = 0; i < args.getLength() ; ++i ) { - bool append = true; - // TODO: rewrite this as a static table of keywords, and a loop over these keywords. - if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "password" ) ) ) - { - keywords.push_back( "password", SAL_NO_ACQUIRE ); - } - else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "user" ) ) ) - { - keywords.push_back( "user", SAL_NO_ACQUIRE ); - } - else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "port" ) ) ) - { - keywords.push_back( "port", SAL_NO_ACQUIRE ); - } - else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "dbname" ) ) ) - { - keywords.push_back( "dbname", SAL_NO_ACQUIRE ); - } - else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "connect_timeout" ) ) ) - { - keywords.push_back( "connect_timeout", SAL_NO_ACQUIRE ); - } - else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "options" ) ) ) - { - keywords.push_back( "options", SAL_NO_ACQUIRE ); - } - else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "requiressl" ) ) ) - { - keywords.push_back( "requiressl", SAL_NO_ACQUIRE ); - } - else + bool append = false; + for( int j = 0; j < (int) ( sizeof( keyword_list ) / sizeof( char * )); j++) { + if( args[i].Name.matchIgnoreAsciiCaseAsciiL( keyword_list[j] )) + { + keywords.push_back( keyword_list[j], SAL_NO_ACQUIRE ); + append = true; + break; + } append = false; - // ignore for now - OSL_TRACE("sdbc-postgresql: unknown argument '%s'", OUStringToOString( args[i].Name, RTL_TEXTENCODING_UTF8 ).getStr() ); } + if( append ) { OUString value; @@ -527,6 +514,11 @@ static void properties2arrays( const Sequence< PropertyValue > & args, char *v = strdup(OUStringToOString(value, enc).getStr()); values.push_back ( v ); } + else + { + // ignore for now + OSL_TRACE("sdbc-postgresql: unknown argument '%s'", OUStringToOString( args[i].Name, RTL_TEXTENCODING_UTF8 ).getStr() ); + } } } -- 1.8.1.5
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice