From 001939d5dbcda290cea9baa090ec4e15daca971e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Sun, 14 Sep 2014 20:48:14 +0200 Subject: [PATCH] 2014-09-14 20:48 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbmysql/tmysql.prg * added support for nFlags in TMySQLServer constructor as suggested by Fernando Athayde * src/rtl/gtcgi/gtcgi.c % replaced hb_cdpnDup() with hb_cdpnDup3() to eliminate unnecessary memory block duplicating when translation is not activated. * src/vm/itemapi.c * removed old ugly hack used to mark infinite or undefined double value using double item length field. The code which created such item have been eliminated many years ago. * use HB_DEFAULT_WIDTH instead of hardcoded 99 to force numeric value length recalculation. --- ChangeLog.txt | 16 ++++++++++++++++ contrib/hbmysql/tmysql.prg | 6 +++--- src/rtl/gtcgi/gtcgi.c | 11 ++++++++--- src/vm/itemapi.c | 16 ++++++++-------- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 09157577ce..5eee5a7b46 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,22 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2014-09-14 20:48 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/hbmysql/tmysql.prg + * added support for nFlags in TMySQLServer constructor as + suggested by Fernando Athayde + + * src/rtl/gtcgi/gtcgi.c + % replaced hb_cdpnDup() with hb_cdpnDup3() to eliminate unnecessary + memory block duplicating when translation is not activated. + + * src/vm/itemapi.c + * removed old ugly hack used to mark infinite or undefined double + value using double item length field. The code which created such + item have been eliminated many years ago. + * use HB_DEFAULT_WIDTH instead of hardcoded 99 to force numeric value + length recalculation. + 2014-09-12 22:08 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/vm/estack.c * always set NIL in item allocated by hb_stackAllocItem() when it's diff --git a/contrib/hbmysql/tmysql.prg b/contrib/hbmysql/tmysql.prg index 806a7e8a9e..410233b27b 100644 --- a/contrib/hbmysql/tmysql.prg +++ b/contrib/hbmysql/tmysql.prg @@ -1231,7 +1231,7 @@ CREATE CLASS TMySQLServer VAR lError // .T. if occurred an error VAR cCreateQuery - METHOD New( cServer, cUser, cPassword, nPort ) // Opens connection to a server, returns a server object + METHOD New( cServer, cUser, cPassword, nPort, nFlags ) // Opens connection to a server, returns a server object METHOD Destroy() // Closes connection to server METHOD SelectDB( cDBName ) // Which data base I will use for subsequent queries @@ -1259,13 +1259,13 @@ CREATE CLASS TMySQLServer ENDCLASS -METHOD New( cServer, cUser, cPassword, nPort ) CLASS TMySQLServer +METHOD New( cServer, cUser, cPassword, nPort, nFlags ) CLASS TMySQLServer ::cServer := cServer ::nPort := nPort ::cUser := cUser ::cPassword := cPassword - ::nSocket := mysql_real_connect( cServer, cUser, cPassword, nPort ) + ::nSocket := mysql_real_connect( cServer, cUser, cPassword, nPort, nFlags ) ::lError := .F. IF Empty( ::nSocket ) diff --git a/src/rtl/gtcgi/gtcgi.c b/src/rtl/gtcgi/gtcgi.c index c4dbd885ed..7723b05de8 100644 --- a/src/rtl/gtcgi/gtcgi.c +++ b/src/rtl/gtcgi/gtcgi.c @@ -262,10 +262,15 @@ static void hb_gt_cgi_conOut( PHB_GT pGT, const char * szText, HB_SIZE nLength, if( cdpTerm && cdpHost && cdpTerm != cdpHost ) { - HB_SIZE nLen = nLength; - char * buffer = hb_cdpnDup( szText, &nLen, cdpHost, cdpTerm ); + HB_SIZE nLen = nLength, nBufSize = 0; + char * pBuf = NULL; + const char * buffer = hb_cdpnDup3( szText, nLen, + NULL, &nLen, + &pBuf, &nBufSize, + cdpHost, cdpTerm ); hb_gt_cgi_termOut( pGTCGI, buffer, nLen ); - hb_xfree( buffer ); + if( pBuf ) + hb_xfree( pBuf ); } else hb_gt_cgi_termOut( pGTCGI, szText, nLength ); diff --git a/src/vm/itemapi.c b/src/vm/itemapi.c index a053e041e1..a0645ad3f3 100644 --- a/src/vm/itemapi.c +++ b/src/vm/itemapi.c @@ -1145,7 +1145,7 @@ PHB_ITEM hb_itemPutNLen( PHB_ITEM pItem, double dNumber, int iWidth, int iDec ) if( ( double ) nNumber == dNumber ) { - if( iWidth <= 0 || iWidth > 99 ) + if( iWidth <= 0 || iWidth >= HB_DEFAULT_WIDTH ) iWidth = HB_DBL_LENGTH( dNumber ); return hb_itemPutNIntLen( pItem, nNumber, iWidth ); @@ -1167,7 +1167,7 @@ PHB_ITEM hb_itemPutNDLen( PHB_ITEM pItem, double dNumber, int iWidth, int iDec ) else pItem = hb_itemNew( NULL ); - if( iWidth <= 0 || iWidth > 99 ) + if( iWidth <= 0 || iWidth >= HB_DEFAULT_WIDTH ) iWidth = HB_DBL_LENGTH( dNumber ); if( iDec < 0 ) @@ -1251,7 +1251,7 @@ PHB_ITEM hb_itemPutNILen( PHB_ITEM pItem, int iNumber, int iWidth ) else pItem = hb_itemNew( NULL ); - if( iWidth <= 0 || iWidth > 99 ) + if( iWidth <= 0 || iWidth >= HB_DEFAULT_WIDTH ) iWidth = HB_INT_LENGTH( iNumber ); pItem->type = HB_IT_INTEGER; @@ -1274,14 +1274,14 @@ PHB_ITEM hb_itemPutNLLen( PHB_ITEM pItem, long lNumber, int iWidth ) pItem = hb_itemNew( NULL ); #if HB_VMINT_MAX == LONG_MAX - if( iWidth <= 0 || iWidth > 99 ) + if( iWidth <= 0 || iWidth >= HB_DEFAULT_WIDTH ) iWidth = HB_INT_LENGTH( lNumber ); pItem->type = HB_IT_INTEGER; pItem->item.asInteger.value = ( int ) lNumber; pItem->item.asInteger.length = ( HB_USHORT ) iWidth; #else - if( iWidth <= 0 || iWidth > 99 ) + if( iWidth <= 0 || iWidth >= HB_DEFAULT_WIDTH ) iWidth = HB_LONG_LENGTH( lNumber ); pItem->type = HB_IT_LONG; @@ -1306,7 +1306,7 @@ PHB_ITEM hb_itemPutNLLLen( PHB_ITEM pItem, HB_LONGLONG llNumber, int iWidth ) pItem = hb_itemNew( NULL ); #if HB_VMLONG_MAX >= LONGLONG_MAX - if( iWidth <= 0 || iWidth > 99 ) + if( iWidth <= 0 || iWidth >= HB_DEFAULT_WIDTH ) iWidth = HB_LONG_LENGTH( llNumber ); pItem->type = HB_IT_LONG; @@ -1315,7 +1315,7 @@ PHB_ITEM hb_itemPutNLLLen( PHB_ITEM pItem, HB_LONGLONG llNumber, int iWidth ) #else pItem->type = HB_IT_DOUBLE; pItem->item.asDouble.value = ( double ) llNumber; - if( iWidth <= 0 || iWidth > 99 ) + if( iWidth <= 0 || iWidth >= HB_DEFAULT_WIDTH ) iWidth = HB_LONG_LENGTH( pItem->item.asDouble.value ); pItem->item.asDouble.length = iWidth; pItem->item.asDouble.decimal = 0; @@ -2411,7 +2411,7 @@ HB_BOOL hb_itemStrBuf( char * szResult, PHB_ITEM pNumber, int iSize, int iDec ) { double dNumber = hb_itemGetND( pNumber ); - if( pNumber->item.asDouble.length == 99 || ! hb_isfinite( dNumber ) ) + if( ! hb_isfinite( dNumber ) ) { /* Numeric overflow */ iPos = -1;