Fix a make_string() bug.
authorHiroshi Inoue <inoue@tpf.co.jp>
Wed, 18 Oct 2006 15:34:34 +0000 (15:34 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Wed, 18 Oct 2006 15:34:34 +0000 (15:34 +0000)
Remove some compiler warnings.

bind.c
connection.c
dlg_specific.c
info.c
misc.c
version.h

diff --git a/bind.c b/bind.c
index 80f4c9dbf7b6bcfc30d36f40c66579e36b7fd4a2..8ebbd959d22b0c528d1c157e60bd7fc2b7526286 100644 (file)
--- a/bind.c
+++ b/bind.c
@@ -15,6 +15,7 @@
 
 /* #include <stdlib.h> */
 #include <string.h>
+#include <ctype.h>
 #include "bind.h"
 
 #include "environ.h"
index c023d217d4bb7e2a1c80259e194f8226f85875e0..b78c61b2aa29de3ca6cd7823d90cfab1f414a379 100644 (file)
@@ -105,7 +105,7 @@ PGAPI_Connect(
    RETCODE ret = SQL_SUCCESS;
    char    fchar;
 
-   mylog("%s: entering...\n", func);
+   mylog("%s: entering..cbDSN=%hi.\n", func, cbDSN);
 
    if (!conn)
    {
@@ -1241,6 +1241,8 @@ static char CC_initial_log(ConnectionClass *self, const char *func)
        return 0;
    }
 
+   mylog("%s: DSN = '%s', server = '%s', port = '%s', database = '%s', username = '%s', password='%s'\n", func, ci->dsn, ci->server, ci->port, ci->database, ci->username, ci->password ? "xxxxx" : "");
+
    if (ci->port[0] == '\0' ||
 #ifdef WIN32
        ci->server[0] == '\0' ||
@@ -1251,8 +1253,6 @@ static char CC_initial_log(ConnectionClass *self, const char *func)
        return 0;
    }
 
-   mylog("%s: DSN = '%s', server = '%s', port = '%s', database = '%s', username = '%s', password='%s'\n", func, ci->dsn, ci->server, ci->port, ci->database, ci->username, ci->password ? "xxxxx" : "");
-
    return 1;
 }
 
index 2824003f84184480a305fa9c483ab488fccebc2b..4a96717d90536842283ab99d0a408b7446c06c50 100644 (file)
@@ -904,7 +904,7 @@ writeDriverCommoninfo(const char *fileName, const char *sectionName,
    /*
     * Never update the onlyread from this module.
     */
-   if (ODBCINST_INI == fileName)
+   if (stricmp(ODBCINST_INI, fileName) == 0)
    {
        sprintf(tmp, "%d", comval->onlyread);
        SQLWritePrivateProfileString(sectionName, INI_READONLY, tmp,
@@ -1099,6 +1099,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
 {
    char        temp[256];
    GLOBAL_VALUES *comval;
+   BOOL    inst_position = (stricmp(filename, ODBCINST_INI) == 0);
 
    if (ci)
        comval = &(ci->drivers);
@@ -1114,7 +1115,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
        if (comval->fetch_max <= 0)
            comval->fetch_max = FETCH_MAX;
    }
-   else if (!ci)
+   else if (inst_position)
        comval->fetch_max = FETCH_MAX;
 
    /* Socket Buffersize is stored in driver section */
@@ -1122,7 +1123,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->socket_buffersize = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->socket_buffersize = SOCK_BUFFER_SIZE;
 
    /* Debug is stored in the driver section */
@@ -1130,7 +1131,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->debug = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->debug = DEFAULT_DEBUG;
 
    /* CommLog is stored in the driver section */
@@ -1138,7 +1139,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->commlog = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->commlog = DEFAULT_COMMLOG;
 
    if (!ci)
@@ -1148,7 +1149,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->disable_optimizer = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->disable_optimizer = DEFAULT_OPTIMIZER;
 
    /* KSQO is stored in the driver section only */
@@ -1156,7 +1157,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->ksqo = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->ksqo = DEFAULT_KSQO;
 
    /* Recognize Unique Index is stored in the driver section only */
@@ -1164,7 +1165,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->unique_index = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->unique_index = DEFAULT_UNIQUEINDEX;
 
 
@@ -1173,7 +1174,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->unknown_sizes = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->unknown_sizes = DEFAULT_UNKNOWNSIZES;
 
 
@@ -1182,7 +1183,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->lie = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->lie = DEFAULT_LIE;
 
    /* Parse statements */
@@ -1190,7 +1191,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->parse = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->parse = DEFAULT_PARSE;
 
    /* SQLCancel calls SQLFreeStmt in Driver Manager */
@@ -1198,7 +1199,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->cancel_as_freestmt = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->cancel_as_freestmt = DEFAULT_CANCELASFREESTMT;
 
    /* UseDeclareFetch is stored in the driver section only */
@@ -1206,7 +1207,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->use_declarefetch = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->use_declarefetch = DEFAULT_USEDECLAREFETCH;
 
    /* Max Varchar Size */
@@ -1214,7 +1215,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->max_varchar_size = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->max_varchar_size = MAX_VARCHAR_SIZE;
 
    /* Max TextField Size */
@@ -1222,7 +1223,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->max_longvarchar_size = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->max_longvarchar_size = TEXT_FIELD_SIZE;
 
    /* Text As LongVarchar  */
@@ -1230,7 +1231,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->text_as_longvarchar = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->text_as_longvarchar = DEFAULT_TEXTASLONGVARCHAR;
 
    /* Unknowns As LongVarchar  */
@@ -1238,7 +1239,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->unknowns_as_longvarchar = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->unknowns_as_longvarchar = DEFAULT_UNKNOWNSASLONGVARCHAR;
 
    /* Bools As Char */
@@ -1246,7 +1247,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (temp[0])
        comval->bools_as_char = atoi(temp);
-   else if (!ci)
+   else if (inst_position)
        comval->bools_as_char = DEFAULT_BOOLSASCHAR;
 
    /* Extra Systable prefixes */
@@ -1259,14 +1260,14 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
                               temp, sizeof(temp), filename);
    if (strcmp(temp, "@@@"))
        strcpy(comval->extra_systable_prefixes, temp);
-   else if (!ci)
+   else if (inst_position)
        strcpy(comval->extra_systable_prefixes, DEFAULT_EXTRASYSTABLEPREFIXES);
 
    mylog("globals.extra_systable_prefixes = '%s'\n", comval->extra_systable_prefixes);
 
 
    /* Dont allow override of an override! */
-   if (!ci)
+   if (inst_position)
    {
        /*
         * ConnSettings is stored in the driver section and per datasource
diff --git a/info.c b/info.c
index 96e2dcdfc50174a67df3bba9eadf7bbf9b38e5c7..7a15981b1b1e8cfa30c59b5ae94095f9ed023508 100644 (file)
--- a/info.c
+++ b/info.c
@@ -9,7 +9,7 @@
  * API functions:  SQLGetInfo, SQLGetTypeInfo, SQLGetFunctions,
  *                 SQLTables, SQLColumns, SQLStatistics, SQLSpecialColumns,
  *                 SQLPrimaryKeys, SQLForeignKeys,
- *                 SQLProcedureColumns(NI), SQLProcedures,
+ *                 SQLProcedureColumns, SQLProcedures,
  *                 SQLTablePrivileges, SQLColumnPrivileges(NI)
  *
  * Comments:       See "notice.txt" for copyright and license information.
diff --git a/misc.c b/misc.c
index 8cc540490117ce2f0d24ca0147d204cd000b47e8..63c4e0fdfd7774edcb1a6302ce3371a26e5be17d 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -128,7 +128,7 @@ make_string(const char *s, ssize_t len, char *buf, size_t bufsize)
    }
    if (buf)
    {
-       strncpy_null(buf, s, bufsize);
+       strncpy_null(buf, s, bufsize > length ? length + 1 : bufsize);
        return buf;
    }
 
index e2c42189da7e55cb94ee9f179b63116236059a9b..3b6a263e61de871d60322ed3642643d9a62a9fed 100644 (file)
--- a/version.h
+++ b/version.h
@@ -11,6 +11,6 @@
 
 #define POSTGRESDRIVERVERSION      "08.02.0104"
 #define POSTGRES_RESOURCE_VERSION  "08.02.0104\0"
-#define PG_DRVFILE_VERSION     8,2,01,04 
+#define PG_DRVFILE_VERSION     8,2,01,04
 
 #endif