Changeset: 304b4ec76817 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=304b4ec76817
Modified Files:
        NT/monetdb_config.h.in
        clients/odbc/driver/README
        clients/odbc/driver/SQLParamOptions.c
        clients/odbc/driver/SQLSetConnectAttr.c
        clients/odbc/driver/SQLSetConnectOption.c
        clients/odbc/driver/SQLSetDescField.c
        clients/odbc/driver/SQLSetEnvAttr.c
        clients/odbc/driver/SQLSetStmtAttr.c
        clients/odbc/driver/SQLSetStmtOption.c
        clients/odbc/samples/arraytest.c
        clients/odbc/samples/odbcsample1.c
        clients/odbc/samples/testgetinfo.c
        clients/odbc/winsetup/setup.c
        configure.ag
        gdk/gdk.h
        gdk/gdk_imprints.c
        gdk/gdk_utils.c
        sql/server/sql_parser.y
Branch: Oct2014
Log Message:

Standards compliance and use.
The C standard defines include file stdbool.h with contents true,
false, and __bool_true_false_are_defined, so use them and define the
value if they weren't there.  Note that we don't use the type _Bool
that is also defined, since it has a property that we can't emulate
using another type: (_Bool) 42 has value 1.
The C standard defines a pair of integer types intptr_t and uintptr_t
in stdint.h that guarantee round-trip compatibility with pointers, so
use one of them and define it when it wasn't there.


diffs (truncated from 552 to 300 lines):

diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -99,9 +99,6 @@
 /* there is something very similar to asctime_r on Windows: */
 #define asctime_r(t,b,s)       asctime_s(b,s,t)
 
-/* Define to 1 if the system has the type `bool'. */
-/* #undef HAVE_BOOL */
-
 /* Define if you have the cfitsio library */
 /* #undef HAVE_CFITSIO */
 
@@ -699,7 +696,7 @@
 /* #undef HAVE_XMMINTRIN_H */
 
 /* Define to 1 if the system has the type `_Bool'. */
-#define HAVE__BOOL 1
+/* #undef HAVE__BOOL */
 
 #ifdef _WIN64
 /* Define to 1 if you have the `_mul128' function. */
@@ -1029,6 +1026,12 @@ typedef unsigned __int64 uint64_t;
 
 #include <assert.h>
 
+/* normally defined in stdbool.h, but that doesn't exist on Windows */
+#define true 1
+#define false 0
+#define __bool_true_false_are_defined 1
+
+
 #define SLASH_2_DIR_SEP(s) {char *t; for(t=strchr(s, '/'    ); t; 
t=strchr(t+1, '/'    )) *t=DIR_SEP;}
 #define DIR_SEP_2_SLASH(s) {char *t; for(t=strchr(s, DIR_SEP); t; 
t=strchr(t+1, DIR_SEP)) *t='/'    ;}
 
diff --git a/clients/odbc/driver/README b/clients/odbc/driver/README
--- a/clients/odbc/driver/README
+++ b/clients/odbc/driver/README
@@ -224,12 +224,12 @@ Most important are:
 - SQLExentedFetch()                    /* fetch multiple rows at once */
 - SQLAllocHandle(SQL_HANDLE_DESC)      /* support descriptor handles */
 - SQLFreeHandle(SQL_HANDLE_DESC)       /* support descriptor handles */
-- all the SQL*W() functions    /* the Unicode (UCS-2) variant API functions */
+- all the SQL*W() functions    /* the Unicode (UTF-16) variant API functions */
 
 When these SQL*W() functions are not implemented in a driver the driver
  manager (it must be ODBC 3.0 or higher) will convert those ODBC application
  SQL*W() calls to the ASCII variant (e.g. SQLConnect(), by converting the
- supplied UCS-2 strings to ASCII.
+ supplied UTF-16 strings to ASCII.
 
 TODO 2) Because MonetDB supports UTF-8 strings we should do the conversion
 and thus implement those functions ourselves.
diff --git a/clients/odbc/driver/SQLParamOptions.c 
b/clients/odbc/driver/SQLParamOptions.c
--- a/clients/odbc/driver/SQLParamOptions.c
+++ b/clients/odbc/driver/SQLParamOptions.c
@@ -51,7 +51,7 @@ SQLParamOptions(SQLHSTMT StatementHandle
 
        /* use mapping as described in ODBC 3 SDK Help file */
        rc = SQLSetStmtAttr_(stmt, SQL_ATTR_PARAMSET_SIZE,
-                            (SQLPOINTER) (size_t) RowNumber, 0);
+                            (SQLPOINTER) (uintptr_t) RowNumber, 0);
 
        if (SQL_SUCCEEDED(rc)) {
                rc = SQLSetStmtAttr_(stmt, SQL_ATTR_PARAMS_PROCESSED_PTR,
diff --git a/clients/odbc/driver/SQLSetConnectAttr.c 
b/clients/odbc/driver/SQLSetConnectAttr.c
--- a/clients/odbc/driver/SQLSetConnectAttr.c
+++ b/clients/odbc/driver/SQLSetConnectAttr.c
@@ -51,10 +51,10 @@ SQLSetConnectAttr_(ODBCDbc *dbc,
 
        switch (Attribute) {
        case SQL_ATTR_AUTOCOMMIT:
-               switch ((SQLUINTEGER) (size_t) ValuePtr) {
+               switch ((SQLUINTEGER) (uintptr_t) ValuePtr) {
                case SQL_AUTOCOMMIT_ON:
                case SQL_AUTOCOMMIT_OFF:
-                       dbc->sql_attr_autocommit = (SQLUINTEGER) (size_t) 
ValuePtr;
+                       dbc->sql_attr_autocommit = (SQLUINTEGER) (uintptr_t) 
ValuePtr;
 #ifdef ODBCDEBUG
                        ODBCLOG("SQLSetConnectAttr set autocommit %s\n",
                                dbc->sql_attr_autocommit == SQL_AUTOCOMMIT_ON ? 
"on" : "off");
@@ -69,10 +69,10 @@ SQLSetConnectAttr_(ODBCDbc *dbc,
                }
                return SQL_SUCCESS;
        case SQL_ATTR_METADATA_ID:
-               switch ((SQLUINTEGER) (size_t) ValuePtr) {
+               switch ((SQLUINTEGER) (uintptr_t) ValuePtr) {
                case SQL_TRUE:
                case SQL_FALSE:
-                       dbc->sql_attr_metadata_id = (SQLUINTEGER) (size_t) 
ValuePtr;
+                       dbc->sql_attr_metadata_id = (SQLUINTEGER) (uintptr_t) 
ValuePtr;
 #ifdef ODBCDEBUG
                        ODBCLOG("SQLSetConnectAttr set metadata_id %s\n",
                                dbc->sql_attr_metadata_id == SQL_TRUE ? "true" 
: "false");
@@ -102,7 +102,7 @@ SQLSetConnectAttr_(ODBCDbc *dbc,
                }
                break;
        case SQL_ATTR_CONNECTION_TIMEOUT:
-               dbc->sql_attr_connection_timeout = (SQLUINTEGER) (size_t) 
ValuePtr;
+               dbc->sql_attr_connection_timeout = (SQLUINTEGER) (uintptr_t) 
ValuePtr;
                if (dbc->mid)
                        mapi_timeout(dbc->mid, dbc->sql_attr_connection_timeout 
* 1000);
                break;
diff --git a/clients/odbc/driver/SQLSetConnectOption.c 
b/clients/odbc/driver/SQLSetConnectOption.c
--- a/clients/odbc/driver/SQLSetConnectOption.c
+++ b/clients/odbc/driver/SQLSetConnectOption.c
@@ -59,18 +59,18 @@ SQLSetConnectOption_(ODBCDbc *dbc,
        case SQL_TXN_ISOLATION:
                /* 32 bit integer argument */
                return SQLSetConnectAttr_(dbc, Option,
-                                         (SQLPOINTER) (size_t) ValuePtr, 0);
+                                         (SQLPOINTER) (uintptr_t) ValuePtr, 0);
        case SQL_QUIET_MODE:
                /* 32/64 bit integer argument */
                return SQLSetConnectAttr_(dbc, Option,
-                                         (SQLPOINTER) (size_t) ValuePtr, 0);
+                                         (SQLPOINTER) (uintptr_t) ValuePtr, 0);
 
        case SQL_CURRENT_QUALIFIER:
        case SQL_OPT_TRACEFILE:
        case SQL_TRANSLATE_DLL:
                /* null terminated string argument */
                return SQLSetConnectAttr_(dbc, Option,
-                                         (SQLPOINTER) (size_t) ValuePtr,
+                                         (SQLPOINTER) (uintptr_t) ValuePtr,
                                          SQL_NTS);
 
        default:
@@ -118,7 +118,7 @@ SQLSetConnectOptionW(SQLHDBC ConnectionH
                     SQLULEN ValuePtr)
 {
        ODBCDbc *dbc = (ODBCDbc *) ConnectionHandle;
-       SQLPOINTER ptr = (SQLPOINTER) (size_t) ValuePtr;
+       SQLPOINTER ptr = (SQLPOINTER) (uintptr_t) ValuePtr;
        SQLULEN p;
        SQLRETURN rc;
 
@@ -137,9 +137,9 @@ SQLSetConnectOptionW(SQLHDBC ConnectionH
        case SQL_ATTR_CURRENT_CATALOG:
        case SQL_ATTR_TRACEFILE:
        case SQL_ATTR_TRANSLATE_LIB:
-               fixWcharIn((SQLPOINTER) (size_t) ValuePtr, SQL_NTS, SQLCHAR,
+               fixWcharIn((SQLPOINTER) (uintptr_t) ValuePtr, SQL_NTS, SQLCHAR,
                           ptr, addDbcError, dbc, return SQL_ERROR);
-               p = (SQLULEN) (size_t) ptr;
+               p = (SQLULEN) (uintptr_t) ptr;
                break;
        default:
                p = ValuePtr;
diff --git a/clients/odbc/driver/SQLSetDescField.c 
b/clients/odbc/driver/SQLSetDescField.c
--- a/clients/odbc/driver/SQLSetDescField.c
+++ b/clients/odbc/driver/SQLSetDescField.c
@@ -57,19 +57,19 @@ SQLSetDescField_(ODBCDesc *desc,
                addDescError(desc, "HY091", NULL, 0);
                return SQL_ERROR;
        case SQL_DESC_ARRAY_SIZE:
-               if ((SQLULEN) (size_t) ValuePtr == 0) {
+               if ((SQLULEN) (uintptr_t) ValuePtr == 0) {
                        /* Invalid attribute/option identifier */
                        addDescError(desc, "HY092", NULL, 0);
                        return SQL_ERROR;
                }
                if (isAD(desc)) {
                        /* limit size to protect against bugs */
-                       if ((SQLULEN) (size_t) ValuePtr > 10000) {
+                       if ((SQLULEN) (uintptr_t) ValuePtr > 10000) {
                                /* Driver does not support this function */
                                addDescError(desc, "IM001", NULL, 0);
                                return SQL_ERROR;
                        }
-                       desc->sql_desc_array_size = (SQLULEN) (size_t) ValuePtr;
+                       desc->sql_desc_array_size = (SQLULEN) (uintptr_t) 
ValuePtr;
                }
                return SQL_SUCCESS;
        case SQL_DESC_ARRAY_STATUS_PTR:
@@ -81,7 +81,7 @@ SQLSetDescField_(ODBCDesc *desc,
                return SQL_SUCCESS;
        case SQL_DESC_BIND_TYPE:
                if (isAD(desc))
-                       desc->sql_desc_bind_type = (SQLUINTEGER) (size_t) 
ValuePtr;
+                       desc->sql_desc_bind_type = (SQLUINTEGER) (uintptr_t) 
ValuePtr;
                return SQL_SUCCESS;
        case SQL_DESC_COUNT:
                if (isIRD(desc)) {
@@ -196,7 +196,7 @@ SQLSetDescField_(ODBCDesc *desc,
                        rec->sql_desc_indicator_ptr = (SQLLEN *) ValuePtr;
                return SQL_SUCCESS;
        case SQL_DESC_LENGTH:
-               rec->sql_desc_length = (SQLUINTEGER) (size_t) ValuePtr;
+               rec->sql_desc_length = (SQLUINTEGER) (uintptr_t) ValuePtr;
                return SQL_SUCCESS;
        case SQL_DESC_NAME:
                if (isID(desc)) {
diff --git a/clients/odbc/driver/SQLSetEnvAttr.c 
b/clients/odbc/driver/SQLSetEnvAttr.c
--- a/clients/odbc/driver/SQLSetEnvAttr.c
+++ b/clients/odbc/driver/SQLSetEnvAttr.c
@@ -54,14 +54,14 @@ SQLSetEnvAttr(SQLHENV EnvironmentHandle,
 #ifdef ODBCDEBUG
        ODBCLOG("SQLSetEnvAttr " PTRFMT " %s 0x%lx\n",
                PTRFMTCAST EnvironmentHandle, translateEnvAttribute(Attribute),
-               (unsigned long) (size_t) ValuePtr);
+               (unsigned long) (uintptr_t) ValuePtr);
 #endif
 
        (void) StringLength;    /* Stefan: unused!? */
 
        /* global attribute */
        if (Attribute == SQL_ATTR_CONNECTION_POOLING && env == NULL) {
-               switch ((SQLUINTEGER) (size_t) ValuePtr) {
+               switch ((SQLUINTEGER) (uintptr_t) ValuePtr) {
                case SQL_CP_OFF:
                case SQL_CP_ONE_PER_DRIVER:
                case SQL_CP_ONE_PER_HENV:
diff --git a/clients/odbc/driver/SQLSetStmtAttr.c 
b/clients/odbc/driver/SQLSetStmtAttr.c
--- a/clients/odbc/driver/SQLSetStmtAttr.c
+++ b/clients/odbc/driver/SQLSetStmtAttr.c
@@ -107,7 +107,7 @@ SQLSetStmtAttr_(ODBCStmt *stmt,
                break;
 #undef desc
        case SQL_ATTR_CURSOR_SCROLLABLE:
-               switch ((SQLUINTEGER) (size_t) ValuePtr) {
+               switch ((SQLUINTEGER) (uintptr_t) ValuePtr) {
                case SQL_NONSCROLLABLE:
                        stmt->cursorType = SQL_CURSOR_FORWARD_ONLY;
                        break;
@@ -119,10 +119,10 @@ SQLSetStmtAttr_(ODBCStmt *stmt,
                        addStmtError(stmt, "HY024", NULL, 0);
                        return SQL_ERROR;
                }
-               stmt->cursorScrollable = (SQLUINTEGER) (size_t) ValuePtr;
+               stmt->cursorScrollable = (SQLUINTEGER) (uintptr_t) ValuePtr;
                break;
        case SQL_ATTR_CURSOR_TYPE:
-               switch ((SQLUINTEGER) (size_t) ValuePtr) {
+               switch ((SQLUINTEGER) (uintptr_t) ValuePtr) {
                case SQL_CURSOR_KEYSET_DRIVEN:
                case SQL_CURSOR_DYNAMIC:
                        /* Option value changed */
@@ -150,7 +150,7 @@ SQLSetStmtAttr_(ODBCStmt *stmt,
                addStmtError(stmt, "HY017", NULL, 0);
                return SQL_ERROR;
        case SQL_ATTR_NOSCAN:
-               switch ((SQLUINTEGER) (size_t) ValuePtr) {
+               switch ((SQLUINTEGER) (uintptr_t) ValuePtr) {
                case SQL_NOSCAN_ON:
                case SQL_NOSCAN_OFF:
                        break;
@@ -159,7 +159,7 @@ SQLSetStmtAttr_(ODBCStmt *stmt,
                        addStmtError(stmt, "HY024", NULL, 0);
                        return SQL_ERROR;
                }
-               stmt->noScan = (SQLUINTEGER) (size_t) ValuePtr;
+               stmt->noScan = (SQLUINTEGER) (uintptr_t) ValuePtr;
                break;
        case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
                return SQLSetDescField_(stmt->ApplParamDescr, 0,
@@ -186,7 +186,7 @@ SQLSetStmtAttr_(ODBCStmt *stmt,
                                        SQL_DESC_ARRAY_SIZE, ValuePtr,
                                        StringLength);
        case SQL_ATTR_RETRIEVE_DATA:
-               switch ((SQLUINTEGER) (size_t) ValuePtr) {
+               switch ((SQLUINTEGER) (uintptr_t) ValuePtr) {
                case SQL_RD_ON:
                case SQL_RD_OFF:
                        break;
@@ -195,7 +195,7 @@ SQLSetStmtAttr_(ODBCStmt *stmt,
                        addStmtError(stmt, "HY024", NULL, 0);
                        return SQL_ERROR;
                }
-               stmt->retrieveData = (SQLUINTEGER) (size_t) ValuePtr;
+               stmt->retrieveData = (SQLUINTEGER) (uintptr_t) ValuePtr;
                break;
        case SQL_ATTR_ROW_ARRAY_SIZE:
        case SQL_ROWSET_SIZE:
@@ -223,7 +223,7 @@ SQLSetStmtAttr_(ODBCStmt *stmt,
                                        SQL_DESC_ROWS_PROCESSED_PTR, ValuePtr,
                                        StringLength);
        case SQL_ATTR_METADATA_ID:
-               switch ((SQLUINTEGER) (size_t) ValuePtr) {
+               switch ((SQLUINTEGER) (uintptr_t) ValuePtr) {
                case SQL_TRUE:
                case SQL_FALSE:
                        break;
@@ -232,11 +232,11 @@ SQLSetStmtAttr_(ODBCStmt *stmt,
                        addStmtError(stmt, "HY024", NULL, 0);
                        return SQL_ERROR;
                }
-               stmt->Dbc->sql_attr_metadata_id = (SQLUINTEGER) (size_t) 
ValuePtr;
+               stmt->Dbc->sql_attr_metadata_id = (SQLUINTEGER) (uintptr_t) 
ValuePtr;
                break;
 
        case SQL_ATTR_CONCURRENCY:
-               switch ((SQLULEN) (size_t) ValuePtr) {
+               switch ((SQLULEN) (uintptr_t) ValuePtr) {
                case SQL_CONCUR_READ_ONLY:
                        /* the only value we support */
                        break;
diff --git a/clients/odbc/driver/SQLSetStmtOption.c 
b/clients/odbc/driver/SQLSetStmtOption.c
--- a/clients/odbc/driver/SQLSetStmtOption.c
+++ b/clients/odbc/driver/SQLSetStmtOption.c
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to