=== modified file 'test/my_basics.c' --- test/my_basics.c 2008-08-22 22:12:25 +0000 +++ test/my_basics.c 2008-09-16 02:58:13 +0000 @@ -909,6 +909,42 @@ } +/* + Bug #39085: MyODBC 5.1 fails to connect if connection string + parameters have preceding space +*/ +DECLARE_TEST(t_bug39085) +{ + SQLCHAR buff[512]; + SQLHENV henv1; + SQLHDBC hdbc1; + SQLHSTMT hstmt1; + SQLCHAR conn[MAX_NAME_LEN]; + + + /* Connect with the space and tab symbols before server parameter */ + sprintf((char *)conn, "DRIVER=%s;SERVER= %s;" \ + "UID=%s;PASSWORD=%s;DATABASE=%s ", mydriver, myserver, myuid, mypwd, mydb); + if (mysock != NULL) + { + strcat((char *)conn, ";SOCKET="); + strcat((char *)conn, (char *)mysock); + } + if (myport) + { + char pbuff[20]; + sprintf(pbuff, ";PORT=%d", myport); + strcat((char *)conn, pbuff); + } + + /* We only need to check that the connection has been established */ + is(mydrvconnect(&henv1, &hdbc1, &hstmt1, conn) == OK); + + free_basic_handles(&henv1, &hdbc1, &hstmt1); + return OK; +} + + BEGIN_TESTS ADD_TEST(my_basics) ADD_TEST(t_max_select) @@ -934,6 +970,7 @@ ADD_TEST(t_bug32727) ADD_TEST(t_bug28820) ADD_TEST(t_bug31959) + ADD_TEST(t_bug39085) END_TESTS === modified file 'util/installer.c' --- util/installer.c 2008-08-09 01:07:56 +0000 +++ util/installer.c 2008-09-16 02:49:37 +0000 @@ -598,7 +598,10 @@ } if (val && *val) + { + val= sqlwcharignorespaces(val, &charcount); *attr= sqlwchardup(val, charcount); + } else *attr= NULL; return *attr || 0; === modified file 'util/stringutil.c' --- util/stringutil.c 2008-09-02 18:53:50 +0000 +++ util/stringutil.c 2008-09-16 02:55:30 +0000 @@ -647,3 +647,21 @@ return dest; } + +/* + * Ignore space symbols in SQLWCHAR string. + * + * @return Position of char next after the space + */ +SQLWCHAR *sqlwcharignorespaces(const SQLWCHAR *wstr, size_t *charcount) +{ + SQLWCHAR *end_pos= (SQLWCHAR*)(wstr + *charcount - 1); + while(((*wstr == (SQLWCHAR)' ') || + (*wstr == (SQLWCHAR)'\t')) && *wstr++) + (*charcount)--; + + while(((*end_pos == (SQLWCHAR)' ') || + (*end_pos == (SQLWCHAR)'\t')) && *end_pos--) + (*charcount)--; + return wstr; +}