From ff8655576676f097dba3807bd4756793a7ea99c0 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Fri, 8 Oct 2004 08:50:08 +0000 Subject: [PATCH] OK, finally think this SQLInfo unicode string length bug can be put to rest. Tested and working in Access 2K3, MS ODBC Testsuite, and some of my own test and live project code. --- info.c | 14 ++++++-------- info30.c | 16 ++++++---------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/info.c b/info.c index 2eea249..2d3386e 100644 --- a/info.c +++ b/info.c @@ -733,8 +733,6 @@ PGAPI_GetInfo( result = SQL_SUCCESS; - mylog("%s: p='%s', len=%d, value=%d, cbMax=%d\n", func, p ? p : "", len, value, cbInfoValueMax); - /* * NOTE, that if rgbInfoValue is NULL, then no warnings or errors * should result and just pcbInfoValue is returned, which indicates @@ -751,15 +749,12 @@ PGAPI_GetInfo( * small. */ if (conn->unicode) - len = (len * WCLEN) - 1; + len = len * WCLEN; if (rgbInfoValue) { if (conn->unicode) - { len = utf8_to_ucs2(p, len, (SQLWCHAR *) rgbInfoValue, cbInfoValueMax / 2); - len *= WCLEN; - } else strncpy_null((char *) rgbInfoValue, p, (size_t) cbInfoValueMax); @@ -782,9 +777,12 @@ PGAPI_GetInfo( } } - if (pcbInfoValue) - *pcbInfoValue = len; + if (pcbInfoValue) + *pcbInfoValue = len; + + mylog("%s: p='%s', len=%d, value=%d, cbMax=%d\n", func, p ? p : "", len, value, cbInfoValueMax); + return result; } diff --git a/info30.c b/info30.c index e9121bd..06b0694 100644 --- a/info30.c +++ b/info30.c @@ -356,7 +356,7 @@ PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue, return SQL_ERROR; } result = SQL_SUCCESS; - mylog("%s: p='%s', len=%d, value=%d, cbMax=%d\n", func, p ? p : "", len, value, cbInfoValueMax); + if (p) { /* char/binary data */ @@ -368,16 +368,13 @@ PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue, * small. */ if (conn->unicode) - len = (len * WCLEN) - 1; + len = len * WCLEN; if (rgbInfoValue) { if (conn->unicode) - { len = utf8_to_ucs2(p, len, (SQLWCHAR *) rgbInfoValue, cbInfoValueMax / 2); - len *= WCLEN; - } else strncpy_null((char *) rgbInfoValue, p, (size_t) cbInfoValueMax); @@ -401,11 +398,10 @@ PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue, } if (pcbInfoValue) - if (conn->unicode) - *pcbInfoValue = len - 2; - else - *pcbInfoValue = len; - + *pcbInfoValue = len; + + mylog("%s: p='%s', len=%d, value=%d, cbMax=%d\n", func, p ? p : "", len, value, cbInfoValueMax); + return result; } -- 2.39.5