2014-01-20 17:36 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* src/rtl/hbsocket.c
    * removed not longer valid TODO note

  * contrib/hbmisc/bbabble.c
    ! fixed buffer size calculation (it fixes buffer overflow for small
      strings, i.e. 2 bytes and does not allocate more memory then necessary
      for long ones)

  * contrib/hbct/dattime2.c
    ! fixed CToMonth() and CToDoW() to respect case intensive search for
      strings with national characters
    * variable name synced with Viktor branch

  * contrib/hbct/strswap.c
    ! fixed NULL reference when neither 1-st nor 2-nd parameter is passed
      by reference

  * contrib/hbct/fcopy.prg
    ! fixed source file positioning in case of partial write
    ! use hb_FGetDateTime() / hb_FSetDateTime() instead of
      FileDate()+FileTime() / SetFDaTi()
      It's faster and unlike FileDate() and FileTime() it does
      not leave directory open.
    ! fixed typo (RTE)
    % minor simplification

  * src/rtl/disksphb.c
    ! use dynamic binding for GetDiskFreeSpaceEx() function

  ; modifications below comes from Viktor fork:

  * contrib/hbct/ctwin.c
    % removed unnecessary declaration

  * contrib/hbct/envparam.c
    ! do not call FreeEnvironmentStrings() is it's not necessary

  * contrib/hbodbc/odbc.c
    ! fixed potential buffer overflow in SQLERROR()/SQLGETDIAGREC()

  * contrib/hbnetio/netiosrv.c
    ! fixed possible NULL reference

  * contrib/hbct/ctnet.c
    ! added missing check for result of WinAPI function call

  * contrib/hbct/cttime.prg
    ! SecToTime(): fixed regression from 2007-11-18 13:46 UTC+0100

  * contrib/hbwin/hbolesrv.c
    ! fixed char -> TCHAR after recent unicodification
This commit is contained in:
Przemysław Czerpak
2014-01-20 17:36:44 +01:00
parent d5899fbc57
commit 48166160de
14 changed files with 101 additions and 40 deletions

View File

@@ -10,6 +10,60 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2014-01-20 17:36 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* src/rtl/hbsocket.c
* removed not longer valid TODO note
* contrib/hbmisc/bbabble.c
! fixed buffer size calculation (it fixes buffer overflow for small
strings, i.e. 2 bytes and does not allocate more memory then necessary
for long ones)
* contrib/hbct/dattime2.c
! fixed CToMonth() and CToDoW() to respect case intensive search for
strings with national characters
* variable name synced with Viktor branch
* contrib/hbct/strswap.c
! fixed NULL reference when neither 1-st nor 2-nd parameter is passed
by reference
* contrib/hbct/fcopy.prg
! fixed source file positioning in case of partial write
! use hb_FGetDateTime() / hb_FSetDateTime() instead of
FileDate()+FileTime() / SetFDaTi()
It's faster and unlike FileDate() and FileTime() it does
not leave directory open.
! fixed typo (RTE)
% minor simplification
* src/rtl/disksphb.c
! use dynamic binding for GetDiskFreeSpaceEx() function
; modifications below comes from Viktor fork:
* contrib/hbct/ctwin.c
% removed unnecessary declaration
* contrib/hbct/envparam.c
! do not call FreeEnvironmentStrings() is it's not necessary
* contrib/hbodbc/odbc.c
! fixed potential buffer overflow in SQLERROR()/SQLGETDIAGREC()
* contrib/hbnetio/netiosrv.c
! fixed possible NULL reference
* contrib/hbct/ctnet.c
! added missing check for result of WinAPI function call
* contrib/hbct/cttime.prg
! SecToTime(): fixed regression from 2007-11-18 13:46 UTC+0100
* contrib/hbwin/hbolesrv.c
! fixed char -> TCHAR after recent unicodification
2014-01-14 23:36 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* config/win/global.mk
* utils/hbmk2/hbmk2.prg

View File

@@ -192,10 +192,13 @@ HB_FUNC( NETRMTNAME )
DWORD dwSize = 0;
LPCTSTR lpLocalName = HB_PARSTRDEF( 1, &hLocalDev, NULL );
WNetGetConnection( lpLocalName, lpRemoteDevice, &dwSize );
if( dwSize > 0 && dwSize <= dwLen && WNetGetConnection( lpLocalName, lpRemoteDevice, &dwSize ) == NO_ERROR )
HB_RETSTRLEN( lpRemoteDevice, ( HB_SIZE ) ( dwSize - 1 ) );
if( WNetGetConnection( lpLocalName, lpRemoteDevice, &dwSize ) == ERROR_MORE_DATA )
{
if( dwSize > 0 && dwSize <= dwLen && WNetGetConnection( lpLocalName, lpRemoteDevice, &dwSize ) == NO_ER
HB_RETSTRLEN( lpRemoteDevice, ( HB_SIZE ) ( dwSize - 1 ) );
else
hb_retc_null();
}
else
hb_retc_null();

View File

@@ -77,14 +77,14 @@ FUNCTION TimeToSec( cTime )
RETURN Round( nSec, 2 ) /* round FL val to be sure that you can compare it */
FUNCTION SecToTime( nSec, lHundr )
FUNCTION SecToTime( nSec, lHundredth )
LOCAL i, h, n
n := iif( ! HB_ISNUMERIC( nSec ), Seconds(), nSec )
IF HB_ISLOGICAL( lHundr ) .AND. lHundr
h := ":" + StrZero( ( nSec * 100 ) % 100, 2 )
IF HB_ISLOGICAL( lHundredth ) .AND. lHundredth
h := StrZero( ( nSec * 100 ) % 100, 2 )
ELSE
h := ""
ENDIF
@@ -92,7 +92,7 @@ FUNCTION SecToTime( nSec, lHundr )
n := Int( n % 86400 )
FOR i := 1 TO 3
h := StrZero( n % 60, 2 ) + iif( Len( h ) == 0, "", ":" ) + h
h := StrZero( n % 60, 2 ) + iif( h == "", "", ":" + h )
n := Int( n / 60 )
NEXT

View File

@@ -2291,7 +2291,7 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions,
PHB_CODEPAGE cdp = hb_vmCDP();
for( i = 1; i <= iOptions; ++i )
{
HB_SIZE nOptLen = hb_arrayGetCLen( pOptions, i );
nOptLen = hb_arrayGetCLen( pOptions, i );
if( nOptLen > 0 )
{
HB_SIZE nIdx1 = 0, nIdx2 = 0;

View File

@@ -83,10 +83,10 @@ static int ct_daysinmonth( int iMonth, HB_BOOL bLeap )
static int ct_daystomonth( int iMonth, HB_BOOL bLeap )
{
static const int iMonthes[] = {
static const int sc_iMonthes[] = {
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
return ( iMonth < 1 && iMonth > 12 ) ? 0 : iMonthes[ iMonth - 1 ] +
return ( iMonth < 1 && iMonth > 12 ) ? 0 : sc_iMonthes[ iMonth - 1 ] +
( ( bLeap && iMonth > 2 ) ? 1 : 0 );
}
@@ -107,12 +107,13 @@ HB_FUNC( CTODOW )
if( nLen )
{
PHB_CODEPAGE cdp = hb_vmCDP();
const char * szParam = hb_parc( 1 );
for( iDow = 7; iDow > 0; iDow-- )
{
const char * szDow = hb_langDGetItem( HB_LANG_ITEM_BASE_DAY + iDow - 1 );
if( hb_strnicmp( szDow, szParam, nLen ) == 0 )
if( hb_cdpicmp( szDow, strlen( szDow ), szParam, nLen, cdp, HB_FALSE ) == 0 )
break;
}
}
@@ -127,11 +128,12 @@ HB_FUNC( CTOMONTH )
if( nLen )
{
PHB_CODEPAGE cdp = hb_vmCDP();
const char * szParam = hb_parc( 1 );
for( iMonth = 12; iMonth > 0; iMonth-- )
{
const char * szMonth = hb_langDGetItem( HB_LANG_ITEM_BASE_MONTH + iMonth - 1 );
if( hb_strnicmp( szMonth, szParam, nLen ) == 0 )
if( hb_cdpicmp( szMonth, strlen( szMonth ), szParam, nLen, cdp, HB_FALSE ) == 0 )
break;
}
}

View File

@@ -131,9 +131,9 @@ HB_FUNC( ENVPARAM )
*lpDst++ = '\n';
}
}
}
FreeEnvironmentStrings( lpEnviron );
FreeEnvironmentStrings( lpEnviron );
}
if( lpResult )
{

View File

@@ -67,7 +67,6 @@
THREAD STATIC t_hSrcFile := F_ERROR
THREAD STATIC t_lSetDaTi := .T.
THREAD STATIC t_fileDate
THREAD STATIC t_fileTime
/*
@@ -92,7 +91,7 @@ FUNCTION FileCopy( cSource, cDest, lMode )
IF t_hSrcFile != F_ERROR
hDstFile := FCreate( cDest )
IF hDstFile != F_ERROR
DO WHILE ! lDone
DO WHILE .T.
nSrcBytes := FRead( t_hSrcFile, @cBuffer, F_BLOCK )
IF nSrcBytes == 0
lDone := .T.
@@ -103,6 +102,9 @@ FUNCTION FileCopy( cSource, cDest, lMode )
nTotBytes += nDstBytes
ENDIF
IF nDstBytes < nSrcBytes
IF lMode
FSeek( t_hSrcFile, nDstBytes - nSrcBytes, FS_RELATIVE )
ENDIF
EXIT
ENDIF
ENDDO
@@ -111,10 +113,9 @@ FUNCTION FileCopy( cSource, cDest, lMode )
FClose( t_hSrcFile )
t_hSrcFile := F_ERROR
ENDIF
t_fileDate := FileDate( cSource )
t_fileTime := FileTime( cSource )
IF t_lSetDaTi
SetFDaTi( cDest, t_fileDate, t_fileTime )
hb_FGetDateTime( cSource, @t_fileTime )
IF t_lSetDaTi .and. !Empty( t_fileTime )
hb_FSetDateTime( cDest, t_fileTime )
ENDIF
ELSE
FClose( t_hSrcFile )
@@ -148,10 +149,10 @@ FUNCTION FileCCont( cDest )
IF t_hSrcFile != F_ERROR
hDstFile := FCreate( cDest )
IF hDstFile != F_ERROR
DO WHILE ! lDone
DO WHILE .T.
nSrcBytes := FRead( t_hSrcFile, @cBuffer, F_BLOCK )
IF nSrcBytes == 0
lDone := 0
lDone := .T.
EXIT
ENDIF
nDstBytes := FWrite( hDstFile, cBuffer, nSrcBytes )
@@ -167,8 +168,8 @@ FUNCTION FileCCont( cDest )
FClose( t_hSrcFile )
t_hSrcFile := F_ERROR
ENDIF
IF t_lSetDaTi
SetFDaTi( cDest, t_fileDate, t_fileTime )
IF t_lSetDaTi .and. !Empty( t_fileTime )
hb_FSetDateTime( cDest, t_fileTime )
ENDIF
ENDIF
ENDIF

View File

@@ -89,7 +89,7 @@ HB_FUNC( STRSWAP )
if( iChange2 )
*( pcRet2 + sIndex ) = cExchange;
}
else
else if( iChange2 )
*( pcRet2 + sIndex ) = *( pcString1 + sIndex );
}

View File

@@ -62,7 +62,7 @@ HB_FUNC( BUBBLEBABBLEENCODE )
const char * pszInput = hb_parcx( 1 );
HB_ISIZ nInputLen = hb_parclen( 1 );
char * pszResult = ( char * ) hb_xgrab( ( nInputLen * 4 ) + 1 );
char * pszResult = ( char * ) hb_xgrab( nInputLen * 3 + 6 );
HB_ISIZ nPos = 0;
HB_ISIZ i;
@@ -103,7 +103,6 @@ HB_FUNC( BUBBLEBABBLEENCODE )
}
pszResult[ nPos++ ] = 'x';
pszResult[ nPos ] = '\0';
hb_retc_buffer( pszResult );
hb_retclen_buffer( pszResult, nPos );
}

View File

@@ -746,9 +746,11 @@ static HB_BOOL s_netio_login_accept( PHB_CONSRV conn )
}
if( ! conn->login )
s_consrv_disconnect( conn );
return conn->login;
}
return conn->login;
return HB_FALSE;
}
/* netio_VerifyClient( <pConnectionSocket> ) -> <lAccepted>

View File

@@ -796,7 +796,7 @@ HB_FUNC( SQLERROR ) /* hEnv, hDbc, hStmt, @cErrorClass, @nType, @cErrorMsg */
( SQLTCHAR * ) buffer,
( SQLINTEGER * ) &lError,
( SQLTCHAR * ) szErrorMsg,
( SQLSMALLINT ) sizeof( szErrorMsg ),
( SQLSMALLINT ) HB_SIZEOFARRAY( szErrorMsg ),
( SQLSMALLINT * ) &iLen ) );
O_HB_STORSTR( ( O_HB_CHAR * ) buffer, 4 );
@@ -845,7 +845,7 @@ HB_FUNC( SQLGETDIAGREC ) /* nHandleType, hHandle, nRecNumber, @cSQLState, @nErro
( SQLTCHAR * ) szSQLState,
( SQLINTEGER * ) &lError,
( SQLTCHAR * ) szErrorMsg,
( SQLSMALLINT ) sizeof( szErrorMsg ),
( SQLSMALLINT ) HB_SIZEOFARRAY( szErrorMsg ),
( SQLSMALLINT * ) &iLen ) );
O_HB_STORSTR( ( O_HB_CHAR * ) szSQLState, 4 );

View File

@@ -153,7 +153,7 @@ static HB_BOOL s_getKeyValue( LPCTSTR lpKey, LPTSTR lpBuffer, int iLen )
iPos = 0;
for( ;; )
{
char c = lpKey[ iPos++ ];
TCHAR c = lpKey[ iPos++ ];
if( c == TEXT( '$' ) || c == TEXT( '@' ) || c == TEXT( '\0' ) )
{
if( --iPos )

View File

@@ -190,10 +190,17 @@ HB_FUNC( HB_DISKSPACE )
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
#if ! defined( HB_OS_WIN_CE ) && ! defined( HB_OS_WIN_64 )
fResult = s_pGetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes );
#else
fResult = GetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes );
#endif
hb_fsSetIOError( fResult, 0 );
if( fResult )

View File

@@ -3512,13 +3512,6 @@ PHB_ITEM hb_socketGetIFaces( int af, HB_BOOL fNoAliases )
&pIfInfo->iiBroadcastAddress,
sizeof( pIfInfo->iiBroadcastAddress ) );
/* TODO:
* use GetAdaptersInfo() and bind interafcaes by
* printf("\tIP Mask: \t%s\n", pAdapter->IpAddressList.IpMask.String);
*
* hb_arraySetC( pItem, HB_SOCKET_IFINFO_HWADDR, hwaddr );
*/
flags = ( ( flags & IFF_UP ) ?
HB_SOCKET_IFF_UP : 0 ) |
( ( flags & IFF_BROADCAST ) ?