2016-04-05 16:27 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/hbnetio/netiosrv.c
* minor optimization
* src/rdd/dbcmd.c
* src/rdd/wacore.c
* src/rdd/wafunc.c
! added protection against exceeding the limit of workarea numbers.
Current maximum is 65534, WA 65535 is reserved for internal RDD
WA destructor.
! fixed possible memory leak in hb_rddInsertAreaNode()
* src/vm/set.c
! fixed typo in device detection code
+ added NUL to list of known device names in DOS, OS2 and MS-Win builds
+ recognize \\<server>\<device>, \\.\PIPE\*, \\.\<device> as
device names in DOS, OS2 and MS-Win builds.
This commit is contained in:
@@ -10,6 +10,24 @@
|
||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||
*/
|
||||
|
||||
2016-04-05 16:27 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* contrib/hbnetio/netiosrv.c
|
||||
* minor optimization
|
||||
|
||||
* src/rdd/dbcmd.c
|
||||
* src/rdd/wacore.c
|
||||
* src/rdd/wafunc.c
|
||||
! added protection against exceeding the limit of workarea numbers.
|
||||
Current maximum is 65534, WA 65535 is reserved for internal RDD
|
||||
WA destructor.
|
||||
! fixed possible memory leak in hb_rddInsertAreaNode()
|
||||
|
||||
* src/vm/set.c
|
||||
! fixed typo in device detection code
|
||||
+ added NUL to list of known device names in DOS, OS2 and MS-Win builds
|
||||
+ recognize \\<server>\<device>, \\.\PIPE\*, \\.\<device> as
|
||||
device names in DOS, OS2 and MS-Win builds.
|
||||
|
||||
2016-04-01 00:28 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* src/rtl/direct.c
|
||||
! removed set of MS-Windows attributes passed unconditionally to
|
||||
|
||||
@@ -197,7 +197,7 @@ static int s_srvFileNew( PHB_CONSRV conn, PHB_FILE pFile )
|
||||
{
|
||||
conn->filesCount++;
|
||||
conn->fileTable[ conn->firstFree ] = pFile;
|
||||
return conn->firstFree;
|
||||
return conn->firstFree++;
|
||||
}
|
||||
conn->firstFree++;
|
||||
}
|
||||
|
||||
@@ -743,27 +743,25 @@ HB_FUNC( DBSELECTAREA )
|
||||
if( szAlias )
|
||||
{
|
||||
hb_rddSelectWorkAreaAlias( szAlias );
|
||||
if( hb_rddGetCurrentWorkAreaNumber() == HB_RDD_MAX_AREA_NUM )
|
||||
hb_rddSelectFirstAvailable();
|
||||
}
|
||||
else
|
||||
{
|
||||
int iNewArea = hb_parni( 1 );
|
||||
|
||||
/*
|
||||
* NOTE: lNewArea >= HB_RDD_MAX_AREA_NUM used intentionally
|
||||
* NOTE: iNewArea >= HB_RDD_MAX_AREA_NUM used intentionally
|
||||
* In Clipper area 65535 is reserved for "M" alias [druzus]
|
||||
*/
|
||||
if( iNewArea < 1 || iNewArea >= HB_RDD_MAX_AREA_NUM )
|
||||
{
|
||||
hb_rddSelectFirstAvailable();
|
||||
if( hb_rddSelectFirstAvailable() != HB_SUCCESS )
|
||||
hb_rddSelectWorkAreaNumber( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_rddSelectWorkAreaNumber( iNewArea );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HB_FUNC( __DBSETFOUND )
|
||||
|
||||
@@ -79,13 +79,10 @@ static void hb_waNodeInsert( PHB_STACKRDD pRddInfo, AREAP pArea )
|
||||
iSize = HB_RDD_MAX_AREA_NUM;
|
||||
|
||||
if( pRddInfo->uiWaNumMax == 0 )
|
||||
{
|
||||
pRddInfo->waNums = ( HB_USHORT * ) hb_xgrab( iSize * sizeof( HB_USHORT ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
pRddInfo->waNums = ( HB_USHORT * ) hb_xrealloc( pRddInfo->waNums, iSize * sizeof( HB_USHORT ) );
|
||||
}
|
||||
|
||||
memset( &pRddInfo->waNums[ pRddInfo->uiWaNumMax ], 0, ( iSize - pRddInfo->uiWaNumMax ) * sizeof( HB_USHORT ) );
|
||||
pRddInfo->uiWaNumMax = ( HB_USHORT ) iSize;
|
||||
}
|
||||
@@ -93,9 +90,7 @@ static void hb_waNodeInsert( PHB_STACKRDD pRddInfo, AREAP pArea )
|
||||
if( pRddInfo->uiWaSpace == 0 )
|
||||
{
|
||||
pRddInfo->uiWaSpace = 256;
|
||||
pRddInfo->waList = ( void ** ) hb_xgrab( pRddInfo->uiWaSpace * sizeof(void *) );
|
||||
memset( &pRddInfo->waList[ 0 ], 0, pRddInfo->uiWaSpace * sizeof(void *) );
|
||||
pRddInfo->waList[ 0 ] = NULL;
|
||||
pRddInfo->waList = ( void ** ) hb_xgrabz( pRddInfo->uiWaSpace * sizeof( void * ) );
|
||||
uiWaPos = 1;
|
||||
pRddInfo->uiWaMax = 2;
|
||||
}
|
||||
@@ -104,9 +99,14 @@ static void hb_waNodeInsert( PHB_STACKRDD pRddInfo, AREAP pArea )
|
||||
uiWaPos = pRddInfo->uiWaMax++;
|
||||
if( pRddInfo->uiWaMax > pRddInfo->uiWaSpace )
|
||||
{
|
||||
pRddInfo->uiWaSpace = ( ( pRddInfo->uiWaMax + 256 ) >> 8 ) << 8;
|
||||
pRddInfo->waList = ( void ** ) hb_xrealloc( pRddInfo->waList, pRddInfo->uiWaSpace * sizeof(void *) );
|
||||
memset( &pRddInfo->waList[ pRddInfo->uiWaMax ], 0, ( pRddInfo->uiWaSpace - pRddInfo->uiWaMax ) * sizeof(void *) );
|
||||
int iSize = ( ( ( int ) pRddInfo->uiWaMax + 256 ) >> 8 ) << 8;
|
||||
|
||||
if( iSize > HB_RDD_MAX_AREA_NUM )
|
||||
iSize = HB_RDD_MAX_AREA_NUM;
|
||||
|
||||
pRddInfo->uiWaSpace = ( HB_USHORT ) iSize;
|
||||
pRddInfo->waList = ( void ** ) hb_xrealloc( pRddInfo->waList, pRddInfo->uiWaSpace * sizeof( void * ) );
|
||||
memset( &pRddInfo->waList[ pRddInfo->uiWaMax ], 0, ( pRddInfo->uiWaSpace - pRddInfo->uiWaMax ) * sizeof( void * ) );
|
||||
}
|
||||
while( uiWaPos > 1 )
|
||||
{
|
||||
@@ -149,9 +149,14 @@ static void hb_waNodeDelete( PHB_STACKRDD pRddInfo )
|
||||
uiWaPos++;
|
||||
}
|
||||
pRddInfo->waList[ pRddInfo->uiWaMax ] = NULL;
|
||||
if( pRddInfo->uiWaSpace - pRddInfo->uiWaMax >= 256 )
|
||||
if( pRddInfo->uiWaSpace - pRddInfo->uiWaMax > 256 )
|
||||
{
|
||||
pRddInfo->uiWaSpace = ( ( pRddInfo->uiWaMax + 256 ) >> 8 ) << 8;
|
||||
int iSize = ( ( ( int ) pRddInfo->uiWaMax + 256 ) >> 8 ) << 8;
|
||||
|
||||
if( iSize > HB_RDD_MAX_AREA_NUM )
|
||||
iSize = HB_RDD_MAX_AREA_NUM;
|
||||
|
||||
pRddInfo->uiWaSpace = ( HB_USHORT ) iSize;
|
||||
pRddInfo->waList = ( void ** ) hb_xrealloc( pRddInfo->waList, pRddInfo->uiWaSpace * sizeof( void * ) );
|
||||
}
|
||||
}
|
||||
@@ -203,16 +208,16 @@ HB_USHORT hb_rddInsertAreaNode( const char * szDriver )
|
||||
if( ! pRddNode )
|
||||
return 0;
|
||||
|
||||
pArea = ( AREAP ) hb_rddNewAreaNode( pRddNode, uiRddID );
|
||||
if( ! pArea )
|
||||
return 0;
|
||||
|
||||
if( pRddInfo->uiCurrArea == 0 )
|
||||
{
|
||||
if( hb_rddSelectFirstAvailable() != HB_SUCCESS )
|
||||
return 0;
|
||||
}
|
||||
|
||||
pArea = ( AREAP ) hb_rddNewAreaNode( pRddNode, uiRddID );
|
||||
if( ! pArea )
|
||||
return 0;
|
||||
|
||||
hb_waNodeInsert( pRddInfo, pArea );
|
||||
|
||||
return pRddInfo->uiCurrArea;
|
||||
@@ -527,7 +532,11 @@ static HB_GARBAGE_FUNC( hb_waHolderDestructor )
|
||||
|
||||
iArea = hb_rddGetCurrentWorkAreaNumber();
|
||||
|
||||
hb_rddSelectFirstAvailable();
|
||||
if( hb_rddSelectFirstAvailable() != HB_SUCCESS )
|
||||
/* workarea number HB_RDD_MAX_AREA_NUM is reserved
|
||||
for this destructor and used when all other workareas
|
||||
are active [druzus] */
|
||||
hb_rddSelectWorkAreaNumber( HB_RDD_MAX_AREA_NUM );
|
||||
hb_waNodeInsert( hb_stackRDD(), pArea );
|
||||
hb_rddReleaseCurrentArea();
|
||||
|
||||
|
||||
@@ -591,13 +591,16 @@ HB_ERRCODE hb_rddOpenTable( const char * szFileName, const char * szDriver,
|
||||
* shares WA between threads so dbUseArea() should be covered
|
||||
* by external mutex to make lNewArea MT safe, [druzus]
|
||||
*/
|
||||
if( uiArea )
|
||||
if( uiArea && uiArea < HB_RDD_MAX_AREA_NUM )
|
||||
{
|
||||
hb_rddSelectWorkAreaNumber( uiArea );
|
||||
hb_rddReleaseCurrentArea();
|
||||
}
|
||||
else
|
||||
hb_rddSelectFirstAvailable();
|
||||
else if( hb_rddSelectFirstAvailable() != HB_SUCCESS )
|
||||
{
|
||||
hb_errRT_DBCMD( EG_ARG, EDBCMD_BADPARAMETER, NULL, HB_ERR_FUNCNAME );
|
||||
return HB_FAILURE;
|
||||
}
|
||||
|
||||
/* Clipper clears NETERR flag before parameter validation, [druzus]
|
||||
*/
|
||||
|
||||
39
src/vm/set.c
39
src/vm/set.c
@@ -198,27 +198,54 @@ static const char * is_devicename( const char * szFileName )
|
||||
{
|
||||
#if defined( HB_OS_OS2 ) || defined( HB_OS_WIN ) || defined( HB_OS_DOS )
|
||||
const char * szDevices[] =
|
||||
{ "PRN", "CON", "LPT1", "LPT2", "LPT3",
|
||||
{ "NUL", "PRN", "CON",
|
||||
"LPT1", "LPT2", "LPT3",
|
||||
"COM1", "COM2", "COM3", "COM4", "COM5",
|
||||
"COM6", "COM7", "COM8", "COM9" };
|
||||
int iLen = ( int ) strlen( szFileName ), iFrom, iTo;
|
||||
int iSkip = 0, iLen, iFrom, iTo;
|
||||
|
||||
if( ( szFileName[ 0 ] == '\\' || szFileName[ 0 ] == '/' ) &&
|
||||
( szFileName[ 1 ] == '\\' || szFileName[ 1 ] == '/' ) )
|
||||
{
|
||||
if( szFileName[ 2 ] == '.' &&
|
||||
( szFileName[ 3 ] == '\\' || szFileName[ 3 ] == '/' ) )
|
||||
{
|
||||
iSkip = 4;
|
||||
if( hb_strnicmp( szFileName + 4, "PIPE", 4 ) == 0 &&
|
||||
( szFileName[ 8 ] == '\\' || szFileName[ 8 ] == '/' ) )
|
||||
return szFileName;
|
||||
}
|
||||
if( szFileName[ 2 ] != '\\' && szFileName[ 2 ] != '/' )
|
||||
{
|
||||
for( iFrom = 2, iTo = 0; szFileName[ iFrom ]; ++iFrom )
|
||||
{
|
||||
if( szFileName[ iFrom ] == '\\' || szFileName[ iFrom ] == '/' )
|
||||
{
|
||||
if( iTo++ )
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( iTo == 1 )
|
||||
return szFileName;
|
||||
}
|
||||
}
|
||||
iLen = ( int ) strlen( szFileName + iSkip );
|
||||
if( iLen >= 3 && iLen <= 4 )
|
||||
{
|
||||
if( iLen == 3 )
|
||||
{
|
||||
iFrom = 0;
|
||||
iTo = 0;
|
||||
iTo = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
iFrom = 2;
|
||||
iFrom = 3;
|
||||
iTo = HB_SIZEOFARRAY( szDevices );
|
||||
}
|
||||
for( ; iFrom < iTo; ++iFrom )
|
||||
{
|
||||
if( hb_stricmp( szFileName, szDevices[ iFrom ] ) == 0 )
|
||||
return szDevices[ iFrom ];
|
||||
if( hb_stricmp( szFileName + iSkip, szDevices[ iFrom ] ) == 0 )
|
||||
return iSkip ? szFileName : szDevices[ iFrom ];
|
||||
}
|
||||
}
|
||||
#elif defined( HB_OS_UNIX )
|
||||
|
||||
Reference in New Issue
Block a user