Modified:
trunk/SDK/C/Library/MYODBCC.cpp
trunk/SDK/C/include/MYODBCC.h
Log:
Fixed QString_toWString to allow retrieving only a specific amount of the string.
Partial fix for bug#24876
Modified: trunk/SDK/C/Library/MYODBCC.cpp
===================================================================
--- trunk/SDK/C/Library/MYODBCC.cpp 2006-12-07 22:00:23 UTC (rev 711)
+++ trunk/SDK/C/Library/MYODBCC.cpp 2006-12-08 00:37:24 UTC (rev 712)
@@ -2546,11 +2546,14 @@
return false;
}
-int MYODBCC::QString_toWString( QString qs, std::wstring *st )
+int MYODBCC::QString_toWString( QString qs, std::wstring *st, int ws_max_chars )
{
int size = qs.length();
int i,j; /* i = Position(qs); j = Position(st) */
+ if(ws_max_chars > 0 && size > ws_max_chars)
+ size = ws_max_chars;
+
st->resize(size);
for(i = 0, j = 0; i < size; ++i, ++j)
@@ -2580,7 +2583,8 @@
int MYODBCC::QString_toWCharArray( QString qs, wchar_t *array, int nLenChars )
{
std::wstring st;
- int r = QString_toWString(qs, &st);
+ /* convert to the WString and save a spot for null-term */
+ int r = QString_toWString(qs, &st, nLenChars - 1);
/* enforce max size to copy info wchar array */
if(nLenChars > 0 && r >= nLenChars)
{
Modified: trunk/SDK/C/include/MYODBCC.h
===================================================================
--- trunk/SDK/C/include/MYODBCC.h 2006-12-07 22:00:23 UTC (rev 711)
+++ trunk/SDK/C/include/MYODBCC.h 2006-12-08 00:37:24 UTC (rev 712)
@@ -591,7 +591,7 @@
These features will be available in the QString class as of Qt 4.2.
*/
/*@{*/
- static int QString_toWString( QString qs, std::wstring *ws );
+ static int QString_toWString( QString qs, std::wstring *ws, int ws_max_chars = -1 );
static int QString_toWCharArray( QString qs, wchar_t *array, int nLenChars = -1 );
static QString QString_fromWCharArray( const wchar_t *pwsString, int nLenChars = -1
);
/*@}*/
| Thread |
|---|
| • Connector/ODBC 5 commit: r712 - in trunk/SDK/C: Library include | jbalint | 8 Dec |