19990830-19:00 GMT+1
This commit is contained in:
@@ -1,3 +1,62 @@
|
||||
19990830-19:00 GMT+1 Victor Szel <info@szelvesz.hu>
|
||||
|
||||
* source/filesys.c
|
||||
include/filesys.h
|
||||
funclist.txt
|
||||
+ Added: DIRCHANGE(), MAKEDIR(), DIRREMOVE(), DISKCHANGE(), DISKNAME()
|
||||
All of them are Clipper 5.3 compatible functions. Some of them will not
|
||||
work, since the underlying low level API is not worked out.
|
||||
! Fixed CURDIR() to preserve the FERROR() value.
|
||||
! Fixed prototype of hb_fsChDrv().
|
||||
+ DISKSPACE() added (currently only working in DOS).
|
||||
* source/rtl/arrays.c
|
||||
+ hb_arrayAdd() added BASE/1187 Bound error "AADD" error message.
|
||||
! 1068 Not an array errors changed to the 9999 code, until we allocate
|
||||
a 3xxx error for. This error was not there in Clipper.
|
||||
* source/vm/hvm.c
|
||||
+ Added standard "no exported method" and "no exported variable"
|
||||
runtime error instead of the internal error.
|
||||
( ErrorNew():hello := 1, ErrorNew():hello )
|
||||
+ hb_vmPlus() and hb_vmMinus() added "string overflow" runtime errors
|
||||
(1209, 1210) (could not test this though :)
|
||||
* Error code 1000 in BADALIAS errors changed to 9999, until someone finds
|
||||
out the correct error code, since there's no 1000 error code in Clipper.
|
||||
* source/rtl/set.c
|
||||
! Fixed to also accept strings that *begin* with "ON" or "OFF", like
|
||||
Clipper.
|
||||
* source/rtl/tone.c
|
||||
source/rtl/codebloc.c
|
||||
source/rtl/memvars.c
|
||||
source/rtl/environ.c
|
||||
source/rtl/classes.c
|
||||
source/rtl/console.c
|
||||
source/rtl/langapi.c
|
||||
source/rtl/setcolor.c
|
||||
source/rtl/strings.c
|
||||
source/rtl/dates.c
|
||||
source/rtl/set.c
|
||||
source/rtl/transfrm.c (removed static)
|
||||
source/rtl/inkey.c
|
||||
source/rtl/fm.c
|
||||
source/rtl/dir.c
|
||||
source/rtl/gtapi.c
|
||||
* Formatting errors corrected.
|
||||
+ static variables prefixed with "s_"
|
||||
* Some type changed to BOOL.
|
||||
|
||||
19990830-16:59 +0300 Chen Kedem <niki@actcom.co.il>
|
||||
* source/rtl/mouse/mouseos2.c
|
||||
* hb_mouse_Hide() now work in any text screen mode.
|
||||
* hb_mouse_IsButtonPressed() now return TRUE if any button was
|
||||
pressed.
|
||||
TOFIX: every time I read event from the queue I lose the result
|
||||
so I can not check if iButton was pressed, so for now I ignore
|
||||
iButton and return TRUE if the last event saved had DOWN in it.
|
||||
also to keep the noise level down I mask out MOUSE_MOTION
|
||||
events.
|
||||
* suMouHandle changed to s_uMouHandle
|
||||
* Some reformatting.
|
||||
|
||||
19990830-12:49 EDT Paul Tucker <ptucker@sympatico.ca>
|
||||
* source/rtl/gtapi.c
|
||||
* Handle nesting of gtPre/PostExt
|
||||
|
||||
@@ -90,7 +90,7 @@ DEVOUT ;R;
|
||||
DEVOUTPICT ;R;
|
||||
DEVPOS ;R;
|
||||
DIRECTORY ;R;
|
||||
DISKSPACE ;N;
|
||||
DISKSPACE ;R;
|
||||
DISPBEGIN ;S;
|
||||
DISPBOX ;R;
|
||||
DISPCOUNT ;S;
|
||||
|
||||
@@ -62,7 +62,7 @@ typedef struct
|
||||
} HB_FNAME, * PHB_FNAME, * HB_FNAME_PTR;
|
||||
|
||||
extern BOOL hb_fsChDir ( BYTE * pDirName );
|
||||
extern USHORT hb_fsChDrv ( BYTE * nDrive );
|
||||
extern USHORT hb_fsChDrv ( BYTE nDrive );
|
||||
extern void hb_fsClose ( FHANDLE hFileHandle );
|
||||
extern void hb_fsCommit ( FHANDLE hFileHandle );
|
||||
extern FHANDLE hb_fsCreate ( BYTE * pFilename, USHORT uiAttribute );
|
||||
|
||||
@@ -147,9 +147,15 @@ void hb_arrayNew( PHB_ITEM pItem, ULONG ulLen ) /* creates a new array */
|
||||
void hb_arrayAdd( PHB_ITEM pArray, PHB_ITEM pValue )
|
||||
{
|
||||
PBASEARRAY pBaseArray = ( PBASEARRAY ) pArray->item.asArray.value;
|
||||
hb_arraySize( pArray, pBaseArray->ulLen + 1 );
|
||||
pBaseArray = ( PBASEARRAY ) pArray->item.asArray.value;
|
||||
hb_itemCopy( pBaseArray->pItems + ( pBaseArray->ulLen - 1 ), pValue );
|
||||
|
||||
if( pBaseArray->ulLen < ULONG_MAX )
|
||||
{
|
||||
hb_arraySize( pArray, pBaseArray->ulLen + 1 );
|
||||
pBaseArray = ( PBASEARRAY ) pArray->item.asArray.value;
|
||||
hb_itemCopy( pBaseArray->pItems + ( pBaseArray->ulLen - 1 ), pValue );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_BOUND, 1187, NULL, "AADD" );
|
||||
}
|
||||
|
||||
void hb_arrayGet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
|
||||
@@ -313,7 +319,7 @@ void hb_arrayFill( PHB_ITEM pArray, PHB_ITEM pValue, ULONG ulStart, ULONG ulCoun
|
||||
hb_itemCopy( pBaseArray->pItems + ( ulStart - 1 ), pValue );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
hb_errRT_BASE( EG_ARG, 9999, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
}
|
||||
|
||||
void hb_arrayDel( PHB_ITEM pArray, ULONG ulIndex )
|
||||
@@ -335,7 +341,7 @@ void hb_arrayDel( PHB_ITEM pArray, ULONG ulIndex )
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
hb_errRT_BASE( EG_ARG, 9999, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
}
|
||||
|
||||
void hb_arrayIns( PHB_ITEM pArray, ULONG ulIndex )
|
||||
@@ -357,7 +363,7 @@ void hb_arrayIns( PHB_ITEM pArray, ULONG ulIndex )
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
hb_errRT_BASE( EG_ARG, 9999, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
}
|
||||
|
||||
int hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, ULONG ulStart, ULONG ulCount )
|
||||
@@ -432,7 +438,7 @@ int hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, ULONG ulStart, ULONG ulCount
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
hb_errRT_BASE( EG_ARG, 9999, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -491,7 +497,7 @@ void hb_arrayRelease( PHB_ITEM pArray )
|
||||
pArray->item.asArray.value = NULL;
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
hb_errRT_BASE( EG_ARG, 9999, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
}
|
||||
|
||||
void hb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, ULONG ulStart,
|
||||
@@ -525,7 +531,7 @@ void hb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, ULONG ulStart,
|
||||
hb_itemCopy( pDstBaseArray->pItems + ( ulTarget + ulStart ), pSrcBaseArray->pItems + ulStart );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
hb_errRT_BASE( EG_ARG, 9999, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
}
|
||||
|
||||
PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
|
||||
@@ -559,7 +565,7 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
hb_errRT_BASE( EG_ARG, 9999, NULL, hb_langDGetErrorDesc( EG_NOTARRAY ) );
|
||||
|
||||
return pDstArray;
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ typedef struct
|
||||
#define BUCKET 4
|
||||
#define HASH_KEY ( BASE_METHODS / BUCKET )
|
||||
|
||||
static PCLASS pClasses = 0;
|
||||
static WORD wClasses = 0;
|
||||
static PMETHOD pMethod = 0;
|
||||
static PHB_DYNS msgClassName = 0;
|
||||
static PHB_DYNS msgClassH = 0;
|
||||
static PHB_DYNS msgEval = 0;
|
||||
static PHB_DYNS msgClassSel = 0;
|
||||
static PCLASS s_pClasses = NULL;
|
||||
static WORD s_wClasses = 0;
|
||||
static PMETHOD s_pMethod = NULL;
|
||||
static PHB_DYNS s_msgClassName = NULL;
|
||||
static PHB_DYNS s_msgClassH = NULL;
|
||||
static PHB_DYNS s_msgEval = NULL;
|
||||
static PHB_DYNS s_msgClassSel = NULL;
|
||||
|
||||
/* All functions contained in classes.c */
|
||||
|
||||
@@ -120,9 +120,9 @@ HARBOUR HB___CLSADDMSG( void )
|
||||
{
|
||||
WORD wClass = hb_parnl( 1 );
|
||||
|
||||
if( wClass && wClass <= wClasses )
|
||||
if( wClass && wClass <= s_wClasses )
|
||||
{
|
||||
PCLASS pClass = &pClasses[ wClass - 1 ];
|
||||
PCLASS pClass = &s_pClasses[ wClass - 1 ];
|
||||
PHB_DYNS pMessage = hb_dynsymGet( hb_parc( 2 ) );
|
||||
WORD wType = hb_parni( 4 );
|
||||
WORD wAt = ( ( ( unsigned ) pMessage ) % pClass->wHashKey ) * BUCKET;
|
||||
@@ -225,19 +225,19 @@ HARBOUR HB___CLSNEW( void )
|
||||
WORD wSuper = hb_parni( 3 ); /* Super class present */
|
||||
PCLASS pNewCls;
|
||||
|
||||
if( pClasses )
|
||||
pClasses = ( PCLASS ) hb_xrealloc( pClasses,
|
||||
sizeof( CLASS ) * ( wClasses + 1 ) );
|
||||
if( s_pClasses )
|
||||
s_pClasses = ( PCLASS ) hb_xrealloc( s_pClasses,
|
||||
sizeof( CLASS ) * ( s_wClasses + 1 ) );
|
||||
else
|
||||
pClasses = ( PCLASS ) hb_xgrab( sizeof( CLASS ) );
|
||||
s_pClasses = ( PCLASS ) hb_xgrab( sizeof( CLASS ) );
|
||||
|
||||
pNewCls = pClasses + wClasses;
|
||||
pNewCls = s_pClasses + s_wClasses;
|
||||
pNewCls->szName = ( char * ) hb_xgrab( hb_parclen( 1 ) + 1 );
|
||||
strcpy( pNewCls->szName, hb_parc( 1 ) );
|
||||
|
||||
if( wSuper )
|
||||
{
|
||||
PCLASS pSprCls = pClasses + wSuper - 1;
|
||||
PCLASS pSprCls = s_pClasses + wSuper - 1;
|
||||
WORD wSize;
|
||||
|
||||
pNewCls->wDataFirst = pSprCls->wDatas;
|
||||
@@ -266,7 +266,7 @@ HARBOUR HB___CLSNEW( void )
|
||||
|
||||
memset( pNewCls->pMethods, 0, BASE_METHODS * sizeof( METHOD ) );
|
||||
}
|
||||
hb_retni( ++wClasses );
|
||||
hb_retni( ++s_wClasses );
|
||||
}
|
||||
|
||||
|
||||
@@ -283,9 +283,9 @@ HARBOUR HB___CLSDELMSG( void )
|
||||
WORD wClass = hb_parni( 1 );
|
||||
PHB_ITEM pString = hb_param( 2, IT_STRING );
|
||||
|
||||
if( wClass && wClass <= wClasses && pString )
|
||||
if( wClass && wClass <= s_wClasses && pString )
|
||||
{
|
||||
PCLASS pClass = pClasses + wClass - 1;
|
||||
PCLASS pClass = s_pClasses + wClass - 1;
|
||||
PHB_SYMB pMessage = hb_dynsymGet( pString->item.asString.value )->pSymbol;
|
||||
PHB_DYNS pMsg = pMessage->pDynSym;
|
||||
WORD wAt = ( ( ( unsigned ) pMsg ) % pClass->wHashKey ) * BUCKET;
|
||||
@@ -349,9 +349,9 @@ HARBOUR HB___CLSINST( void )
|
||||
{
|
||||
WORD wClass = hb_parni( 1 );
|
||||
|
||||
if( wClass <= wClasses )
|
||||
if( wClass <= s_wClasses )
|
||||
{
|
||||
PCLASS pClass = pClasses + ( wClass - 1 );
|
||||
PCLASS pClass = s_pClasses + ( wClass - 1 );
|
||||
WORD wAt;
|
||||
WORD wLimit = pClass->wHashKey * BUCKET;
|
||||
PMETHOD pMeth = pClass->pMethods; /* Initialize DATA */
|
||||
@@ -375,9 +375,9 @@ HARBOUR HB___CLSMODMSG( void )
|
||||
WORD wClass = hb_parni( 1 );
|
||||
PHB_ITEM pString = hb_param( 2, IT_STRING );
|
||||
|
||||
if( wClass && wClass <= wClasses && pString )
|
||||
if( wClass && wClass <= s_wClasses && pString )
|
||||
{
|
||||
PCLASS pClass = pClasses + wClass - 1;
|
||||
PCLASS pClass = s_pClasses + wClass - 1;
|
||||
PHB_SYMB pMessage = hb_dynsymGet( pString->item.asString.value )->pSymbol;
|
||||
PHB_DYNS pMsg = pMessage->pDynSym;
|
||||
WORD wAt = ( ( ( unsigned ) pMsg ) % pClass->wHashKey ) * BUCKET;
|
||||
@@ -449,14 +449,14 @@ HARBOUR HB___OBJGETCLSNAME( void )
|
||||
{
|
||||
wClass = pObject->item.asArray.value->wClass;
|
||||
|
||||
hb_retc( pClasses[ wClass - 1 ].szName );
|
||||
hb_retc( s_pClasses[ wClass - 1 ].szName );
|
||||
}
|
||||
else
|
||||
{
|
||||
wClass = hb_parni( 1 );
|
||||
|
||||
if( wClass <= wClasses )
|
||||
hb_retc( pClasses[ wClass - 1 ].szName );
|
||||
if( wClass <= s_wClasses )
|
||||
hb_retc( s_pClasses[ wClass - 1 ].szName );
|
||||
else
|
||||
hb_retc( "" );
|
||||
}
|
||||
@@ -482,9 +482,9 @@ static HARBOUR hb___msgClsSel( void )
|
||||
wClass = pItemRef->item.asArray.value->wClass;
|
||||
}
|
||||
|
||||
if( wClass && wClass <= wClasses )
|
||||
if( wClass && wClass <= s_wClasses )
|
||||
{
|
||||
PCLASS pClass = &pClasses[ wClass - 1 ];
|
||||
PCLASS pClass = &s_pClasses[ wClass - 1 ];
|
||||
WORD wLimit = pClass->wHashKey * BUCKET; /* Number of Hash keys */
|
||||
WORD wPos = 0;
|
||||
WORD wAt;
|
||||
@@ -533,7 +533,7 @@ static HARBOUR hb___msgEvalInline( void )
|
||||
WORD wClass = ( stack.pBase + 1 )->item.asArray.value->wClass;
|
||||
WORD w;
|
||||
|
||||
hb_arrayGet( pClasses[ wClass - 1 ].pInlines, pMethod->wData, &block );
|
||||
hb_arrayGet( s_pClasses[ wClass - 1 ].pInlines, s_pMethod->wData, &block );
|
||||
|
||||
hb_vmPushSymbol( &symEval );
|
||||
hb_vmPush( &block );
|
||||
@@ -562,7 +562,7 @@ char * hb_objGetClsName( PHB_ITEM pObject )
|
||||
szClassName = "ARRAY";
|
||||
else
|
||||
szClassName =
|
||||
( pClasses + pObject->item.asArray.value->wClass - 1 )->szName;
|
||||
( s_pClasses + pObject->item.asArray.value->wClass - 1 )->szName;
|
||||
}
|
||||
else /* built in types */
|
||||
{
|
||||
@@ -614,10 +614,10 @@ char * hb_objGetClsName( PHB_ITEM pObject )
|
||||
static HARBOUR hb___msgGetClsData( void )
|
||||
{
|
||||
WORD wClass = ( stack.pBase + 1 )->item.asArray.value->wClass;
|
||||
WORD wIndex = pMethod->wData;
|
||||
WORD wIndex = s_pMethod->wData;
|
||||
|
||||
if( wClass && wClass <= wClasses )
|
||||
hb_arrayGet( pClasses[ wClass - 1 ].pClassDatas, wIndex, &stack.Return );
|
||||
if( wClass && wClass <= s_wClasses )
|
||||
hb_arrayGet( s_pClasses[ wClass - 1 ].pClassDatas, wIndex, &stack.Return );
|
||||
}
|
||||
|
||||
|
||||
@@ -629,7 +629,7 @@ static HARBOUR hb___msgGetClsData( void )
|
||||
static HARBOUR hb___msgGetData( void )
|
||||
{
|
||||
PHB_ITEM pObject = stack.pBase + 1;
|
||||
WORD wIndex = pMethod->wData;
|
||||
WORD wIndex = s_pMethod->wData;
|
||||
|
||||
if( wIndex > ( WORD ) hb_arrayLen ( pObject ) )
|
||||
/* Resize needed */
|
||||
@@ -654,29 +654,29 @@ PHB_FUNC hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pMessage )
|
||||
else
|
||||
wClass = 0;
|
||||
|
||||
if( ! msgClassName )
|
||||
if( ! s_msgClassName )
|
||||
{
|
||||
msgClassName = hb_dynsymGet( "CLASSNAME" ); /* Standard messages */
|
||||
msgClassH = hb_dynsymGet( "CLASSH" ); /* Not present in classdef. */
|
||||
msgClassSel = hb_dynsymGet( "CLASSSEL" );
|
||||
msgEval = hb_dynsymGet( "EVAL" );
|
||||
s_msgClassName = hb_dynsymGet( "CLASSNAME" ); /* Standard messages */
|
||||
s_msgClassH = hb_dynsymGet( "CLASSH" ); /* Not present in classdef. */
|
||||
s_msgClassSel = hb_dynsymGet( "CLASSSEL" );
|
||||
s_msgEval = hb_dynsymGet( "EVAL" );
|
||||
}
|
||||
|
||||
if( wClass && wClass <= wClasses )
|
||||
if( wClass && wClass <= s_wClasses )
|
||||
{
|
||||
PCLASS pClass = &pClasses[ wClass - 1 ];
|
||||
PCLASS pClass = &s_pClasses[ wClass - 1 ];
|
||||
WORD wAt = ( ( ( unsigned ) pMsg ) % pClass->wHashKey ) * BUCKET;
|
||||
WORD wMask = pClass->wHashKey * BUCKET;
|
||||
WORD wLimit = wAt ? ( wAt - 1 ) : ( wMask - 1 );
|
||||
|
||||
pMethod = 0; /* Current method pointer */
|
||||
s_pMethod = NULL; /* Current method pointer */
|
||||
|
||||
while( wAt != wLimit )
|
||||
{
|
||||
if( pClass->pMethods[ wAt ].pMessage == pMsg )
|
||||
{
|
||||
pMethod = pClass->pMethods + wAt;
|
||||
return pMethod->pFunction;
|
||||
s_pMethod = pClass->pMethods + wAt;
|
||||
return s_pMethod->pFunction;
|
||||
}
|
||||
wAt++;
|
||||
if( wAt == wMask )
|
||||
@@ -684,19 +684,19 @@ PHB_FUNC hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pMessage )
|
||||
}
|
||||
}
|
||||
|
||||
if( pMsg == msgClassName )
|
||||
if( pMsg == s_msgClassName )
|
||||
return hb___msgClsName;
|
||||
|
||||
else if( pMsg == msgClassH )
|
||||
else if( pMsg == s_msgClassH )
|
||||
return hb___msgClsH;
|
||||
|
||||
else if( pMsg == msgClassSel )
|
||||
else if( pMsg == s_msgClassSel )
|
||||
return hb___msgClsSel;
|
||||
|
||||
else if( pMsg == msgEval )
|
||||
else if( pMsg == s_msgEval )
|
||||
return hb___msgEvalInline;
|
||||
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -810,11 +810,11 @@ void hb_clsReleaseAll( void )
|
||||
{
|
||||
WORD w;
|
||||
|
||||
for( w = 0; w < wClasses; w++ )
|
||||
hb_clsRelease( pClasses + w );
|
||||
for( w = 0; w < s_wClasses; w++ )
|
||||
hb_clsRelease( s_pClasses + w );
|
||||
|
||||
if( pClasses )
|
||||
hb_xfree( pClasses );
|
||||
if( s_pClasses )
|
||||
hb_xfree( s_pClasses );
|
||||
}
|
||||
|
||||
|
||||
@@ -828,7 +828,7 @@ static HARBOUR hb___msgSuper( void )
|
||||
PHB_ITEM pObject = stack.pBase + 1;
|
||||
PHB_ITEM pSuper = ( PHB_ITEM ) hb_xgrab( sizeof( HB_ITEM ) );
|
||||
PBASEARRAY pNewBase = ( PBASEARRAY ) hb_xgrab( sizeof( BASEARRAY ) );
|
||||
WORD wSuperCls = pMethod->wData; /* Get handle of superclass */
|
||||
WORD wSuperCls = s_pMethod->wData; /* Get handle of superclass */
|
||||
|
||||
memcpy( pSuper, pObject, sizeof( HB_ITEM ) );
|
||||
/* Allocate new structures */
|
||||
@@ -855,10 +855,10 @@ static HARBOUR hb___msgSetClsData( void )
|
||||
WORD wClass = ( stack.pBase + 1 )->item.asArray.value->wClass;
|
||||
PHB_ITEM pReturn = stack.pBase + 2;
|
||||
|
||||
if( wClass && wClass <= wClasses )
|
||||
if( wClass && wClass <= s_wClasses )
|
||||
{
|
||||
hb_arraySet( pClasses[ wClass - 1 ].pClassDatas,
|
||||
pMethod->wData, pReturn );
|
||||
hb_arraySet( s_pClasses[ wClass - 1 ].pClassDatas,
|
||||
s_pMethod->wData, pReturn );
|
||||
hb_itemCopy( &stack.Return, pReturn );
|
||||
}
|
||||
}
|
||||
@@ -873,7 +873,7 @@ static HARBOUR hb___msgSetData( void )
|
||||
{
|
||||
PHB_ITEM pObject = stack.pBase + 1;
|
||||
PHB_ITEM pReturn = stack.pBase + 2;
|
||||
WORD wIndex = pMethod->wData;
|
||||
WORD wIndex = s_pMethod->wData;
|
||||
|
||||
if( wIndex > ( WORD ) hb_arrayLen( pObject ) )
|
||||
/* Resize needed */
|
||||
@@ -917,9 +917,9 @@ HARBOUR HB___CLSINSTSUPER( void )
|
||||
hb_errRT_BASE( EG_ARG, 3002, "Super class does not return an object", "__CLSINSTSUPER" );
|
||||
}
|
||||
|
||||
for( w = 0; !bFound && w < wClasses; w++ )
|
||||
for( w = 0; !bFound && w < s_wClasses; w++ )
|
||||
{ /* Locate the entry */
|
||||
if( !hb_stricmp( pString->item.asString.value, pClasses[ w ].szName ) )
|
||||
if( !hb_stricmp( pString->item.asString.value, s_pClasses[ w ].szName ) )
|
||||
{
|
||||
hb_retni( w + 1 ); /* Entry + 1 = hb___msgClsH */
|
||||
bFound = TRUE;
|
||||
@@ -945,7 +945,7 @@ HARBOUR HB___CLS_CNTCLSDATA( void )
|
||||
|
||||
if( wClass )
|
||||
{
|
||||
PCLASS pClass = &pClasses[ wClass - 1 ];
|
||||
PCLASS pClass = &s_pClasses[ wClass - 1 ];
|
||||
hb_retni( hb_arrayLen( pClass->pClassDatas ) );
|
||||
}
|
||||
}
|
||||
@@ -960,7 +960,7 @@ HARBOUR HB___CLS_CNTDATA( void )
|
||||
WORD wClass = hb_parnl( 1 );
|
||||
|
||||
if( wClass )
|
||||
hb_retni( pClasses[ wClass - 1 ].wDatas );
|
||||
hb_retni( s_pClasses[ wClass - 1 ].wDatas );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -973,7 +973,7 @@ HARBOUR HB___CLS_DECDATA( void )
|
||||
WORD wClass = hb_parnl( 1 );
|
||||
|
||||
if( wClass )
|
||||
hb_retni( pClasses[ wClass - 1 ].wDatas-- );
|
||||
hb_retni( s_pClasses[ wClass - 1 ].wDatas-- );
|
||||
}
|
||||
|
||||
|
||||
@@ -987,6 +987,6 @@ HARBOUR HB___CLS_INCDATA( void )
|
||||
WORD wClass = hb_parnl( 1 );
|
||||
|
||||
if( wClass )
|
||||
hb_retni( ++pClasses[ wClass - 1 ].wDatas );
|
||||
hb_retni( ++s_pClasses[ wClass - 1 ].wDatas );
|
||||
}
|
||||
|
||||
|
||||
@@ -58,87 +58,87 @@ HB_CODEBLOCK_PTR hb_codeblockNew( BYTE * pBuffer,
|
||||
WORD *pLocalPosTable,
|
||||
PHB_SYMB pSymbols )
|
||||
{
|
||||
HB_CODEBLOCK_PTR pCBlock;
|
||||
HB_CODEBLOCK_PTR pCBlock;
|
||||
|
||||
pCBlock =( HB_CODEBLOCK_PTR ) hb_xgrab( sizeof(HB_CODEBLOCK) );
|
||||
pCBlock = ( HB_CODEBLOCK_PTR ) hb_xgrab( sizeof( HB_CODEBLOCK ) );
|
||||
|
||||
/* Store the number of referenced local variables
|
||||
*/
|
||||
pCBlock->wLocals =wLocals;
|
||||
if( wLocals )
|
||||
{
|
||||
/* NOTE: if a codeblock will be created by macro compiler then
|
||||
* wLocal have to be ZERO
|
||||
*/
|
||||
WORD w = 0;
|
||||
PHB_ITEM pLocal;
|
||||
HB_HANDLE hMemvar;
|
||||
|
||||
/* Create a table that will store the values of local variables
|
||||
* accessed in a codeblock
|
||||
*/
|
||||
pCBlock->pLocals =(PHB_ITEM) hb_xgrab( wLocals * sizeof(HB_ITEM) );
|
||||
|
||||
while( wLocals-- )
|
||||
{
|
||||
/* Swap the current value of local variable with the reference to this
|
||||
* value.
|
||||
* TODO: If Harbour will support threads in the future then we need
|
||||
* to implement some kind of semaphores here.
|
||||
/* Store the number of referenced local variables
|
||||
*/
|
||||
pCBlock->wLocals = wLocals;
|
||||
if( wLocals )
|
||||
{
|
||||
/* NOTE: if a codeblock will be created by macro compiler then
|
||||
* wLocal have to be ZERO
|
||||
*/
|
||||
pLocal =stack.pBase +1 +(*pLocalPosTable++);
|
||||
WORD w = 0;
|
||||
PHB_ITEM pLocal;
|
||||
HB_HANDLE hMemvar;
|
||||
|
||||
if( ! IS_MEMVAR( pLocal ) )
|
||||
/* Create a table that will store the values of local variables
|
||||
* accessed in a codeblock
|
||||
*/
|
||||
pCBlock->pLocals = ( PHB_ITEM ) hb_xgrab( wLocals * sizeof( HB_ITEM ) );
|
||||
|
||||
while( wLocals-- )
|
||||
{
|
||||
/* Change the value only if this variable is not referenced
|
||||
* by another codeblock yet.
|
||||
* In this case we have to copy the current value to a global memory
|
||||
* pool so it can be shared by codeblocks
|
||||
/* Swap the current value of local variable with the reference to this
|
||||
* value.
|
||||
* TODO: If Harbour will support threads in the future then we need
|
||||
* to implement some kind of semaphores here.
|
||||
*/
|
||||
pLocal = stack.pBase + 1 + ( *pLocalPosTable++ );
|
||||
|
||||
hMemvar =hb_memvarValueNew( pLocal, FALSE );
|
||||
if( ! IS_MEMVAR( pLocal ) )
|
||||
{
|
||||
/* Change the value only if this variable is not referenced
|
||||
* by another codeblock yet.
|
||||
* In this case we have to copy the current value to a global memory
|
||||
* pool so it can be shared by codeblocks
|
||||
*/
|
||||
|
||||
pLocal->type =IT_BYREF | IT_MEMVAR;
|
||||
pLocal->item.asMemvar.itemsbase =hb_memvarValueBaseAddress();
|
||||
pLocal->item.asMemvar.offset =0;
|
||||
pLocal->item.asMemvar.value =hMemvar;
|
||||
hMemvar = hb_memvarValueNew( pLocal, FALSE );
|
||||
|
||||
hb_memvarValueIncRef( pLocal->item.asMemvar.value );
|
||||
memcpy( pCBlock->pLocals + w, pLocal, sizeof(HB_ITEM) );
|
||||
pLocal->type = IT_BYREF | IT_MEMVAR;
|
||||
pLocal->item.asMemvar.itemsbase = hb_memvarValueBaseAddress();
|
||||
pLocal->item.asMemvar.offset = 0;
|
||||
pLocal->item.asMemvar.value = hMemvar;
|
||||
|
||||
hb_memvarValueIncRef( pLocal->item.asMemvar.value );
|
||||
memcpy( pCBlock->pLocals + w, pLocal, sizeof( HB_ITEM ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This variable is already detached (by another codeblock)
|
||||
* - copy the reference to a value
|
||||
*/
|
||||
/* Increment the reference counter so this value will not be
|
||||
* released if other codeblock will be deleted
|
||||
*/
|
||||
hb_memvarValueIncRef( pLocal->item.asMemvar.value );
|
||||
memcpy( pCBlock->pLocals + w, pLocal, sizeof( HB_ITEM ) );
|
||||
|
||||
}
|
||||
|
||||
++w;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This variable is already detached (by another codeblock)
|
||||
* - copy the reference to a value
|
||||
*/
|
||||
/* Increment the reference counter so this value will not be
|
||||
* released if other codeblock will be deleted
|
||||
*/
|
||||
hb_memvarValueIncRef( pLocal->item.asMemvar.value );
|
||||
memcpy( pCBlock->pLocals + w, pLocal, sizeof(HB_ITEM) );
|
||||
}
|
||||
else
|
||||
pCBlock->pLocals = NULL;
|
||||
|
||||
}
|
||||
/*
|
||||
* The codeblock pcode is stored in static segment.
|
||||
* The only allowed operation on a codeblock is evaluating it then
|
||||
* there is no need to duplicate its pcode - just store the pointer to it
|
||||
*/
|
||||
pCBlock->pCode = pBuffer;
|
||||
|
||||
++w;
|
||||
}
|
||||
}
|
||||
else
|
||||
pCBlock->pLocals =NULL;
|
||||
|
||||
/*
|
||||
* The codeblock pcode is stored in static segment.
|
||||
* The only allowed operation on a codeblock is evaluating it then
|
||||
* there is no need to duplicate its pcode - just store the pointer to it
|
||||
*/
|
||||
pCBlock->pCode = pBuffer;
|
||||
|
||||
pCBlock->pSymbols =pSymbols;
|
||||
pCBlock->lCounter =1;
|
||||
pCBlock->pSymbols = pSymbols;
|
||||
pCBlock->lCounter = 1;
|
||||
|
||||
#ifdef CODEBLOCKDEBUG
|
||||
printf( "\ncodeblock created (%li) %lx", pCBlock->lCounter, pCBlock );
|
||||
printf( "\ncodeblock created (%li) %lx", pCBlock->lCounter, pCBlock );
|
||||
#endif
|
||||
return pCBlock;
|
||||
return pCBlock;
|
||||
}
|
||||
|
||||
/* Delete a codeblock
|
||||
@@ -181,11 +181,11 @@ void hb_codeblockDelete( HB_ITEM_PTR pItem )
|
||||
*/
|
||||
void hb_codeblockEvaluate( HB_ITEM_PTR pItem )
|
||||
{
|
||||
int iStatics = stack.iStatics;
|
||||
int iStatics = stack.iStatics;
|
||||
|
||||
stack.iStatics = pItem->item.asBlock.statics;
|
||||
hb_vmExecute( pItem->item.asBlock.value->pCode, pItem->item.asBlock.value->pSymbols );
|
||||
stack.iStatics = iStatics;
|
||||
stack.iStatics = pItem->item.asBlock.statics;
|
||||
hb_vmExecute( pItem->item.asBlock.value->pCode, pItem->item.asBlock.value->pSymbols );
|
||||
stack.iStatics = iStatics;
|
||||
}
|
||||
|
||||
/* Get local variable referenced in a codeblock
|
||||
@@ -194,16 +194,16 @@ PHB_ITEM hb_codeblockGetVar( PHB_ITEM pItem, LONG iItemPos )
|
||||
{
|
||||
HB_CODEBLOCK_PTR pCBlock = pItem->item.asBlock.value;
|
||||
/* local variables accessed in a codeblock are always stored as reference */
|
||||
return hb_itemUnRef( pCBlock->pLocals -iItemPos -1 );
|
||||
return hb_itemUnRef( pCBlock->pLocals - iItemPos - 1 );
|
||||
}
|
||||
|
||||
/* Get local variable passed by reference
|
||||
*/
|
||||
PHB_ITEM hb_codeblockGetRef( PHB_ITEM pItem, PHB_ITEM pRefer )
|
||||
{
|
||||
HB_CODEBLOCK_PTR pCBlock = pItem->item.asBlock.value;
|
||||
HB_CODEBLOCK_PTR pCBlock = pItem->item.asBlock.value;
|
||||
|
||||
return pCBlock->pLocals -pRefer->item.asRefer.value -1;
|
||||
return pCBlock->pLocals - pRefer->item.asRefer.value - 1;
|
||||
}
|
||||
|
||||
/* Copy the codeblock
|
||||
@@ -212,9 +212,9 @@ PHB_ITEM hb_codeblockGetRef( PHB_ITEM pItem, PHB_ITEM pRefer )
|
||||
*/
|
||||
void hb_codeblockCopy( PHB_ITEM pDest, PHB_ITEM pSource )
|
||||
{
|
||||
pDest->item.asBlock.value =pSource->item.asBlock.value;
|
||||
pDest->item.asBlock.value->lCounter++;
|
||||
#ifdef CODEBLOCKDEBUG
|
||||
printf( "\ncopy a codeblock (%li) %lx", pSource->item.asBlock.value->lCounter, pSource->item.asBlock.value );
|
||||
#endif
|
||||
pDest->item.asBlock.value = pSource->item.asBlock.value;
|
||||
pDest->item.asBlock.value->lCounter++;
|
||||
#ifdef CODEBLOCKDEBUG
|
||||
printf( "\ncopy a codeblock (%li) %lx", pSource->item.asBlock.value->lCounter, pSource->item.asBlock.value );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -61,25 +61,25 @@
|
||||
we can always get the border styles */
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#include <unistd.h>
|
||||
#if defined(__DJGPP__) || defined(__CYGWIN__) || defined(HARBOUR_GCC_OS2)
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#if defined(__DJGPP__) || defined(__CYGWIN__) || defined(HARBOUR_GCC_OS2)
|
||||
#include <io.h>
|
||||
#endif
|
||||
#else
|
||||
#include <io.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#define ACCEPT_BUFFER_LEN 256 /*length of input buffer for ACCEPT command */
|
||||
|
||||
#if defined(OS_UNIX_COMPATIBLE)
|
||||
#define CRLF_BUFFER_LEN 2 /*length of buffer for CR/LF characters */
|
||||
#define CRLF_BUFFER_LEN 2 /*length of buffer for CR/LF characters */
|
||||
#else
|
||||
#define CRLF_BUFFER_LEN 3 /*length of buffer for CR/LF characters */
|
||||
#define CRLF_BUFFER_LEN 3 /*length of buffer for CR/LF characters */
|
||||
#endif
|
||||
|
||||
static USHORT dev_row, dev_col, p_row, p_col;
|
||||
static char CrLf[ CRLF_BUFFER_LEN ];
|
||||
static char s_szCrLf[ CRLF_BUFFER_LEN ];
|
||||
|
||||
void hb_consoleRelease( void )
|
||||
{
|
||||
@@ -91,12 +91,12 @@ void hb_consoleRelease( void )
|
||||
void hb_consoleInitialize( void )
|
||||
{
|
||||
#if defined(OS_DOS_COMPATIBLE)
|
||||
CrLf[ 0 ] = '\r';
|
||||
CrLf[ 1 ] = '\n';
|
||||
CrLf[ 2 ] = '\0';
|
||||
s_szCrLf[ 0 ] = '\r';
|
||||
s_szCrLf[ 1 ] = '\n';
|
||||
s_szCrLf[ 2 ] = '\0';
|
||||
#else
|
||||
CrLf[ 0 ] = '\n';
|
||||
CrLf[ 1 ] = '\0';
|
||||
s_szCrLf[ 0 ] = '\n';
|
||||
s_szCrLf[ 1 ] = '\0';
|
||||
#endif
|
||||
|
||||
p_row = p_col = 0;
|
||||
@@ -122,7 +122,7 @@ void hb_consoleInitialize( void )
|
||||
|
||||
char * hb_consoleGetNewLine( void )
|
||||
{
|
||||
return CrLf;
|
||||
return s_szCrLf;
|
||||
}
|
||||
|
||||
WORD hb_max_row( void )
|
||||
@@ -452,12 +452,12 @@ void hb_setpos( WORD row, WORD col )
|
||||
|
||||
if( row < dev_row || col < dev_col )
|
||||
{
|
||||
printf( CrLf );
|
||||
printf( s_szCrLf );
|
||||
dev_col = 0;
|
||||
dev_row++;
|
||||
}
|
||||
else if( row > dev_row ) dev_col = 0;
|
||||
for( count = dev_row; count < row; count++ ) printf( CrLf );
|
||||
for( count = dev_row; count < row; count++ ) printf( s_szCrLf );
|
||||
for( count = dev_col; count < col; count++ ) printf( " " );
|
||||
#endif
|
||||
|
||||
@@ -477,7 +477,7 @@ void hb_devpos( WORD row, WORD col )
|
||||
write( hb_set_printhan, "\x0C", 1 );
|
||||
p_row = p_col = 0;
|
||||
}
|
||||
for( count = p_row; count < row; count++ ) write( hb_set_printhan, CrLf, CRLF_BUFFER_LEN-1 );
|
||||
for( count = p_row; count < row; count++ ) write( hb_set_printhan, s_szCrLf, CRLF_BUFFER_LEN-1 );
|
||||
if( row > p_row ) p_col = 0;
|
||||
col += hb_set.HB_SET_MARGIN;
|
||||
for( count = p_col; count < col; count++ ) write( hb_set_printhan, " ", 1 );
|
||||
@@ -527,7 +527,7 @@ HARBOUR HB_QOUT( void )
|
||||
{
|
||||
WORD count;
|
||||
|
||||
hb_altout( CrLf, CRLF_BUFFER_LEN - 1 );
|
||||
hb_altout( s_szCrLf, CRLF_BUFFER_LEN - 1 );
|
||||
|
||||
if( hb_set.HB_SET_PRINTER && hb_set_printhan >= 0 )
|
||||
{
|
||||
@@ -725,7 +725,7 @@ HARBOUR HB_SCROLL( void ) /* Scrolls a screen region (requires the GT API) */
|
||||
{
|
||||
WORD count;
|
||||
dev_row = iMR;
|
||||
for( count = 0; count < dev_row ; count++ ) printf( CrLf );
|
||||
for( count = 0; count < dev_row ; count++ ) printf( s_szCrLf );
|
||||
dev_row = dev_col = 0;
|
||||
}
|
||||
#endif
|
||||
@@ -1065,7 +1065,7 @@ HARBOUR HB___ACCEPT( void ) /* Internal Clipper function used in ACCEPT command
|
||||
|
||||
if( hb_pcount() == 1 ) /* cPrompt passed */
|
||||
{
|
||||
hb_altout( CrLf, CRLF_BUFFER_LEN - 1 );
|
||||
hb_altout( s_szCrLf, CRLF_BUFFER_LEN - 1 );
|
||||
hb_altout( szPrompt, len );
|
||||
}
|
||||
#ifdef OS_UNIX_COMPATIBLE
|
||||
|
||||
@@ -44,10 +44,10 @@
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__DJGPP__)
|
||||
#include <dos.h>
|
||||
#include <dos.h>
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
#include <sys\timeb.h>
|
||||
#include <sys\timeb.h>
|
||||
#endif
|
||||
#ifndef HARBOUR_STRICT_CLIPPER_COMPATIBILITY
|
||||
#define HB_OPTIMIZE_DTOS
|
||||
|
||||
@@ -25,117 +25,117 @@
|
||||
#include "itemapi.h"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#if defined(__DJGPP__)
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#if defined(__DJGPP__)
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#endif
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
#include <time.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__) || defined(_MSC_VER)
|
||||
#include <sys/stat.h>
|
||||
#include <share.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <errno.h>
|
||||
#include <direct.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <share.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <errno.h>
|
||||
#include <direct.h>
|
||||
#include <time.h>
|
||||
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#endif
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__IBMCPP__)
|
||||
#include <sys/stat.h>
|
||||
/* #include <share.h> */
|
||||
/* #include <fcntl.h> */
|
||||
/* #include <io.h> */
|
||||
/* #include <errno.h> */
|
||||
/* #include <direct.h> */
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
/* #include <share.h> */
|
||||
/* #include <fcntl.h> */
|
||||
/* #include <io.h> */
|
||||
/* #include <errno.h> */
|
||||
/* #include <direct.h> */
|
||||
#include <time.h>
|
||||
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#endif
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#include <sys\stat.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <share.h>
|
||||
#include <dirent.h>
|
||||
#include <dir.h>
|
||||
#include <dos.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <sys\stat.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <share.h>
|
||||
#include <dirent.h>
|
||||
#include <dir.h>
|
||||
#include <dos.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#ifndef S_IEXEC
|
||||
#define S_IEXEC 0x0040 /* owner may execute <directory search> */
|
||||
#endif
|
||||
#ifndef S_IRWXU
|
||||
#define S_IRWXU 0x01c0 /* RWE permissions mask for owner */
|
||||
#endif
|
||||
#ifndef S_IRUSR
|
||||
#define S_IRUSR 0x0100 /* owner may read */
|
||||
#endif
|
||||
#ifndef S_IWUSR
|
||||
#define S_IWUSR 0x0080 /* owner may write */
|
||||
#endif
|
||||
#ifndef S_IXUSR
|
||||
#define S_IXUSR 0x0040 /* owner may execute <directory search> */
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#ifndef S_IEXEC
|
||||
#define S_IEXEC 0x0040 /* owner may execute <directory search> */
|
||||
#endif
|
||||
#ifndef S_IRWXU
|
||||
#define S_IRWXU 0x01c0 /* RWE permissions mask for owner */
|
||||
#endif
|
||||
#ifndef S_IRUSR
|
||||
#define S_IRUSR 0x0100 /* owner may read */
|
||||
#endif
|
||||
#ifndef S_IWUSR
|
||||
#define S_IWUSR 0x0080 /* owner may write */
|
||||
#endif
|
||||
#ifndef S_IXUSR
|
||||
#define S_IXUSR 0x0040 /* owner may execute <directory search> */
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(FA_RDONLY)
|
||||
#define FA_RDONLY 1
|
||||
#define FA_HIDDEN 2
|
||||
#define FA_SYSTEM 4
|
||||
#define FA_LABEL 8
|
||||
#define FA_DIREC 16
|
||||
#define FA_ARCH 32
|
||||
#define FA_RDONLY 1
|
||||
#define FA_HIDDEN 2
|
||||
#define FA_SYSTEM 4
|
||||
#define FA_LABEL 8
|
||||
#define FA_DIREC 16
|
||||
#define FA_ARCH 32
|
||||
#endif
|
||||
/* this may not work, but lets find out (only implimented for msvc) */
|
||||
#if !defined(FA_ENCRYPTED)
|
||||
#define FA_ENCRYPTED 64
|
||||
#define FA_NORMAL 128
|
||||
#define FA_TEMPORARY 256
|
||||
#define FA_SPARSE 512
|
||||
#define FA_REPARSE 1024
|
||||
#define FA_COMPRESSED 2048
|
||||
#define FA_OFFLINE 4096
|
||||
#define FA_NOTINDEXED 8192
|
||||
#define FA_VOLCOMP 32764
|
||||
#define FA_ENCRYPTED 64
|
||||
#define FA_NORMAL 128
|
||||
#define FA_TEMPORARY 256
|
||||
#define FA_SPARSE 512
|
||||
#define FA_REPARSE 1024
|
||||
#define FA_COMPRESSED 2048
|
||||
#define FA_OFFLINE 4096
|
||||
#define FA_NOTINDEXED 8192
|
||||
#define FA_VOLCOMP 32764
|
||||
#endif
|
||||
|
||||
HARBOUR HB_DIRECTORY( void )
|
||||
{
|
||||
#if defined(HAVE_POSIX_IO)
|
||||
|
||||
PHB_ITEM arg1_it = hb_param(1,IT_STRING);
|
||||
PHB_ITEM arg2_it = hb_param(2,IT_STRING);
|
||||
PHB_ITEM arg1_it = hb_param( 1, IT_STRING );
|
||||
PHB_ITEM arg2_it = hb_param( 2, IT_STRING );
|
||||
|
||||
struct stat statbuf;
|
||||
struct tm *ft;
|
||||
struct tm * ft;
|
||||
|
||||
#if defined(_MSC_VER )
|
||||
struct _finddata_t entry;
|
||||
@@ -151,19 +151,19 @@ HARBOUR HB_DIRECTORY( void )
|
||||
DIR * dir;
|
||||
#endif
|
||||
|
||||
char fullfile[_POSIX_PATH_MAX+1];
|
||||
char filename[_POSIX_PATH_MAX+1];
|
||||
char pattern[_POSIX_PATH_MAX+1];
|
||||
char dirname[_POSIX_PATH_MAX+1];
|
||||
char string[_POSIX_PATH_MAX+1];
|
||||
char pfname[_POSIX_PATH_MAX+1];
|
||||
char pfext[_POSIX_PATH_MAX+1];
|
||||
char fname[_POSIX_PATH_MAX+1];
|
||||
char fext[_POSIX_PATH_MAX+1];
|
||||
char filesize[10];
|
||||
char ddate[9];
|
||||
char ttime[9];
|
||||
char aatrib[8];
|
||||
char fullfile[ _POSIX_PATH_MAX + 1 ];
|
||||
char filename[ _POSIX_PATH_MAX + 1 ];
|
||||
char pattern[ _POSIX_PATH_MAX + 1 ];
|
||||
char dirname[ _POSIX_PATH_MAX + 1 ];
|
||||
char string[ _POSIX_PATH_MAX + 1 ];
|
||||
char pfname[ _POSIX_PATH_MAX + 1 ];
|
||||
char pfext[ _POSIX_PATH_MAX + 1 ];
|
||||
char fname[ _POSIX_PATH_MAX + 1 ];
|
||||
char fext[ _POSIX_PATH_MAX + 1 ];
|
||||
char filesize[ 10 ];
|
||||
char ddate[ 9 ];
|
||||
char ttime[ 9 ];
|
||||
char aatrib[ 8 ];
|
||||
int attrib;
|
||||
long fsize;
|
||||
time_t ftime;
|
||||
@@ -178,178 +178,178 @@ HARBOUR HB_DIRECTORY( void )
|
||||
PHB_ITEM ptime;
|
||||
PHB_ITEM pattr;
|
||||
|
||||
dirname[0] = '\0';
|
||||
pattern[0] = '\0';
|
||||
dirname[ 0 ] = '\0';
|
||||
pattern[ 0 ] = '\0';
|
||||
|
||||
if( arg1_it )
|
||||
{
|
||||
strcpy(string, hb_parc(1));
|
||||
pos = strrchr(string,OS_PATH_DELIMITER);
|
||||
strcpy( string, hb_parc( 1 ) );
|
||||
pos = strrchr( string, OS_PATH_DELIMITER );
|
||||
if( pos )
|
||||
{
|
||||
strcpy(pattern,(pos+1));
|
||||
*(pos+1) = '\0';
|
||||
strcpy(dirname,string);
|
||||
strcpy( pattern, pos + 1 );
|
||||
*( pos + 1 ) = '\0';
|
||||
strcpy( dirname, string );
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(pattern,string);
|
||||
strcpy(dirname,".X");
|
||||
dirname[1] = OS_PATH_DELIMITER;
|
||||
strcpy( pattern, string );
|
||||
strcpy( dirname, ".X" );
|
||||
dirname[ 1 ] = OS_PATH_DELIMITER;
|
||||
}
|
||||
}
|
||||
if (strlen(pattern) < 1)
|
||||
strcpy(pattern,"*.*");
|
||||
iDirnameLen =strlen(dirname);
|
||||
if( strlen( pattern ) < 1 )
|
||||
strcpy( pattern, "*.*" );
|
||||
iDirnameLen = strlen( dirname );
|
||||
if( iDirnameLen < 1 )
|
||||
{
|
||||
strcpy(dirname,".X");
|
||||
dirname[1] = OS_PATH_DELIMITER;
|
||||
iDirnameLen =2;
|
||||
strcpy( dirname, ".X" );
|
||||
dirname[ 1 ] = OS_PATH_DELIMITER;
|
||||
iDirnameLen = 2;
|
||||
}
|
||||
|
||||
if (strlen(pattern) > 0)
|
||||
if( strlen( pattern ) > 0 )
|
||||
{
|
||||
strcpy(string,pattern);
|
||||
pos = strrchr(string,'.');
|
||||
strcpy( string, pattern );
|
||||
pos = strrchr( string, '.' );
|
||||
if( pos )
|
||||
{
|
||||
strcpy(pfext,(pos+1));
|
||||
strcpy( pfext, pos + 1 );
|
||||
*pos = '\0';
|
||||
strcpy(pfname,string);
|
||||
strcpy( pfname, string );
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(pfname,string);
|
||||
pfext[0] = '\0';
|
||||
strcpy( pfname, string );
|
||||
pfext[ 0 ] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* redundant
|
||||
if (strlen(pfext) < 1)
|
||||
pfext[0] = '\0';
|
||||
if( strlen( pfext ) < 1 )
|
||||
pfext[ 0 ] = '\0';
|
||||
*/
|
||||
|
||||
if (strlen(pfname) < 1)
|
||||
strcpy(pfname,"*");
|
||||
if( strlen( pfname ) < 1 )
|
||||
strcpy( pfname, "*" );
|
||||
|
||||
/* debug code
|
||||
printf("\n dirname pattern %s %s ",dirname,pattern);
|
||||
printf("\n pfname pfext %s %s ",pfname,pfext);
|
||||
while(0==getchar());
|
||||
printf( "\n dirname pattern %s %s ", dirname, pattern );
|
||||
printf( "\n pfname pfext %s %s ", pfname, pfext );
|
||||
while( 0 == getchar() );
|
||||
*/
|
||||
/* should have drive,directory in dirname and filespec in pattern */
|
||||
|
||||
tzset();
|
||||
pdir = hb_itemArrayNew(0);
|
||||
pdir = hb_itemArrayNew( 0 );
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
strcpy(string,dirname);
|
||||
strcat(string,pattern);
|
||||
if( (hFile = _findfirst( string, &entry )) != -1L )
|
||||
strcpy( string, dirname );
|
||||
strcat( string, pattern );
|
||||
if( ( hFile = _findfirst( string, &entry ) ) != -1L )
|
||||
{
|
||||
|
||||
do
|
||||
{
|
||||
strcpy(string,entry.name);
|
||||
strcpy( string, entry.name );
|
||||
#elif defined(__IBMCPP__)
|
||||
strcpy(string,dirname);
|
||||
strcat(string,pattern);
|
||||
strcpy( string, dirname );
|
||||
strcat( string, pattern );
|
||||
if( DosFindFirst( string, &hFind, fileTypes, &entry, findSize, &findCount, FIL_STANDARD ) == NO_ERROR && findCount > 0 )
|
||||
{
|
||||
do
|
||||
{
|
||||
strcpy(string,entry.achName);
|
||||
strcpy( string, entry.achName );
|
||||
#else
|
||||
#if defined(__WATCOMC__)
|
||||
/* opendir in Watcom doesn't like the path delimiter at the end of a string */
|
||||
dirname[ iDirnameLen ] ='.';
|
||||
dirname[ iDirnameLen+1 ] ='\x0';
|
||||
dirname[ iDirnameLen ] = '.';
|
||||
dirname[ iDirnameLen+1 ] = '\x0';
|
||||
#endif
|
||||
dir = opendir( dirname );
|
||||
#if defined(__WATCOMC__)
|
||||
dirname[ iDirnameLen ] ='\x0';
|
||||
#endif
|
||||
if (NULL == dir)
|
||||
dirname[ iDirnameLen ] = '\x0';
|
||||
#endif
|
||||
if( NULL == dir )
|
||||
{
|
||||
/* TODO: proper error handling */
|
||||
printf("\n invalid dirname %s ",dirname);
|
||||
while(0==getchar());
|
||||
printf( "\n invalid dirname %s ", dirname );
|
||||
while( 0 == getchar() );
|
||||
}
|
||||
|
||||
/* now put everything into an array */
|
||||
while ((entry = readdir( dir )) != NULL)
|
||||
while( ( entry = readdir( dir ) ) != NULL )
|
||||
{
|
||||
strcpy(string,entry->d_name);
|
||||
strcpy( string, entry->d_name );
|
||||
|
||||
#endif
|
||||
pos = strrchr(string,'.');
|
||||
pos = strrchr( string, '.' );
|
||||
if( pos )
|
||||
{
|
||||
strcpy(fext,(pos+1));
|
||||
strcpy( fext, pos + 1 );
|
||||
*pos = '\0';
|
||||
strcpy(fname,string);
|
||||
strcpy( fname, string );
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(fname,string);
|
||||
fext[0] = '\0';
|
||||
strcpy( fname, string );
|
||||
fext[ 0 ] = '\0';
|
||||
}
|
||||
|
||||
/* redundant
|
||||
if (strlen(fext) < 1)
|
||||
fext[0] = '\0';
|
||||
if( strlen( fext ) < 1 )
|
||||
fext[ 0 ] = '\0';
|
||||
*/
|
||||
|
||||
if (strlen(fname) < 1)
|
||||
strcpy(fname,"*");
|
||||
if( strlen( fname ) < 1 )
|
||||
strcpy( fname, "*" );
|
||||
|
||||
/* debug code
|
||||
printf("\n fname fext %s %s ",fname,fext);
|
||||
while(0==getchar());
|
||||
printf( "\n fname fext %s %s ", fname, fext );
|
||||
while( 0 == getchar() );
|
||||
*/
|
||||
if (hb_strMatchRegExp( fname,pfname) && hb_strMatchRegExp( fext,pfext))
|
||||
if( hb_strMatchRegExp( fname, pfname ) && hb_strMatchRegExp( fext, pfext ) )
|
||||
{
|
||||
attrib = 0;
|
||||
aatrib[0] = '\0';
|
||||
filesize[0] = '\0';
|
||||
attrib = 0;
|
||||
aatrib[ 0 ] = '\0';
|
||||
filesize[ 0 ] = '\0';
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
strcpy(filename,entry.name);
|
||||
strcpy( filename, entry.name );
|
||||
#elif defined(__IBMCPP__)
|
||||
strcpy( filename, entry.achName );
|
||||
#else
|
||||
strcpy(filename,entry->d_name);
|
||||
strcpy( filename, entry->d_name );
|
||||
#endif
|
||||
strcpy(fullfile,dirname);
|
||||
strcat(fullfile,filename);
|
||||
strcpy( fullfile, dirname );
|
||||
strcat( fullfile, filename );
|
||||
|
||||
if (-1 == stat(fullfile,&statbuf))
|
||||
if( -1 == stat( fullfile, &statbuf ) )
|
||||
{
|
||||
/* TODO: proper error handling */
|
||||
printf("\n invalid file %s ",fullfile);
|
||||
while(0==getchar());
|
||||
printf( "\n invalid file %s ", fullfile );
|
||||
while( 0 == getchar() );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This might be a problem under Novell when the file is a directory */
|
||||
/* needs test */
|
||||
fsize = statbuf.st_size;
|
||||
sprintf(filesize, "%ld", fsize);
|
||||
sprintf( filesize, "%ld", fsize );
|
||||
|
||||
ftime = statbuf.st_mtime;
|
||||
ft = localtime(&ftime);
|
||||
sprintf(ddate, "%04d%02d%02d",
|
||||
ft->tm_year+1900, ft->tm_mon + 1, ft->tm_mday);
|
||||
ft = localtime( &ftime );
|
||||
sprintf( ddate, "%04d%02d%02d",
|
||||
ft->tm_year + 1900, ft->tm_mon + 1, ft->tm_mday );
|
||||
|
||||
sprintf(ttime, "%02d:%02d:%02d",
|
||||
ft->tm_hour, ft->tm_min, ft->tm_sec);
|
||||
sprintf( ttime, "%02d:%02d:%02d",
|
||||
ft->tm_hour, ft->tm_min, ft->tm_sec );
|
||||
|
||||
/* debug code
|
||||
|
||||
printf("\n name date time %s %s %s ",filename,ddate,ttime);
|
||||
while(0==getchar());
|
||||
printf( "\n name date time %s %s %s ", filename, ddate, ttime );
|
||||
while( 0 == getchar() );
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -357,19 +357,19 @@ HARBOUR HB_DIRECTORY( void )
|
||||
#if defined(OS_UNIX_COMPATIBLE)
|
||||
/* GNU C on Linux or on other UNIX */
|
||||
aatrib[ 0 ] = '\0';
|
||||
if( S_ISREG(statbuf.st_mode) )
|
||||
if( S_ISREG( statbuf.st_mode ) )
|
||||
strcat( aatrib, "A" );
|
||||
if( S_ISDIR(statbuf.st_mode) )
|
||||
if( S_ISDIR( statbuf.st_mode ) )
|
||||
strcat( aatrib, "D" );
|
||||
if( S_ISLNK(statbuf.st_mode) )
|
||||
if( S_ISLNK( statbuf.st_mode ) )
|
||||
strcat( aatrib, "L" );
|
||||
if( S_ISCHR(statbuf.st_mode) )
|
||||
if( S_ISCHR( statbuf.st_mode ) )
|
||||
strcat( aatrib, "C" );
|
||||
if( S_ISBLK(statbuf.st_mode) )
|
||||
if( S_ISBLK( statbuf.st_mode ) )
|
||||
strcat( aatrib, "B" );
|
||||
if( S_ISFIFO(statbuf.st_mode) )
|
||||
if( S_ISFIFO( statbuf.st_mode ) )
|
||||
strcat( aatrib, "F" );
|
||||
if( S_ISSOCK(statbuf.st_mode) )
|
||||
if( S_ISSOCK( statbuf.st_mode ) )
|
||||
strcat( aatrib, "K" );
|
||||
#else
|
||||
#if defined(__IBMCPP__)
|
||||
@@ -388,84 +388,84 @@ HARBOUR HB_DIRECTORY( void )
|
||||
#if defined(_MSC_VER)
|
||||
attrib = entry.attrib;
|
||||
#elif defined(__BORLANDC__) || defined(__DJGPP__)
|
||||
attrib = _chmod(fullfile,0);
|
||||
attrib = _chmod( fullfile, 0 );
|
||||
#else
|
||||
attrib = 0;
|
||||
#endif
|
||||
if (attrib & FA_ARCH)
|
||||
strcat(aatrib,"A");
|
||||
if (attrib & FA_DIREC)
|
||||
strcat(aatrib,"D");
|
||||
if (attrib & FA_HIDDEN)
|
||||
strcat(aatrib,"H");
|
||||
if (attrib & FA_RDONLY)
|
||||
strcat(aatrib,"R");
|
||||
if (attrib & FA_SYSTEM)
|
||||
strcat(aatrib,"S");
|
||||
if (attrib & FA_LABEL)
|
||||
if( attrib & FA_ARCH )
|
||||
strcat( aatrib, "A" );
|
||||
if( attrib & FA_DIREC )
|
||||
strcat( aatrib,"D" );
|
||||
if( attrib & FA_HIDDEN )
|
||||
strcat( aatrib,"H" );
|
||||
if( attrib & FA_RDONLY )
|
||||
strcat( aatrib,"R" );
|
||||
if( attrib & FA_SYSTEM )
|
||||
strcat( aatrib,"S" );
|
||||
if( attrib & FA_LABEL )
|
||||
{
|
||||
strcat(aatrib,"V");
|
||||
if (attrib & FA_VOLCOMP)
|
||||
strcat(aatrib,"L"); /* volume supports compression. */
|
||||
strcat( aatrib, "V" );
|
||||
if( attrib & FA_VOLCOMP )
|
||||
strcat( aatrib, "L" ); /* volume supports compression. */
|
||||
}
|
||||
/* some of these are known to work under NT - I picked the letters to use.*/
|
||||
/* needs testing on a Novell drive */
|
||||
#if defined(USE_NT)
|
||||
if (attrib & FA_ENCRYPTED)
|
||||
strcat(aatrib,"E");
|
||||
/* if (attrib & FA_NORMAL) */
|
||||
/* strcat(aatrib,"N"); */
|
||||
if (attrib & FA_TEMPORARY)
|
||||
strcat(aatrib,"T");
|
||||
if (attrib & FA_SPARSE)
|
||||
strcat(aatrib,"P");
|
||||
if (attrib & FA_REPARSE)
|
||||
strcat(aatrib,"Z");
|
||||
if (attrib & FA_COMPRESSED)
|
||||
strcat(aatrib,"C");
|
||||
if (attrib & FA_OFFLINE)
|
||||
strcat(aatrib,"O");
|
||||
if (attrib & FA_NOTINDEXED)
|
||||
strcat(aatrib,"X");
|
||||
if( attrib & FA_ENCRYPTED )
|
||||
strcat( aatrib, "E" );
|
||||
/* if( attrib & FA_NORMAL ) */
|
||||
/* strcat( aatrib, "N" ); */
|
||||
if( attrib & FA_TEMPORARY )
|
||||
strcat( aatrib, "T" );
|
||||
if( attrib & FA_SPARSE )
|
||||
strcat( aatrib, "P" );
|
||||
if( attrib & FA_REPARSE )
|
||||
strcat( aatrib, "Z" );
|
||||
if( attrib & FA_COMPRESSED )
|
||||
strcat( aatrib, "C" );
|
||||
if( attrib & FA_OFFLINE )
|
||||
strcat( aatrib, "O" );
|
||||
if( attrib & FA_NOTINDEXED )
|
||||
strcat( aatrib, "X" );
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
/* TODO: attribute match rtn */
|
||||
pos = string;
|
||||
if( arg2_it && hb_parclen(2) >= 1)
|
||||
if( arg2_it && hb_parclen( 2 ) >= 1 )
|
||||
{
|
||||
strcpy(string, hb_parc(2));
|
||||
while (*pos != '\0')
|
||||
strcpy( string, hb_parc( 2 ) );
|
||||
while( *pos != '\0' )
|
||||
{
|
||||
*pos = (char)toupper(*pos);
|
||||
*pos = ( char ) toupper( *pos );
|
||||
pos++;
|
||||
}
|
||||
pos = strchr(string,*aatrib);
|
||||
pos = strchr( string, *aatrib );
|
||||
}
|
||||
|
||||
if ( pos )
|
||||
if( pos )
|
||||
{
|
||||
/* array cname, csize, ddate, ctime, cattributes */
|
||||
pfilename = hb_itemPutC(NULL,filename);
|
||||
psize = hb_itemPutC(NULL,filesize);
|
||||
pdate = hb_itemPutDS(NULL,ddate);
|
||||
ptime = hb_itemPutC(NULL,ttime);
|
||||
pattr = hb_itemPutC(NULL,aatrib);
|
||||
psubarray = hb_itemArrayNew(5);
|
||||
hb_itemArrayPut(psubarray,1,pfilename);
|
||||
hb_itemArrayPut(psubarray,2,psize);
|
||||
hb_itemArrayPut(psubarray,3,pdate);
|
||||
hb_itemArrayPut(psubarray,4,ptime);
|
||||
hb_itemArrayPut(psubarray,5,pattr);
|
||||
pfilename = hb_itemPutC( NULL, filename );
|
||||
psize = hb_itemPutC( NULL, filesize );
|
||||
pdate = hb_itemPutDS( NULL, ddate );
|
||||
ptime = hb_itemPutC( NULL, ttime );
|
||||
pattr = hb_itemPutC( NULL, aatrib );
|
||||
psubarray = hb_itemArrayNew( 5 );
|
||||
hb_itemArrayPut( psubarray, 1, pfilename );
|
||||
hb_itemArrayPut( psubarray, 2, psize );
|
||||
hb_itemArrayPut( psubarray, 3, pdate );
|
||||
hb_itemArrayPut( psubarray, 4, ptime );
|
||||
hb_itemArrayPut( psubarray, 5, pattr );
|
||||
|
||||
hb_arrayAdd(pdir,psubarray);
|
||||
hb_arrayAdd( pdir, psubarray );
|
||||
|
||||
hb_itemRelease(pfilename);
|
||||
hb_itemRelease(psize);
|
||||
hb_itemRelease(pdate);
|
||||
hb_itemRelease(ptime);
|
||||
hb_itemRelease(pattr);
|
||||
hb_itemRelease(psubarray);
|
||||
hb_itemRelease( pfilename );
|
||||
hb_itemRelease( psize );
|
||||
hb_itemRelease( pdate );
|
||||
hb_itemRelease( ptime );
|
||||
hb_itemRelease( pattr );
|
||||
hb_itemRelease( psubarray );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -473,7 +473,7 @@ HARBOUR HB_DIRECTORY( void )
|
||||
while( _findnext( hFile, &entry ) == 0 );
|
||||
_findclose( hFile );
|
||||
#elif defined(__IBMCPP__)
|
||||
while( DosFindNext (hFind, &entry, findSize, &findCount) == NO_ERROR && findCount > 0 );
|
||||
while( DosFindNext( hFind, &entry, findSize, &findCount ) == NO_ERROR && findCount > 0 );
|
||||
DosFindClose( hFind );
|
||||
#else
|
||||
closedir( dir );
|
||||
@@ -481,7 +481,7 @@ HARBOUR HB_DIRECTORY( void )
|
||||
|
||||
hb_itemCopy( &stack.Return, pdir ); /* DIRECTORY() returns an array */
|
||||
|
||||
hb_itemRelease(pdir);
|
||||
hb_itemRelease( pdir );
|
||||
|
||||
#if defined(_MSC_VER) || defined(__IBMCPP__)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
be ahead of any and all #include statements!
|
||||
*/
|
||||
#ifdef __IBMCPP__
|
||||
#define INCL_DOSMISC
|
||||
#define INCL_DOSMISC
|
||||
#endif
|
||||
|
||||
#include "extend.h"
|
||||
@@ -20,47 +20,47 @@
|
||||
#include "hbver.h"
|
||||
|
||||
#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__MSC__) || defined(_MSC_VER) || defined(__DJGPP__)
|
||||
#include <dos.h>
|
||||
#include <stdlib.h>
|
||||
#include <dos.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__DJGPP__)
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#include <i86.h>
|
||||
#if defined(__386__) && !defined(__WINDOWS_386__)
|
||||
#define INT_86 int386
|
||||
#else
|
||||
#define INT_86 int86
|
||||
#endif
|
||||
#include <i86.h>
|
||||
#if defined(__386__) && !defined(__WINDOWS_386__)
|
||||
#define INT_86 int386
|
||||
#else
|
||||
#define INT_86 int86
|
||||
#endif
|
||||
#else
|
||||
#if defined(__EMX__)
|
||||
#define INT_86 _int86
|
||||
#else
|
||||
#define INT_86 int86
|
||||
#endif
|
||||
#if defined(__EMX__)
|
||||
#define INT_86 _int86
|
||||
#else
|
||||
#define INT_86 int86
|
||||
#endif
|
||||
#endif
|
||||
|
||||
HARBOUR HB_OS(void)
|
||||
HARBOUR HB_OS( void )
|
||||
{
|
||||
#ifdef __MPW__
|
||||
/* TODO: not implemented yet */
|
||||
hb_retc ( "MacOS" );
|
||||
hb_retc( "MacOS" );
|
||||
#else
|
||||
int hb_osmajor = -1, hb_osminor = -1, hb_osletter = -1;
|
||||
char * hb_os = 0;
|
||||
char version [128];
|
||||
char * hb_os = NULL;
|
||||
char version[ 128 ];
|
||||
#ifdef __IBMCPP__
|
||||
|
||||
unsigned long aulQSV [QSV_MAX] = {0};
|
||||
APIRET rc= DosQuerySysInfo (1L, QSV_MAX, (void *) aulQSV, sizeof (ULONG) * QSV_MAX);
|
||||
if (!rc)
|
||||
unsigned long aulQSV[ QSV_MAX ] = { 0 };
|
||||
APIRET rc = DosQuerySysInfo( 1L, QSV_MAX, ( void * ) aulQSV, sizeof( ULONG ) * QSV_MAX );
|
||||
if( ! rc )
|
||||
{
|
||||
hb_osmajor = aulQSV [QSV_VERSION_MAJOR] / 10;
|
||||
hb_osminor = aulQSV [QSV_VERSION_MINOR];
|
||||
hb_osletter = (aulQSV [QSV_VERSION_REVISION] > 0 && aulQSV [QSV_VERSION_REVISION] < 26) ? '@' + aulQSV [QSV_VERSION_REVISION] : 0;
|
||||
hb_osmajor = aulQSV[ QSV_VERSION_MAJOR ] / 10;
|
||||
hb_osminor = aulQSV[ QSV_VERSION_MINOR ];
|
||||
hb_osletter = ( aulQSV[ QSV_VERSION_REVISION ] > 0 && aulQSV[ QSV_VERSION_REVISION ] < 26 ) ? '@' + aulQSV[ QSV_VERSION_REVISION ] : 0;
|
||||
}
|
||||
hb_os = "OS/2";
|
||||
|
||||
@@ -91,21 +91,21 @@ HARBOUR HB_OS(void)
|
||||
hb_os = "Windows";
|
||||
#else
|
||||
#if defined(__MSC__) || defined(_MSC_VER)
|
||||
if (_osmode == _WIN_MODE)
|
||||
if( _osmode == _WIN_MODE )
|
||||
{
|
||||
hb_os = "Windows";
|
||||
hb_osmajor = _osmajor;
|
||||
hb_osminor = _osminor
|
||||
hb_osmajor = _osmajor;
|
||||
hb_osminor = _osminor
|
||||
hb_osletter = 0;
|
||||
}
|
||||
#else
|
||||
/* detect Windows */
|
||||
_AX = 0x160A;
|
||||
geninterrupt(0x2F);
|
||||
if(_AX == 0)
|
||||
geninterrupt( 0x2F );
|
||||
if( _AX == 0 )
|
||||
{
|
||||
hb_osmajor = _BX / 256;
|
||||
hb_osminor = _BX % 256;
|
||||
hb_osmajor = _BX / 256;
|
||||
hb_osminor = _BX % 256;
|
||||
hb_osletter = 0;
|
||||
hb_os = "Windows 95/98";
|
||||
}
|
||||
@@ -113,8 +113,8 @@ HARBOUR HB_OS(void)
|
||||
else
|
||||
{
|
||||
hb_os = "DOS";
|
||||
hb_osmajor = _osmajor;
|
||||
hb_osminor = _osminor;
|
||||
hb_osmajor = _osmajor;
|
||||
hb_osminor = _osminor;
|
||||
hb_osletter = 0;
|
||||
}
|
||||
|
||||
@@ -129,34 +129,34 @@ HARBOUR HB_OS(void)
|
||||
|
||||
INT_86( 0x21, ®s, ®s );
|
||||
|
||||
if(regs.h.al >= 10)
|
||||
if( regs.h.al >= 10 )
|
||||
{
|
||||
hb_os = "OS/2";
|
||||
if (regs.h.al == 20 && regs.h.ah > 20)
|
||||
if( regs.h.al == 20 && regs.h.ah > 20 )
|
||||
{
|
||||
hb_osmajor = regs.h.ah / 10;
|
||||
hb_osminor = regs.h.ah % 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_osmajor = regs.h.al / 10;
|
||||
hb_osminor = regs.h.ah;
|
||||
hb_osmajor = regs.h.al / 10;
|
||||
hb_osminor = regs.h.ah;
|
||||
}
|
||||
hb_osletter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_osmajor = _osmajor;
|
||||
hb_osminor = _osminor;
|
||||
hb_osmajor = _osmajor;
|
||||
hb_osminor = _osminor;
|
||||
regs.w.ax = 0x160A;
|
||||
|
||||
INT_86( 0x2F, ®s, ®s );
|
||||
|
||||
if( regs.w.ax == 0)
|
||||
if( regs.w.ax == 0 )
|
||||
{
|
||||
hb_os = "Windows";
|
||||
hb_osmajor = regs.w.bx / 256;
|
||||
hb_osminor = regs.w.bx % 256;
|
||||
hb_osmajor = regs.w.bx / 256;
|
||||
hb_osminor = regs.w.bx % 256;
|
||||
hb_osletter = 0;
|
||||
}
|
||||
else
|
||||
@@ -167,8 +167,8 @@ HARBOUR HB_OS(void)
|
||||
}
|
||||
#endif /* __TURBOC__ or __BORLANDC__ or __MSC__ 0r __DJGPP__ */
|
||||
#ifdef __DJGPP__
|
||||
hb_os = hb_xgrab (strlen (_os_flavor) + 1);
|
||||
strcpy (hb_os, _os_flavor);
|
||||
hb_os = hb_xgrab( strlen( _os_flavor ) + 1 );
|
||||
strcpy( hb_os, _os_flavor );
|
||||
hb_osmajor = _osmajor;
|
||||
hb_osminor = _osminor;
|
||||
hb_osletter = 0;
|
||||
@@ -179,49 +179,51 @@ HARBOUR HB_OS(void)
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* __IBMCPP__ */
|
||||
|
||||
if (!hb_os) strcpy (version, "Unknown");
|
||||
else if (hb_osmajor == -1) strcpy (version, hb_os);
|
||||
else if (hb_osmajor == -2 ) { /* NOP */ }
|
||||
else sprintf (version, "%s %d.%02d%c", hb_os, hb_osmajor, hb_osminor, hb_osletter);
|
||||
hb_retc (version);
|
||||
if( ! hb_os ) strcpy( version, "Unknown" );
|
||||
else if( hb_osmajor == -1 ) strcpy( version, hb_os );
|
||||
else if( hb_osmajor == -2 ) { /* NOP */ }
|
||||
else sprintf( version, "%s %d.%02d%c", hb_os, hb_osmajor, hb_osminor, hb_osletter );
|
||||
hb_retc( version );
|
||||
#ifdef __DJGPP__
|
||||
hb_xfree (hb_os);
|
||||
hb_xfree( hb_os );
|
||||
#endif
|
||||
|
||||
#endif /* __MPW__ */
|
||||
}
|
||||
|
||||
HARBOUR HB_VERSION(void)
|
||||
HARBOUR HB_VERSION( void )
|
||||
{
|
||||
char hb_ver[ 80 ];
|
||||
|
||||
sprintf( hb_ver, "Harbour %d.%d Intl. (Build %d%s) (%04d.%02d.%02d)",
|
||||
hb_major, hb_minor, hb_build, hb_revision, hb_year, hb_month, hb_day );
|
||||
|
||||
hb_retc( hb_ver );
|
||||
}
|
||||
|
||||
HARBOUR HB_GETENV(void)
|
||||
HARBOUR HB_GETENV( void )
|
||||
{
|
||||
if( hb_pcount() == 1 )
|
||||
{
|
||||
char *szName = hb_parc(1);
|
||||
long lName = hb_parclen(1);
|
||||
char * szName = hb_parc( 1 );
|
||||
long lName = hb_parclen( 1 );
|
||||
|
||||
while( lName && szName[lName - 1] == '=' )
|
||||
while( lName && szName[ lName - 1 ] == '=' )
|
||||
{
|
||||
/* strip the '=' or else it will clear the variable! */
|
||||
szName[lName - 1] = 0;
|
||||
szName[ lName - 1 ] = '\0';
|
||||
lName--;
|
||||
}
|
||||
if( lName )
|
||||
{
|
||||
char *Value = getenv(szName);
|
||||
hb_retc(Value? Value: "");
|
||||
char * Value = getenv( szName );
|
||||
hb_retc( Value ? Value : "" );
|
||||
}
|
||||
else
|
||||
hb_retc("");
|
||||
hb_retc( "" );
|
||||
}
|
||||
else
|
||||
hb_retc("");
|
||||
hb_retc( "" );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -237,7 +239,7 @@ HARBOUR HB_GETENV(void)
|
||||
* Do not use it to run Terminate and Stay Resident programs (in case of DOS)
|
||||
* since it cause several problems
|
||||
* $Examples$
|
||||
* __Run( "edit "+cMyTextFile ) // Runs an external editor
|
||||
* __Run( "edit " + cMyTextFile ) // Runs an external editor
|
||||
* __Run( "command" ) // Gives a DOS shell (DOS only)
|
||||
* $Files$
|
||||
* source/rtl/environ.c
|
||||
|
||||
@@ -2,6 +2,19 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/* Harbour Project source code
|
||||
http://www.Harbour-Project.org/
|
||||
The following functions are Copyright 1999 Victor Szel <info@szelvesz.hu>:
|
||||
HB_CURDIR()
|
||||
HB_DIRCHANGE()
|
||||
HB_MAKEDIR()
|
||||
HB_DIRREMOVE()
|
||||
HB_DISKCHANGE()
|
||||
HB_DISKNAME()
|
||||
HB_DISKSPACE() (parts by Luiz Rafael Culik <Culik@sl.conex.net>)
|
||||
See doc/hdr_tpl.txt, Version 1.2 or later, for licensing terms.
|
||||
*/
|
||||
|
||||
/* NOTE: In DOS/DJGPP under WinNT4 hb_fsSeek( fhnd, offset < 0, FS_SET) will
|
||||
set the file pointer to the passed negative value, and the subsequent
|
||||
hb_fsWrite() call will fail. In CA-Clipper hb_fsSeek() will fail,
|
||||
@@ -70,6 +83,10 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef DOS
|
||||
#include <dos.h>
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0 /* O_BINARY not defined on Linux */
|
||||
#endif
|
||||
@@ -618,7 +635,7 @@ BYTE * hb_fsCurDir ( USHORT uiDrive )
|
||||
|
||||
/* TODO: Implement nDrive */
|
||||
|
||||
USHORT hb_fsChDrv ( BYTE * nDrive )
|
||||
USHORT hb_fsChDrv ( BYTE nDrive )
|
||||
{
|
||||
USHORT iResult;
|
||||
|
||||
@@ -894,10 +911,129 @@ HARBOUR HB_FREADSTR( void )
|
||||
/* NOTE: This function should not return the leading and trailing */
|
||||
/* (back)slashes. */
|
||||
|
||||
/* NOTE: Clipper 5.3 only */
|
||||
|
||||
HARBOUR HB_CURDIR( void )
|
||||
{
|
||||
int uiErrorOld = s_uiErrorLast;
|
||||
|
||||
hb_retc( ( char * ) hb_fsCurDir( ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ?
|
||||
( USHORT )( toupper( *hb_parc( 1 ) ) - 'A' + 1 ) : 0 ) );
|
||||
|
||||
s_uiErrorLast = uiErrorOld;
|
||||
}
|
||||
|
||||
/* NOTE: Clipper 5.3 only */
|
||||
|
||||
HARBOUR HB_DIRCHANGE( void )
|
||||
{
|
||||
int uiErrorOld = s_uiErrorLast;
|
||||
int iResult;
|
||||
|
||||
if( ISCHAR( 1 ) )
|
||||
{
|
||||
if( hb_fsChDir( ( BYTE * ) hb_parc( 1 ) ) )
|
||||
iResult = 0;
|
||||
else
|
||||
iResult = s_uiErrorLast;
|
||||
}
|
||||
else
|
||||
iResult = -1;
|
||||
|
||||
hb_retni( iResult );
|
||||
|
||||
s_uiErrorLast = uiErrorOld;
|
||||
}
|
||||
|
||||
/* NOTE: Clipper 5.3 only */
|
||||
/* NOTE: Clipper 5.3 NG incorrectly states that the name if this function is
|
||||
DIRMAKE(), in reality it's not. */
|
||||
|
||||
HARBOUR HB_MAKEDIR( void )
|
||||
{
|
||||
int uiErrorOld = s_uiErrorLast;
|
||||
int iResult;
|
||||
|
||||
if( ISCHAR( 1 ) )
|
||||
{
|
||||
if( hb_fsMkDir( ( BYTE * ) hb_parc( 1 ) ) )
|
||||
iResult = 0;
|
||||
else
|
||||
iResult = s_uiErrorLast;
|
||||
}
|
||||
else
|
||||
iResult = -1;
|
||||
|
||||
hb_retni( iResult );
|
||||
|
||||
s_uiErrorLast = uiErrorOld;
|
||||
}
|
||||
|
||||
/* NOTE: Clipper 5.3 only */
|
||||
|
||||
HARBOUR HB_DIRREMOVE( void )
|
||||
{
|
||||
int uiErrorOld = s_uiErrorLast;
|
||||
int iResult;
|
||||
|
||||
if( ISCHAR( 1 ) )
|
||||
{
|
||||
if( hb_fsRmDir( ( BYTE * ) hb_parc( 1 ) ) )
|
||||
iResult = 0;
|
||||
else
|
||||
iResult = s_uiErrorLast;
|
||||
}
|
||||
else
|
||||
iResult = -1;
|
||||
|
||||
hb_retni( iResult );
|
||||
|
||||
s_uiErrorLast = uiErrorOld;
|
||||
}
|
||||
|
||||
HARBOUR HB_DISKSPACE( void )
|
||||
{
|
||||
USHORT nDrive = ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ?
|
||||
( USHORT )( toupper( *hb_parc( 1 ) ) - 'A' + 1 ) : 0;
|
||||
|
||||
#ifdef DOS
|
||||
struct diskfree_t disk;
|
||||
|
||||
_dos_getdiskfree( nDrive, &disk );
|
||||
|
||||
hb_retnl( ( LONG ) ( ( ULONG ) disk.avail_clusters *
|
||||
( ULONG ) disk.sectors_per_cluster *
|
||||
( ULONG ) disk.bytes_per_sector ) );
|
||||
#else
|
||||
|
||||
HB_SYMBOL_UNUSED( nDrive );
|
||||
|
||||
hb_retnl( 0 );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
HARBOUR HB_DISKCHANGE( void )
|
||||
{
|
||||
int uiErrorOld = s_uiErrorLast;
|
||||
|
||||
hb_retl( ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ?
|
||||
hb_fsChDrv( ( USHORT )( toupper( *hb_parc( 1 ) ) - 'A' + 1 ) ) == 0 :
|
||||
FALSE );
|
||||
|
||||
s_uiErrorLast = uiErrorOld;
|
||||
}
|
||||
|
||||
HARBOUR HB_DISKNAME( void )
|
||||
{
|
||||
int uiErrorOld = s_uiErrorLast;
|
||||
char szDrive[ 1 ];
|
||||
|
||||
szDrive[ 0 ] = ( ( char ) hb_fsCurDrv() ) + 'A';
|
||||
|
||||
hb_retclen( szDrive, 1 );
|
||||
|
||||
s_uiErrorLast = uiErrorOld;
|
||||
}
|
||||
|
||||
HARBOUR HB_BIN2I( void )
|
||||
|
||||
@@ -29,17 +29,17 @@
|
||||
#define HB_FM_STATISTICS
|
||||
|
||||
#ifndef __MPW__
|
||||
#include <malloc.h>
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include "extend.h"
|
||||
#include "errorapi.h"
|
||||
|
||||
#ifdef HB_FM_STATISTICS
|
||||
static ULONG s_ulMemoryBlocks = 0; /* memory blocks used */
|
||||
static ULONG s_ulMemoryMaxBlocks = 0; /* maximum number of used memory blocks */
|
||||
static ULONG s_ulMemoryMaxConsumed = 0; /* memory size consumed */
|
||||
static ULONG s_ulMemoryConsumed = 0; /* memory max size consumed */
|
||||
static ULONG s_ulMemoryBlocks = 0; /* memory blocks used */
|
||||
static ULONG s_ulMemoryMaxBlocks = 0; /* maximum number of used memory blocks */
|
||||
static ULONG s_ulMemoryMaxConsumed = 0; /* memory size consumed */
|
||||
static ULONG s_ulMemoryConsumed = 0; /* memory max size consumed */
|
||||
#endif
|
||||
|
||||
void * hb_xalloc( ULONG ulSize ) /* allocates fixed memory, returns NULL on failure */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -43,7 +43,7 @@
|
||||
Harbour includes are ahead of platform includes.
|
||||
*/
|
||||
#ifdef __IBMCPP__
|
||||
#define INCL_DOSPROCESS
|
||||
#define INCL_DOSPROCESS
|
||||
#endif
|
||||
|
||||
#include "extend.h"
|
||||
@@ -52,45 +52,45 @@
|
||||
#include "init.h"
|
||||
|
||||
#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__MSC__) || defined(_MSC_VER)
|
||||
#include <conio.h>
|
||||
#include <dos.h>
|
||||
#include <conio.h>
|
||||
#include <dos.h>
|
||||
#elif defined(__DJGPP__)
|
||||
#include <pc.h>
|
||||
#include <dos.h>
|
||||
#include <pc.h>
|
||||
#include <dos.h>
|
||||
#elif defined(HARBOUR_GCC_OS2)
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#elif defined(__IBMCPP__)
|
||||
#define INCL_DOSPROCESS
|
||||
#include <bsedos.h>
|
||||
#include <conio.h>
|
||||
#define INCL_DOSPROCESS
|
||||
#include <bsedos.h>
|
||||
#include <conio.h>
|
||||
#elif defined(__CYGWIN__)
|
||||
#include <mingw32/conio.h>
|
||||
#include <mingw32/conio.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#include <conio.h>
|
||||
#include <i86.h>
|
||||
#if defined(__386__) && !defined(__WINDOWS_386__)
|
||||
#define INT_86 int386
|
||||
#define DOS_REGS REGS
|
||||
#else
|
||||
#define INT_86 int86
|
||||
#define DOS_REGS REGS
|
||||
#endif
|
||||
#include <conio.h>
|
||||
#include <i86.h>
|
||||
#if defined(__386__) && !defined(__WINDOWS_386__)
|
||||
#define INT_86 int386
|
||||
#define DOS_REGS REGS
|
||||
#else
|
||||
#define INT_86 int86
|
||||
#define DOS_REGS REGS
|
||||
#endif
|
||||
#elif defined(__EMX__)
|
||||
#define INT_86 _int86
|
||||
#define DOS_REGS REGS
|
||||
#define INT_86 _int86
|
||||
#define DOS_REGS REGS
|
||||
#elif defined(_MSC_VER)
|
||||
#define INT_86 _int86
|
||||
#define DOS_REGS _REGS
|
||||
#define INT_86 _int86
|
||||
#define DOS_REGS _REGS
|
||||
#else
|
||||
#define INT_86 int86
|
||||
#define DOS_REGS REGS
|
||||
#define INT_86 int86
|
||||
#define DOS_REGS REGS
|
||||
#endif
|
||||
|
||||
#if defined(HARBOUR_GCC_OS2)
|
||||
ULONG DosSleep( ULONG ulMilliseconds );
|
||||
ULONG DosSleep( ULONG ulMilliseconds );
|
||||
#endif
|
||||
|
||||
#if defined(OS_UNIX_COMPATIBLE)
|
||||
@@ -144,23 +144,23 @@ void hb_releaseCPU( void )
|
||||
|
||||
returns zero on failure. (means not supported)
|
||||
*/
|
||||
#if defined(__TURBOC__)
|
||||
_AX = 0x1680;
|
||||
geninterrupt( 0x2f );
|
||||
_AH = 0;
|
||||
_AL ^= 0x80;
|
||||
#else
|
||||
union REGS regs;
|
||||
regs.h.ah = 0x16;
|
||||
regs.h.al = 0x80;
|
||||
#if defined(__WATCOMC__) && defined(__386__)
|
||||
int386( 0x2f, ®s, ®s );
|
||||
#else
|
||||
int86( 0x2f, ®s, ®s );
|
||||
#endif
|
||||
regs.h.ah = 0;
|
||||
regs.h.al ^= 0x80;
|
||||
#endif
|
||||
#if defined(__TURBOC__)
|
||||
_AX = 0x1680;
|
||||
geninterrupt( 0x2f );
|
||||
_AH = 0;
|
||||
_AL ^= 0x80;
|
||||
#else
|
||||
union REGS regs;
|
||||
regs.h.ah = 0x16;
|
||||
regs.h.al = 0x80;
|
||||
#if defined(__WATCOMC__) && defined(__386__)
|
||||
int386( 0x2f, ®s, ®s );
|
||||
#else
|
||||
int86( 0x2f, ®s, ®s );
|
||||
#endif
|
||||
regs.h.ah = 0;
|
||||
regs.h.al ^= 0x80;
|
||||
#endif
|
||||
#elif defined(OS_UNIX_COMPATIBLE)
|
||||
#else
|
||||
#endif
|
||||
|
||||
@@ -147,51 +147,51 @@ static HB_LANG langEN =
|
||||
}
|
||||
};
|
||||
|
||||
static PHB_LANG langDef = &langEN;
|
||||
static PHB_LANG s_langDef = &langEN;
|
||||
|
||||
void hb_langDSet ( PHB_LANG lang )
|
||||
{
|
||||
if( lang )
|
||||
langDef = lang;
|
||||
s_langDef = lang;
|
||||
}
|
||||
|
||||
PHB_LANG hb_langDGet ( void )
|
||||
{
|
||||
return langDef;
|
||||
return s_langDef;
|
||||
}
|
||||
|
||||
char * hb_langDGetName ( void )
|
||||
{
|
||||
return langDef->szName;
|
||||
return s_langDef->szName;
|
||||
}
|
||||
|
||||
char * hb_langDGetID ( void )
|
||||
{
|
||||
return langDef->szID;
|
||||
return s_langDef->szID;
|
||||
}
|
||||
|
||||
char * hb_langDGetText ( ULONG ulIndex )
|
||||
{
|
||||
return langDef->szTextList[ ( ulIndex < sizeof( langDef->szTextList ) / sizeof( langDef->szTextList[ 0 ] ) ) ? ulIndex : 0 ];
|
||||
return s_langDef->szTextList[ ( ulIndex < sizeof( s_langDef->szTextList ) / sizeof( s_langDef->szTextList[ 0 ] ) ) ? ulIndex : 0 ];
|
||||
}
|
||||
|
||||
char * hb_langDGetDayName ( ULONG ulIndex )
|
||||
{
|
||||
return langDef->szDayNameList[ ( ulIndex < sizeof( langDef->szDayNameList ) / sizeof( langDef->szDayNameList[ 0 ] ) ) ? ulIndex : 0 ];
|
||||
return s_langDef->szDayNameList[ ( ulIndex < sizeof( s_langDef->szDayNameList ) / sizeof( s_langDef->szDayNameList[ 0 ] ) ) ? ulIndex : 0 ];
|
||||
}
|
||||
|
||||
char * hb_langDGetMonthName ( ULONG ulIndex )
|
||||
{
|
||||
return langDef->szMonthNameList[ ( ulIndex < sizeof( langDef->szMonthNameList ) / sizeof( langDef->szMonthNameList[ 0 ] ) ) ? ulIndex : 0 ];
|
||||
return s_langDef->szMonthNameList[ ( ulIndex < sizeof( s_langDef->szMonthNameList ) / sizeof( s_langDef->szMonthNameList[ 0 ] ) ) ? ulIndex : 0 ];
|
||||
}
|
||||
|
||||
char * hb_langDGetErrorDesc ( ULONG ulIndex )
|
||||
{
|
||||
return langDef->szErrorDescList[ ( ulIndex < sizeof( langDef->szErrorDescList ) / sizeof( langDef->szErrorDescList[ 0 ] ) ) ? ulIndex : 0 ];
|
||||
return s_langDef->szErrorDescList[ ( ulIndex < sizeof( s_langDef->szErrorDescList ) / sizeof( s_langDef->szErrorDescList[ 0 ] ) ) ? ulIndex : 0 ];
|
||||
}
|
||||
|
||||
char * hb_langDGetErrorIntr ( ULONG ulIndex )
|
||||
{
|
||||
return langDef->szErrorIntrList[ ( ulIndex < sizeof( langDef->szErrorIntrList ) / sizeof( langDef->szErrorIntrList[ 0 ] ) ) ? ulIndex : 0 ];
|
||||
return s_langDef->szErrorIntrList[ ( ulIndex < sizeof( s_langDef->szErrorIntrList ) / sizeof( s_langDef->szErrorIntrList[ 0 ] ) ) ? ulIndex : 0 ];
|
||||
}
|
||||
|
||||
|
||||
@@ -42,16 +42,16 @@
|
||||
#define VS_PRIVATE 64
|
||||
#define VS_PUBLIC 128
|
||||
|
||||
static PHB_DYNS * _privateStack = NULL;
|
||||
static ULONG _privateStackSize = 0;
|
||||
static ULONG _privateStackCnt = 0;
|
||||
static ULONG _privateStackBase = 0;
|
||||
static PHB_DYNS * s_privateStack = NULL;
|
||||
static ULONG s_privateStackSize = 0;
|
||||
static ULONG s_privateStackCnt = 0;
|
||||
static ULONG s_privateStackBase = 0;
|
||||
|
||||
static ULONG _globalTableSize = 0;
|
||||
static ULONG _globalFirstFree = 0;
|
||||
static ULONG _globalLastFree = 0;
|
||||
static ULONG _globalFreeCnt = 0;
|
||||
static HB_VALUE_PTR _globalTable = NULL;
|
||||
static ULONG s_globalTableSize = 0;
|
||||
static ULONG s_globalFirstFree = 0;
|
||||
static ULONG s_globalLastFree = 0;
|
||||
static ULONG s_globalFreeCnt = 0;
|
||||
static HB_VALUE_PTR s_globalTable = NULL;
|
||||
|
||||
#define TABLE_INITHB_VALUE 100
|
||||
#define TABLE_EXPANDHB_VALUE 50
|
||||
@@ -66,38 +66,38 @@ static void hb_memvarAddPrivate( PHB_DYNS );
|
||||
|
||||
void hb_memvarsInit( void )
|
||||
{
|
||||
_globalTable = (HB_VALUE_PTR) hb_xgrab( sizeof(HB_VALUE) * TABLE_INITHB_VALUE );
|
||||
_globalTableSize = TABLE_INITHB_VALUE;
|
||||
_globalFreeCnt = 0;
|
||||
_globalFirstFree = _globalLastFree = 1;
|
||||
s_globalTable = ( HB_VALUE_PTR ) hb_xgrab( sizeof( HB_VALUE ) * TABLE_INITHB_VALUE );
|
||||
s_globalTableSize = TABLE_INITHB_VALUE;
|
||||
s_globalFreeCnt = 0;
|
||||
s_globalFirstFree = s_globalLastFree = 1;
|
||||
|
||||
_privateStack = (PHB_DYNS *) hb_xgrab( sizeof(PHB_DYNS) * TABLE_INITHB_VALUE );
|
||||
_privateStackSize = TABLE_INITHB_VALUE;
|
||||
_privateStackCnt = _privateStackBase = 0;
|
||||
s_privateStack = ( PHB_DYNS * ) hb_xgrab( sizeof( PHB_DYNS ) * TABLE_INITHB_VALUE );
|
||||
s_privateStackSize = TABLE_INITHB_VALUE;
|
||||
s_privateStackCnt = s_privateStackBase = 0;
|
||||
}
|
||||
|
||||
|
||||
void hb_memvarsRelease( void )
|
||||
{
|
||||
ULONG ulCnt = _globalLastFree;
|
||||
ULONG ulCnt = s_globalLastFree;
|
||||
|
||||
if( _globalTable )
|
||||
if( s_globalTable )
|
||||
{
|
||||
while( ulCnt )
|
||||
{
|
||||
if( _globalTable[ ulCnt ].counter )
|
||||
if( s_globalTable[ ulCnt ].counter )
|
||||
{
|
||||
hb_itemClear( &_globalTable[ ulCnt ].item );
|
||||
_globalTable[ ulCnt ].counter =0;
|
||||
hb_itemClear( &s_globalTable[ ulCnt ].item );
|
||||
s_globalTable[ ulCnt ].counter = 0;
|
||||
}
|
||||
--ulCnt;
|
||||
}
|
||||
|
||||
hb_xfree( _globalTable );
|
||||
hb_xfree( s_globalTable );
|
||||
}
|
||||
|
||||
if( _privateStack )
|
||||
hb_xfree( _privateStack );
|
||||
if( s_privateStack )
|
||||
hb_xfree( s_privateStack );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -105,7 +105,7 @@ void hb_memvarsRelease( void )
|
||||
*/
|
||||
HB_VALUE_PTR *hb_memvarValueBaseAddress( void )
|
||||
{
|
||||
return &_globalTable;
|
||||
return &s_globalTable;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,59 +130,59 @@ HB_HANDLE hb_memvarValueNew( HB_ITEM_PTR pSource, BOOL bTrueMemvar )
|
||||
HB_VALUE_PTR pValue;
|
||||
HB_HANDLE hValue = 1; /* handle 0 is reserved */
|
||||
|
||||
if( _globalFreeCnt )
|
||||
if( s_globalFreeCnt )
|
||||
{
|
||||
/* There are holes in the table
|
||||
* Get a first available hole
|
||||
*/
|
||||
hValue =_globalFirstFree;
|
||||
--_globalFreeCnt;
|
||||
hValue = s_globalFirstFree;
|
||||
--s_globalFreeCnt;
|
||||
|
||||
/* Now find the next hole
|
||||
*/
|
||||
if( _globalFreeCnt )
|
||||
if( s_globalFreeCnt )
|
||||
{
|
||||
++_globalFirstFree;
|
||||
while( _globalTable[ _globalFirstFree ].counter )
|
||||
++_globalFirstFree;
|
||||
++s_globalFirstFree;
|
||||
while( s_globalTable[ s_globalFirstFree ].counter )
|
||||
++s_globalFirstFree;
|
||||
}
|
||||
else
|
||||
/* No more holes
|
||||
*/
|
||||
_globalFirstFree =_globalLastFree;
|
||||
s_globalFirstFree = s_globalLastFree;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Allocate the value from the end of table
|
||||
*/
|
||||
if( _globalFirstFree < _globalTableSize )
|
||||
if( s_globalFirstFree < s_globalTableSize )
|
||||
{
|
||||
hValue =_globalFirstFree;
|
||||
_globalFirstFree = ++_globalLastFree;
|
||||
hValue = s_globalFirstFree;
|
||||
s_globalFirstFree = ++s_globalLastFree;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No more free values in the table - expand the table
|
||||
*/
|
||||
hValue = _globalTableSize;
|
||||
_globalFirstFree =_globalLastFree = _globalTableSize +1;
|
||||
_globalTableSize += TABLE_EXPANDHB_VALUE;
|
||||
_globalTable =(HB_VALUE_PTR) hb_xrealloc( _globalTable, sizeof(HB_VALUE) * _globalTableSize );
|
||||
hValue = s_globalTableSize;
|
||||
s_globalFirstFree = s_globalLastFree = s_globalTableSize + 1;
|
||||
s_globalTableSize += TABLE_EXPANDHB_VALUE;
|
||||
s_globalTable = ( HB_VALUE_PTR ) hb_xrealloc( s_globalTable, sizeof( HB_VALUE ) * s_globalTableSize );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pValue =_globalTable + hValue;
|
||||
pValue->counter =1;
|
||||
pValue = s_globalTable + hValue;
|
||||
pValue->counter = 1;
|
||||
if( pSource )
|
||||
{
|
||||
if( bTrueMemvar )
|
||||
hb_itemCopy( &pValue->item, pSource );
|
||||
else
|
||||
memcpy( &pValue->item, pSource, sizeof(HB_ITEM) );
|
||||
memcpy( &pValue->item, pSource, sizeof( HB_ITEM ) );
|
||||
}
|
||||
else
|
||||
pValue->item.type =IT_NIL;
|
||||
pValue->item.type = IT_NIL;
|
||||
|
||||
#ifdef MEMVARDEBUG
|
||||
printf( "\n>>>>>Memvar item created with handle =%i", hValue );
|
||||
@@ -202,15 +202,15 @@ static void hb_memvarAddPrivate( PHB_DYNS pDynSym )
|
||||
{
|
||||
/* Allocate the value from the end of table
|
||||
*/
|
||||
if( _privateStackCnt == _privateStackSize )
|
||||
if( s_privateStackCnt == s_privateStackSize )
|
||||
{
|
||||
/* No more free values in the table - expand the table
|
||||
*/
|
||||
_privateStackSize += TABLE_EXPANDHB_VALUE;
|
||||
_privateStack =(PHB_DYNS *) hb_xrealloc( _privateStack, sizeof(PHB_DYNS) * _privateStackSize );
|
||||
s_privateStackSize += TABLE_EXPANDHB_VALUE;
|
||||
s_privateStack = ( PHB_DYNS * ) hb_xrealloc( s_privateStack, sizeof( PHB_DYNS ) * s_privateStackSize );
|
||||
}
|
||||
|
||||
_privateStack[ _privateStackCnt++ ] =pDynSym;
|
||||
s_privateStack[ s_privateStackCnt++ ] = pDynSym;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -218,8 +218,8 @@ static void hb_memvarAddPrivate( PHB_DYNS pDynSym )
|
||||
*/
|
||||
ULONG hb_memvarGetPrivatesBase( void )
|
||||
{
|
||||
ULONG ulBase = _privateStackBase;
|
||||
_privateStackBase =_privateStackCnt;
|
||||
ULONG ulBase = s_privateStackBase;
|
||||
s_privateStackBase = s_privateStackCnt;
|
||||
return ulBase;
|
||||
}
|
||||
|
||||
@@ -231,18 +231,18 @@ void hb_memvarSetPrivatesBase( ULONG ulBase )
|
||||
{
|
||||
HB_HANDLE hVar, hOldValue;
|
||||
|
||||
while( _privateStackCnt > _privateStackBase )
|
||||
while( s_privateStackCnt > s_privateStackBase )
|
||||
{
|
||||
--_privateStackCnt;
|
||||
hVar =_privateStack[ _privateStackCnt ]->hMemvar;
|
||||
hOldValue =_globalTable[ hVar ].hPrevMemvar;
|
||||
--s_privateStackCnt;
|
||||
hVar = s_privateStack[ s_privateStackCnt ]->hMemvar;
|
||||
hOldValue = s_globalTable[ hVar ].hPrevMemvar;
|
||||
hb_memvarValueDecRef( hVar );
|
||||
/*
|
||||
* Restore previous value for variables that were overridden
|
||||
*/
|
||||
_privateStack[ _privateStackCnt ]->hMemvar =hOldValue;
|
||||
s_privateStack[ s_privateStackCnt ]->hMemvar = hOldValue;
|
||||
}
|
||||
_privateStackBase =ulBase;
|
||||
s_privateStackBase = ulBase;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -252,17 +252,17 @@ void hb_memvarSetPrivatesBase( ULONG ulBase )
|
||||
void hb_memvarValueIncRef( HB_HANDLE hValue )
|
||||
{
|
||||
#ifdef MEMVARDEBUG
|
||||
if( hValue < 1 || hValue > _globalTableSize )
|
||||
if( hValue < 1 || hValue > s_globalTableSize )
|
||||
{
|
||||
printf( "\nInvalid MEMVAR handle %i (max %li)\n", hValue, _globalTableSize );
|
||||
printf( "\nInvalid MEMVAR handle %i (max %li)\n", hValue, s_globalTableSize );
|
||||
exit( 1 );
|
||||
}
|
||||
#endif
|
||||
|
||||
_globalTable[ hValue ].counter++;
|
||||
s_globalTable[ hValue ].counter++;
|
||||
|
||||
#ifdef MEMVARDEBUG
|
||||
printf( "\n+++Memvar item (%i) increment refCounter=%li", hValue, _globalTable[ hValue ].counter );
|
||||
printf( "\n+++Memvar item (%i) increment refCounter=%li", hValue, s_globalTable[ hValue ].counter );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -276,14 +276,14 @@ void hb_memvarValueDecRef( HB_HANDLE hValue )
|
||||
HB_VALUE_PTR pValue;
|
||||
|
||||
#ifdef MEMVARDEBUG
|
||||
if( hValue < 1 || hValue > _globalTableSize )
|
||||
if( hValue < 1 || hValue > s_globalTableSize )
|
||||
{
|
||||
printf( "\nInvalid MEMVAR handle %i (max %li)\n", hValue, _globalTableSize );
|
||||
printf( "\nInvalid MEMVAR handle %i (max %li)\n", hValue, s_globalTableSize );
|
||||
exit( 1 );
|
||||
}
|
||||
#endif
|
||||
|
||||
pValue =_globalTable + hValue;
|
||||
pValue = s_globalTable + hValue;
|
||||
#ifdef MEMVARDEBUG
|
||||
printf( "\n---Memvar item (%i) decrement refCounter=%li", hValue, pValue->counter-1 );
|
||||
#endif
|
||||
@@ -292,24 +292,24 @@ void hb_memvarValueDecRef( HB_HANDLE hValue )
|
||||
if( --pValue->counter == 0 )
|
||||
{
|
||||
hb_itemClear( &pValue->item );
|
||||
if( _globalFirstFree > hValue )
|
||||
if( s_globalFirstFree > hValue )
|
||||
{
|
||||
if( (_globalLastFree - hValue) == 1 )
|
||||
_globalFirstFree = _globalLastFree =hValue; /* last item */
|
||||
if( ( s_globalLastFree - hValue ) == 1 )
|
||||
s_globalFirstFree = s_globalLastFree = hValue; /* last item */
|
||||
else
|
||||
{
|
||||
_globalFirstFree =hValue;
|
||||
++_globalFreeCnt; /* middle item */
|
||||
s_globalFirstFree = hValue;
|
||||
++s_globalFreeCnt; /* middle item */
|
||||
}
|
||||
}
|
||||
else if( (_globalLastFree - hValue) == 1 )
|
||||
else if( ( s_globalLastFree - hValue ) == 1 )
|
||||
{
|
||||
_globalLastFree =hValue; /* last item */
|
||||
if( _globalLastFree == _globalFirstFree )
|
||||
_globalFreeCnt =0;
|
||||
s_globalLastFree = hValue; /* last item */
|
||||
if( s_globalLastFree == s_globalFirstFree )
|
||||
s_globalFreeCnt = 0;
|
||||
}
|
||||
else
|
||||
++_globalFreeCnt;
|
||||
++s_globalFreeCnt;
|
||||
|
||||
#ifdef MEMVARDEBUG
|
||||
printf( "\n<<<<<Memvar item (%i) deleted", hValue );
|
||||
@@ -336,9 +336,7 @@ void hb_memvarValueDecRef( HB_HANDLE hValue )
|
||||
*/
|
||||
void hb_memvarSetValue( PHB_SYMB pMemvarSymb, HB_ITEM_PTR pItem )
|
||||
{
|
||||
PHB_DYNS pDyn;
|
||||
|
||||
pDyn = (PHB_DYNS) pMemvarSymb->pDynSym;
|
||||
PHB_DYNS pDyn = ( PHB_DYNS ) pMemvarSymb->pDynSym;
|
||||
|
||||
if( pDyn )
|
||||
{
|
||||
@@ -348,9 +346,9 @@ void hb_memvarSetValue( PHB_SYMB pMemvarSymb, HB_ITEM_PTR pItem )
|
||||
if( pDyn->hMemvar )
|
||||
{
|
||||
/* value is already created */
|
||||
HB_ITEM_PTR pSetItem = &_globalTable[ pDyn->hMemvar ].item;
|
||||
if( IS_BYREF(pSetItem) )
|
||||
hb_itemCopy( hb_itemUnRef(pSetItem), pItem );
|
||||
HB_ITEM_PTR pSetItem = &s_globalTable[ pDyn->hMemvar ].item;
|
||||
if( IS_BYREF( pSetItem ) )
|
||||
hb_itemCopy( hb_itemUnRef( pSetItem ), pItem );
|
||||
else
|
||||
hb_itemCopy( pSetItem, pItem );
|
||||
}
|
||||
@@ -367,9 +365,7 @@ void hb_memvarSetValue( PHB_SYMB pMemvarSymb, HB_ITEM_PTR pItem )
|
||||
|
||||
void hb_memvarGetValue( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb )
|
||||
{
|
||||
PHB_DYNS pDyn;
|
||||
|
||||
pDyn = (PHB_DYNS) pMemvarSymb->pDynSym;
|
||||
PHB_DYNS pDyn = ( PHB_DYNS ) pMemvarSymb->pDynSym;
|
||||
|
||||
if( pDyn )
|
||||
{
|
||||
@@ -380,9 +376,9 @@ void hb_memvarGetValue( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb )
|
||||
{
|
||||
/* value is already created
|
||||
*/
|
||||
HB_ITEM_PTR pGetItem = &_globalTable[ pDyn->hMemvar ].item;
|
||||
if( IS_BYREF(pGetItem) )
|
||||
hb_itemCopy( pItem, hb_itemUnRef(pGetItem) );
|
||||
HB_ITEM_PTR pGetItem = &s_globalTable[ pDyn->hMemvar ].item;
|
||||
if( IS_BYREF( pGetItem ) )
|
||||
hb_itemCopy( pItem, hb_itemUnRef( pGetItem ) );
|
||||
else
|
||||
hb_itemCopy( pItem, pGetItem );
|
||||
}
|
||||
@@ -395,9 +391,7 @@ void hb_memvarGetValue( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb )
|
||||
|
||||
void hb_memvarGetRefer( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb )
|
||||
{
|
||||
PHB_DYNS pDyn;
|
||||
|
||||
pDyn = (PHB_DYNS) pMemvarSymb->pDynSym;
|
||||
PHB_DYNS pDyn = ( PHB_DYNS ) pMemvarSymb->pDynSym;
|
||||
|
||||
if( pDyn )
|
||||
{
|
||||
@@ -410,8 +404,8 @@ void hb_memvarGetRefer( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb )
|
||||
pItem->type = IT_BYREF | IT_MEMVAR;
|
||||
pItem->item.asMemvar.offset = 0;
|
||||
pItem->item.asMemvar.value = pDyn->hMemvar;
|
||||
pItem->item.asMemvar.itemsbase = &_globalTable;
|
||||
++_globalTable[ pDyn->hMemvar ].counter;
|
||||
pItem->item.asMemvar.itemsbase = &s_globalTable;
|
||||
++s_globalTable[ pDyn->hMemvar ].counter;
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_NOVAR, 1003, NULL, pMemvarSymb->szName );
|
||||
@@ -439,9 +433,9 @@ static void hb_memvarCreateFromItem( PHB_ITEM pMemvar, BYTE bScope, PHB_ITEM pVa
|
||||
|
||||
/* find dynamic symbol or creeate one */
|
||||
if( IS_SYMBOL( pMemvar ) )
|
||||
pDynVar =hb_dynsymGet( pMemvar->item.asSymbol.value->szName );
|
||||
pDynVar = hb_dynsymGet( pMemvar->item.asSymbol.value->szName );
|
||||
else if( IS_STRING( pMemvar ) )
|
||||
pDynVar =hb_dynsymGet( pMemvar->item.asString.value );
|
||||
pDynVar = hb_dynsymGet( pMemvar->item.asString.value );
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 3008, NULL, "&" );
|
||||
|
||||
@@ -464,16 +458,16 @@ static void hb_memvarCreateFromDynSymbol( PHB_DYNS pDynVar, BYTE bScope, PHB_ITE
|
||||
/* new PUBLIC variable - initialize it to .F.
|
||||
*/
|
||||
|
||||
_globalTable[ pDynVar->hMemvar ].item.type = IT_LOGICAL;
|
||||
s_globalTable[ pDynVar->hMemvar ].item.type = IT_LOGICAL;
|
||||
|
||||
/* NOTE: PUBLIC variables named CLIPPER and HARBOUR are initialized */
|
||||
/* to .T., this is normal Clipper behaviour */
|
||||
|
||||
if ( strcmp( pDynVar->pSymbol->szName, "HARBOUR" ) == 0 ||
|
||||
if( strcmp( pDynVar->pSymbol->szName, "HARBOUR" ) == 0 ||
|
||||
strcmp( pDynVar->pSymbol->szName, "CLIPPER" ) == 0 )
|
||||
_globalTable[ pDynVar->hMemvar ].item.item.asLogical.value = TRUE;
|
||||
s_globalTable[ pDynVar->hMemvar ].item.item.asLogical.value = TRUE;
|
||||
else
|
||||
_globalTable[ pDynVar->hMemvar ].item.item.asLogical.value = FALSE;
|
||||
s_globalTable[ pDynVar->hMemvar ].item.item.asLogical.value = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -483,10 +477,10 @@ static void hb_memvarCreateFromDynSymbol( PHB_DYNS pDynVar, BYTE bScope, PHB_ITE
|
||||
* visible at this moment so later we can restore this value when
|
||||
* the new variable will be released
|
||||
*/
|
||||
HB_HANDLE hCurrentValue =pDynVar->hMemvar;
|
||||
HB_HANDLE hCurrentValue = pDynVar->hMemvar;
|
||||
|
||||
pDynVar->hMemvar = hb_memvarValueNew( pValue, TRUE );
|
||||
_globalTable[ pDynVar->hMemvar ].hPrevMemvar =hCurrentValue;
|
||||
s_globalTable[ pDynVar->hMemvar ].hPrevMemvar = hCurrentValue;
|
||||
|
||||
/* Add this variable to the PRIVATE variables stack
|
||||
*/
|
||||
@@ -500,10 +494,10 @@ static void hb_memvarCreateFromDynSymbol( PHB_DYNS pDynVar, BYTE bScope, PHB_ITE
|
||||
*/
|
||||
static void hb_memvarRelease( HB_ITEM_PTR pMemvar )
|
||||
{
|
||||
ULONG ulBase = _privateStackCnt;
|
||||
ULONG ulBase = s_privateStackCnt;
|
||||
PHB_DYNS pDynVar;
|
||||
|
||||
if( IS_STRING(pMemvar) )
|
||||
if( IS_STRING( pMemvar ) )
|
||||
{
|
||||
/* Find the variable with a requested name that is currently visible
|
||||
* Start from the top of the stack.
|
||||
@@ -511,7 +505,7 @@ static void hb_memvarRelease( HB_ITEM_PTR pMemvar )
|
||||
while( ulBase > 0 )
|
||||
{
|
||||
--ulBase;
|
||||
pDynVar =_privateStack[ ulBase ];
|
||||
pDynVar = s_privateStack[ ulBase ];
|
||||
/* reset current value to NIL - the overriden variables will be
|
||||
* visible after exit from current procedure
|
||||
*/
|
||||
@@ -519,8 +513,8 @@ static void hb_memvarRelease( HB_ITEM_PTR pMemvar )
|
||||
{
|
||||
if( hb_stricmp( pDynVar->pSymbol->szName, pMemvar->item.asString.value ) == 0 )
|
||||
{
|
||||
hb_itemClear( &_globalTable[ pDynVar->hMemvar ].item );
|
||||
ulBase =0;
|
||||
hb_itemClear( &s_globalTable[ pDynVar->hMemvar ].item );
|
||||
ulBase = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -537,13 +531,13 @@ static void hb_memvarRelease( HB_ITEM_PTR pMemvar )
|
||||
*/
|
||||
static void hb_memvarReleaseWithMask( char *szMask, BOOL bInclude )
|
||||
{
|
||||
ULONG ulBase = _privateStackCnt;
|
||||
ULONG ulBase = s_privateStackCnt;
|
||||
PHB_DYNS pDynVar;
|
||||
|
||||
while( ulBase > _privateStackBase )
|
||||
while( ulBase > s_privateStackBase )
|
||||
{
|
||||
--ulBase;
|
||||
pDynVar =_privateStack[ ulBase ];
|
||||
pDynVar = s_privateStack[ ulBase ];
|
||||
/* reset current value to NIL - the overriden variables will be
|
||||
* visible after exit from current procedure
|
||||
*/
|
||||
@@ -551,54 +545,54 @@ static void hb_memvarReleaseWithMask( char *szMask, BOOL bInclude )
|
||||
{
|
||||
if( bInclude )
|
||||
{
|
||||
if( (szMask[ 0 ] == '*') || hb_strMatchRegExp( pDynVar->pSymbol->szName, szMask ) )
|
||||
hb_itemClear( &_globalTable[ pDynVar->hMemvar ].item );
|
||||
if( ( szMask[ 0 ] == '*') || hb_strMatchRegExp( pDynVar->pSymbol->szName, szMask ) )
|
||||
hb_itemClear( &s_globalTable[ pDynVar->hMemvar ].item );
|
||||
}
|
||||
else if( ! hb_strMatchRegExp( pDynVar->pSymbol->szName, szMask ) )
|
||||
hb_itemClear( &_globalTable[ pDynVar->hMemvar ].item );
|
||||
hb_itemClear( &s_globalTable[ pDynVar->hMemvar ].item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This function checks the scope of passed variable
|
||||
*/
|
||||
static int hb_memvarScope( char *szVarName, ULONG ulLength )
|
||||
static int hb_memvarScope( char * szVarName, ULONG ulLength )
|
||||
{
|
||||
int iMemvar = MV_ERROR;
|
||||
char *szName;
|
||||
char * szName;
|
||||
|
||||
szName =(char *)hb_xalloc( ulLength );
|
||||
szName = ( char * ) hb_xalloc( ulLength );
|
||||
if( szName )
|
||||
{
|
||||
PHB_DYNS pDynVar;
|
||||
|
||||
memcpy( szName, szVarName, ulLength );
|
||||
pDynVar =hb_dynsymFind( hb_strUpper( szName, ulLength-1 ) );
|
||||
pDynVar = hb_dynsymFind( hb_strUpper( szName, ulLength - 1 ) );
|
||||
if( pDynVar )
|
||||
{
|
||||
if( pDynVar->hMemvar == 0 )
|
||||
iMemvar =MV_UNKNOWN;
|
||||
iMemvar = MV_UNKNOWN;
|
||||
else
|
||||
{
|
||||
ULONG ulBase = _privateStackCnt; /* start from the top of the stack */
|
||||
ULONG ulBase = s_privateStackCnt; /* start from the top of the stack */
|
||||
|
||||
iMemvar =MV_PUBLIC;
|
||||
iMemvar = MV_PUBLIC;
|
||||
while( ulBase )
|
||||
{
|
||||
--ulBase;
|
||||
if( pDynVar == _privateStack[ ulBase ] )
|
||||
if( pDynVar == s_privateStack[ ulBase ] )
|
||||
{
|
||||
if( ulBase >= _privateStackBase )
|
||||
iMemvar =MV_PRIVATE_LOCAL;
|
||||
if( ulBase >= s_privateStackBase )
|
||||
iMemvar = MV_PRIVATE_LOCAL;
|
||||
else
|
||||
iMemvar =MV_PRIVATE_GLOBAL;
|
||||
ulBase =0;
|
||||
iMemvar = MV_PRIVATE_GLOBAL;
|
||||
ulBase = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
iMemvar =MV_NOT_FOUND;
|
||||
iMemvar = MV_NOT_FOUND;
|
||||
hb_xfree( szName );
|
||||
}
|
||||
|
||||
@@ -609,10 +603,11 @@ static HB_DYNS_FUNC( hb_memvarClear )
|
||||
{
|
||||
if( pDynSymbol->hMemvar )
|
||||
{
|
||||
_globalTable[ pDynSymbol->hMemvar ].counter = 1;
|
||||
s_globalTable[ pDynSymbol->hMemvar ].counter = 1;
|
||||
hb_memvarValueDecRef( pDynSymbol->hMemvar );
|
||||
pDynSymbol->hMemvar =0;
|
||||
pDynSymbol->hMemvar = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -662,9 +657,9 @@ HARBOUR HB___MVPUBLIC( void )
|
||||
|
||||
if( iCount )
|
||||
{
|
||||
for( i=1; i<=iCount; i++ )
|
||||
for( i = 1; i <= iCount; i++ )
|
||||
{
|
||||
pMemvar =hb_param( i, IT_ANY );
|
||||
pMemvar = hb_param( i, IT_ANY );
|
||||
if( pMemvar )
|
||||
{
|
||||
if( IS_ARRAY( pMemvar ) )
|
||||
@@ -674,7 +669,7 @@ HARBOUR HB___MVPUBLIC( void )
|
||||
ULONG j, ulLen = hb_arrayLen( pMemvar );
|
||||
HB_ITEM VarItem;
|
||||
|
||||
for( j=1; j<=ulLen; j++ )
|
||||
for( j = 1; j <= ulLen; j++ )
|
||||
{
|
||||
hb_arrayGet( pMemvar, j, &VarItem );
|
||||
hb_memvarCreateFromItem( &VarItem, VS_PUBLIC, NULL );
|
||||
@@ -730,9 +725,9 @@ HARBOUR HB___MVPRIVATE( void )
|
||||
|
||||
if( iCount )
|
||||
{
|
||||
for( i=1; i<=iCount; i++ )
|
||||
for( i = 1; i <= iCount; i++ )
|
||||
{
|
||||
pMemvar =hb_param( i, IT_ANY );
|
||||
pMemvar = hb_param( i, IT_ANY );
|
||||
if( pMemvar )
|
||||
{
|
||||
if( IS_ARRAY( pMemvar ) )
|
||||
@@ -742,7 +737,7 @@ HARBOUR HB___MVPRIVATE( void )
|
||||
ULONG j, ulLen = hb_arrayLen( pMemvar );
|
||||
HB_ITEM VarItem;
|
||||
|
||||
for( j=1; j<=ulLen; j++ )
|
||||
for( j = 1; j <= ulLen; j++ )
|
||||
{
|
||||
hb_arrayGet( pMemvar, j, &VarItem );
|
||||
hb_memvarCreateFromItem( &VarItem, VS_PRIVATE, NULL );
|
||||
@@ -823,9 +818,9 @@ HARBOUR HB___MVXRELEASE( void )
|
||||
|
||||
if( iCount )
|
||||
{
|
||||
for( i=1; i<=iCount; i++ )
|
||||
for( i = 1; i <= iCount; i++ )
|
||||
{
|
||||
pMemvar =hb_param( i, IT_ANY );
|
||||
pMemvar = hb_param( i, IT_ANY );
|
||||
if( pMemvar )
|
||||
{
|
||||
if( IS_ARRAY( pMemvar ) )
|
||||
@@ -835,7 +830,7 @@ HARBOUR HB___MVXRELEASE( void )
|
||||
ULONG j, ulLen = hb_arrayLen( pMemvar );
|
||||
HB_ITEM VarItem;
|
||||
|
||||
for( j=1; j<=ulLen; j++ )
|
||||
for( j = 1; j <= ulLen; j++ )
|
||||
{
|
||||
hb_arrayGet( pMemvar, j, &VarItem );
|
||||
hb_memvarRelease( &VarItem );
|
||||
@@ -896,15 +891,15 @@ HARBOUR HB___MVRELEASE( void )
|
||||
|
||||
if( iCount )
|
||||
{
|
||||
pMask =hb_param( 1, IT_STRING );
|
||||
pMask = hb_param( 1, IT_STRING );
|
||||
if( pMask )
|
||||
{
|
||||
BOOL bIncludeVar;
|
||||
|
||||
if( iCount > 1 )
|
||||
bIncludeVar =hb_parl( 2 );
|
||||
bIncludeVar = hb_parl( 2 );
|
||||
else
|
||||
bIncludeVar =TRUE;
|
||||
bIncludeVar = TRUE;
|
||||
|
||||
if( pMask->item.asString.value[ 0 ] == '*' )
|
||||
bIncludeVar =TRUE; /* delete all memvar variables */
|
||||
@@ -979,10 +974,10 @@ HARBOUR HB___MVSCOPE( void )
|
||||
{
|
||||
PHB_ITEM pVarName;
|
||||
|
||||
pVarName =hb_param( 1, IT_STRING );
|
||||
pVarName = hb_param( 1, IT_STRING );
|
||||
if( pVarName )
|
||||
{
|
||||
iMemvar =hb_memvarScope( pVarName->item.asString.value, pVarName->item.asString.length+1 );
|
||||
iMemvar = hb_memvarScope( pVarName->item.asString.value, pVarName->item.asString.length + 1 );
|
||||
}
|
||||
}
|
||||
hb_retni( iMemvar );
|
||||
|
||||
@@ -32,81 +32,52 @@
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
|
||||
their web site at http://www.gnu.org/).
|
||||
|
||||
V 1.3 Chen Kedem hb_mouse_Hide() now work in any text
|
||||
screen mode by calling VioGetMode.
|
||||
hb_mouse_IsButtonPressed() now return
|
||||
TRUE if any button was pressed.
|
||||
V 1.0 Chen Kedem Initial version.
|
||||
*/
|
||||
|
||||
#define INCL_MOU
|
||||
#define INCL_VIO /* needed only for VioGetMode/VIOMODEINFO */
|
||||
#define INCL_NOPMAPI /* exclude Presentation Manager Include File */
|
||||
|
||||
#include <os2.h>
|
||||
#include "mouseapi.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TODO: those exist in os2.h which I don't have */
|
||||
/* #define INCL_???? as needed */
|
||||
/* #include <os2.h> */
|
||||
typedef unsigned BOOL;
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned long ULONG;
|
||||
#define API unsigned extern far pascal
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
API MouOpen ( void far *, unsigned far * );
|
||||
API MouClose ( unsigned );
|
||||
API MouDrawPtr ( unsigned );
|
||||
API MouRemovePtr ();
|
||||
API MouGetPtrPos ();
|
||||
API MouSetPtrPos ();
|
||||
API MouGetNumButtons ();
|
||||
API MouReadEventQue ();
|
||||
typedef struct _NOPTRRECT {
|
||||
USHORT row;
|
||||
USHORT col;
|
||||
USHORT cRow;
|
||||
USHORT cCol;
|
||||
} NOPTRRECT;
|
||||
typedef struct _PTRLOC {
|
||||
USHORT row;
|
||||
USHORT col;
|
||||
} PTRLOC;
|
||||
typedef struct _MOUEVENTINFO {
|
||||
USHORT fs; /* Bit(s) Significance (if set) Mask ?
|
||||
0 mouse move, no buttons down MOUSE_MOTION
|
||||
1 mouse move, button 1 down MOUSE_MOTION_WITH_BN1_DOWN
|
||||
2 button 1 down MOUSE_BN1_DOWN
|
||||
3 mouse move, button 2 down MOUSE_MOTION_WITH_BN2_DOWN
|
||||
4 button 2 down MOUSE_BN2_DOWN
|
||||
5 mouse move, button 3 down MOUSE_MOTION_WITH_BN3_DOWN
|
||||
6 button 3 down MOUSE_BN3_DOWN
|
||||
7-15 reserved (0) */
|
||||
ULONG time;
|
||||
USHORT row;
|
||||
USHORT col;
|
||||
} MOUEVENTINFO;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static unsigned suMouHandle; /* mouse logical handle */
|
||||
static unsigned s_uMouHandle; /* mouse logical handle */
|
||||
|
||||
void hb_mouse_Init()
|
||||
{
|
||||
if ( MouOpen ( 0L, &suMouHandle ) ) /* try to open mouse */
|
||||
suMouHandle = 0; /* no mouse found */
|
||||
USHORT fsEvents = MOUSE_MOTION_WITH_BN1_DOWN | MOUSE_BN1_DOWN |
|
||||
MOUSE_MOTION_WITH_BN2_DOWN | MOUSE_BN2_DOWN |
|
||||
MOUSE_MOTION_WITH_BN3_DOWN | MOUSE_BN3_DOWN ;
|
||||
|
||||
if ( MouOpen ( 0L, &s_uMouHandle ) ) /* try to open mouse */
|
||||
s_uMouHandle = 0; /* no mouse found */
|
||||
else
|
||||
MouSetEventMask ( &fsEvents, s_uMouHandle ); /* mask some events */
|
||||
}
|
||||
|
||||
void hb_mouse_Exit(void)
|
||||
{
|
||||
if ( suMouHandle )
|
||||
if ( s_uMouHandle )
|
||||
{
|
||||
MouClose ( suMouHandle ); /* relese mouse handle */
|
||||
suMouHandle = 0;
|
||||
MouClose ( s_uMouHandle ); /* relese mouse handle */
|
||||
s_uMouHandle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL hb_mouse_IsPresent(void)
|
||||
{
|
||||
return ( suMouHandle != 0 );
|
||||
return ( s_uMouHandle != 0 );
|
||||
}
|
||||
|
||||
void hb_mouse_Show(void)
|
||||
{
|
||||
if ( suMouHandle )
|
||||
MouDrawPtr ( suMouHandle );
|
||||
if ( s_uMouHandle )
|
||||
MouDrawPtr ( s_uMouHandle );
|
||||
}
|
||||
|
||||
void hb_mouse_Hide(void)
|
||||
@@ -115,20 +86,22 @@ void hb_mouse_Hide(void)
|
||||
NOTE: mouse cursor always visible if not in full screen
|
||||
*/
|
||||
NOPTRRECT rect;
|
||||
if ( suMouHandle )
|
||||
VIOMODEINFO vi; /* needed to get max Row/Col */
|
||||
if ( s_uMouHandle )
|
||||
{
|
||||
/*
|
||||
QUESTION: should I call the GT function ?
|
||||
QUESTION: should I call the GT MaxRow/Col function ?
|
||||
pro: encapsulating of the GetScreen function
|
||||
con: calling function from another module, GT must be linked in
|
||||
con: VioGetMode is been called twice
|
||||
may be a just a call to MaxRow/Col would be enough
|
||||
*/
|
||||
rect.row = 0; /* x-coordinate upper left */
|
||||
rect.col = 0; /* y-coordinate upper left */
|
||||
rect.cRow = 20/*hb_gt_GetScreenHeight()*/; /* x-coordinate lower right */
|
||||
rect.cCol = 60/*hb_gt_GetScreenWidth()*/; /* y-coordinate lower right */
|
||||
MouRemovePtr ( &rect, suMouHandle );
|
||||
vi.cb = sizeof(VIOMODEINFO);
|
||||
VioGetMode(&vi, 0);
|
||||
rect.row = 0; /* x-coordinate upper left */
|
||||
rect.col = 0; /* y-coordinate upper left */
|
||||
rect.cRow = vi.row - 1; /* x-coordinate lower right */
|
||||
rect.cCol = vi.col - 1; /* y-coordinate lower right */
|
||||
MouRemovePtr ( &rect, s_uMouHandle );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,9 +114,9 @@ void hb_mouse_Hide(void)
|
||||
int hb_mouse_Col(void)
|
||||
{
|
||||
PTRLOC pos;
|
||||
if ( suMouHandle )
|
||||
if ( s_uMouHandle )
|
||||
{
|
||||
MouGetPtrPos ( &pos, suMouHandle );
|
||||
MouGetPtrPos ( &pos, s_uMouHandle );
|
||||
}
|
||||
return ( (int)pos.col );
|
||||
}
|
||||
@@ -151,9 +124,9 @@ int hb_mouse_Col(void)
|
||||
int hb_mouse_Row(void)
|
||||
{
|
||||
PTRLOC pos;
|
||||
if ( suMouHandle )
|
||||
if ( s_uMouHandle )
|
||||
{
|
||||
MouGetPtrPos ( &pos, suMouHandle );
|
||||
MouGetPtrPos ( &pos, s_uMouHandle );
|
||||
}
|
||||
return ( (int)pos.row );
|
||||
}
|
||||
@@ -161,39 +134,60 @@ int hb_mouse_Row(void)
|
||||
void hb_mouse_SetPos( int row, int col )
|
||||
{
|
||||
PTRLOC pos;
|
||||
if ( suMouHandle )
|
||||
if ( s_uMouHandle )
|
||||
{
|
||||
pos.row = (USHORT)row;
|
||||
pos.col = (USHORT)col;
|
||||
MouSetPtrPos ( &pos, suMouHandle );
|
||||
MouSetPtrPos ( &pos, s_uMouHandle );
|
||||
}
|
||||
}
|
||||
|
||||
BOOL hb_mouse_IsButtonPressed( int iButton )
|
||||
{
|
||||
/*
|
||||
TODO: just a sample, a work should be done here !
|
||||
TOFIX: every time I read event from the queue I lose the result
|
||||
so I can not check if iButton was pressed, so for now I ignore
|
||||
iButton and return TRUE if the last event saved had DOWN in it.
|
||||
also to keep the noise level down I mask out MOUSE_MOTION events.
|
||||
*/
|
||||
BOOL bPressed = FALSE;
|
||||
USHORT uMask = 0x0000;
|
||||
USHORT WaitOption = 0; /* 1 = wait until mouse event exist, 0 = don't */
|
||||
MOUEVENTINFO MouEvent;
|
||||
if ( suMouHandle )
|
||||
if ( s_uMouHandle )
|
||||
{
|
||||
MouReadEventQue ( &MouEvent, &WaitOption, suMouHandle );
|
||||
/*
|
||||
now MouEvent.fs contain the mask for the mouse event,
|
||||
what to do next?
|
||||
*/
|
||||
MouReadEventQue ( &MouEvent, &WaitOption, s_uMouHandle );
|
||||
uMask = MouEvent.fs;
|
||||
|
||||
#ifdef PLEASE_PLEASE_MAKE_IT_WORK
|
||||
switch(iButton)
|
||||
{
|
||||
case 1:
|
||||
uMask &= ( MOUSE_MOTION_WITH_BN1_DOWN | MOUSE_BN1_DOWN );
|
||||
break;
|
||||
case 2:
|
||||
uMask &= ( MOUSE_MOTION_WITH_BN2_DOWN | MOUSE_BN2_DOWN );
|
||||
break;
|
||||
case 3:
|
||||
uMask &= ( MOUSE_MOTION_WITH_BN3_DOWN | MOUSE_BN3_DOWN );
|
||||
break;
|
||||
}
|
||||
#else
|
||||
uMask &= (
|
||||
MOUSE_MOTION_WITH_BN1_DOWN | MOUSE_BN1_DOWN |
|
||||
MOUSE_MOTION_WITH_BN2_DOWN | MOUSE_BN2_DOWN |
|
||||
MOUSE_MOTION_WITH_BN3_DOWN | MOUSE_BN3_DOWN
|
||||
) ;
|
||||
#endif
|
||||
}
|
||||
return ( bPressed );
|
||||
return ( uMask != 0 );
|
||||
}
|
||||
|
||||
int hb_mouse_CountButton(void)
|
||||
{
|
||||
USHORT usButtons = 0;
|
||||
if ( suMouHandle )
|
||||
if ( s_uMouHandle )
|
||||
{
|
||||
MouGetNumButtons ( &usButtons, suMouHandle );
|
||||
MouGetNumButtons ( &usButtons, s_uMouHandle );
|
||||
}
|
||||
return ( (int)usButtons );
|
||||
}
|
||||
@@ -201,16 +195,14 @@ int hb_mouse_CountButton(void)
|
||||
void hb_mouse_SetBounds( int iTop, int iLeft, int iBottom, int iRight )
|
||||
{
|
||||
/*
|
||||
NOTE: I don't know if the OS/2 got a function to do that,
|
||||
the old book I'm using does not have such.
|
||||
TODO: (I don't think that the OS/2 got a function to do it)
|
||||
*/
|
||||
}
|
||||
|
||||
void hb_mouse_GetBounds( int * piTop, int * piLeft, int * piBottom, int * piRight )
|
||||
{
|
||||
/*
|
||||
NOTE: I don't know if the OS/2 got a function to do that,
|
||||
the old book I'm using does not have such.
|
||||
TODO: (I don't think that the OS/2 got a function to do it)
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -149,20 +149,20 @@
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#if defined(__DJGPP__)
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#if defined(__DJGPP__)
|
||||
#include <io.h>
|
||||
#endif
|
||||
#else
|
||||
#ifndef __MPW__
|
||||
#include <io.h>
|
||||
#endif
|
||||
#ifndef __MPW__
|
||||
#include <io.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#ifndef __MPW__
|
||||
#include <sys/stat.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
@@ -190,13 +190,13 @@ static BOOL set_logical( PHB_ITEM pItem )
|
||||
if( IS_LOGICAL( pItem ) ) logical = pItem->item.asLogical.value;
|
||||
else if( IS_STRING( pItem ) )
|
||||
{
|
||||
if( pItem->item.asString.length == 2 )
|
||||
if( pItem->item.asString.length >= 2 )
|
||||
{
|
||||
if( toupper( pItem->item.asString.value[ 0 ] ) == 'O'
|
||||
&& toupper( pItem->item.asString.value[ 1 ] ) == 'N' )
|
||||
logical = TRUE;
|
||||
}
|
||||
else if( pItem->item.asString.length == 3 )
|
||||
else if( pItem->item.asString.length >= 3 )
|
||||
{
|
||||
if( toupper( pItem->item.asString.value[ 0 ] ) == 'O'
|
||||
&& toupper( pItem->item.asString.value[ 1 ] ) == 'F'
|
||||
@@ -351,13 +351,13 @@ HARBOUR HB___SETCENTURY( void )
|
||||
if( pItem && IS_LOGICAL( pItem ) ) hb_set_century = pItem->item.asLogical.value;
|
||||
else if( pItem && IS_STRING( pItem ) )
|
||||
{
|
||||
if( pItem->item.asString.length == 2 )
|
||||
if( pItem->item.asString.length >= 2 )
|
||||
{
|
||||
if( toupper( pItem->item.asString.value[ 0 ] ) == 'O'
|
||||
&& toupper( pItem->item.asString.value[ 1 ] ) == 'N' )
|
||||
hb_set_century = TRUE;
|
||||
}
|
||||
else if( pItem->item.asString.length == 3 )
|
||||
else if( pItem->item.asString.length >= 3 )
|
||||
{
|
||||
if( toupper ( pItem->item.asString.value[ 0 ] ) == 'O'
|
||||
&& toupper ( pItem->item.asString.value[ 1 ] ) == 'F'
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
#include "extend.h"
|
||||
#include "set.h"
|
||||
#ifdef HARBOUR_USE_GTAPI
|
||||
#include "gtapi.h"
|
||||
#include "gtapi.h"
|
||||
#else
|
||||
static char old_string[ sizeof( hb_set.HB_SET_COLOR ) ];
|
||||
static char s_old_string[ sizeof( hb_set.HB_SET_COLOR ) ];
|
||||
#endif
|
||||
|
||||
char * hb_setColor( char * sColor )
|
||||
@@ -35,8 +35,8 @@ char * hb_setColor( char * sColor )
|
||||
#ifdef HARBOUR_USE_GTAPI
|
||||
hb_gtGetColorStr( hb_set.HB_SET_COLOR );
|
||||
#else
|
||||
strncpy( old_string, hb_set.HB_SET_COLOR, sizeof( hb_set.HB_SET_COLOR ) );
|
||||
old_string[ sizeof( hb_set.HB_SET_COLOR ) - 1 ] = 0;
|
||||
strncpy( s_old_string, hb_set.HB_SET_COLOR, sizeof( hb_set.HB_SET_COLOR ) );
|
||||
s_old_string[ sizeof( hb_set.HB_SET_COLOR ) - 1 ] = 0;
|
||||
#endif
|
||||
|
||||
if( sColor != ( char * ) NULL )
|
||||
@@ -52,7 +52,7 @@ char * hb_setColor( char * sColor )
|
||||
#ifdef HARBOUR_USE_GTAPI
|
||||
return hb_set.HB_SET_COLOR;
|
||||
#else
|
||||
return old_string;
|
||||
return s_old_string;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,10 @@
|
||||
|
||||
#include "init.h"
|
||||
|
||||
static double infinity = 0;
|
||||
static double s_dInfinity = 0;
|
||||
|
||||
HB_CALL_ON_STARTUP_BEGIN( Strings_InitInfinity )
|
||||
infinity = -log( 0 );
|
||||
s_dInfinity = -log( 0 );
|
||||
HB_CALL_ON_STARTUP_END( Strings_InitInfinity )
|
||||
#if ! defined(__GNUC__)
|
||||
#pragma startup Strings_InitInfinity
|
||||
@@ -1169,7 +1169,7 @@ char * hb_itemStr( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec )
|
||||
double dNumber = hb_itemGetND( pNumber );
|
||||
|
||||
#ifdef HARBOUR_STRICT_CLIPPER_COMPATIBILITY
|
||||
if( pNumber->item.asDouble.length == 99 || dNumber == infinity || dNumber == -infinity )
|
||||
if( pNumber->item.asDouble.length == 99 || dNumber == s_dInfinity || dNumber == -s_dInfinity )
|
||||
/* Numeric overflow */
|
||||
iBytes = iSize + 1;
|
||||
else
|
||||
|
||||
@@ -48,27 +48,27 @@
|
||||
*/
|
||||
|
||||
#if defined(__DJGPP__)
|
||||
#include <pc.h>
|
||||
#include <time.h>
|
||||
#include <pc.h>
|
||||
#include <time.h>
|
||||
#elif defined(_Windows)
|
||||
#elif defined(__BORLANDC__)
|
||||
#include <dos.h>
|
||||
#include <time.h>
|
||||
#include <dos.h>
|
||||
#include <time.h>
|
||||
#elif defined(OS2)
|
||||
#include <dos.h>
|
||||
#include <dos.h>
|
||||
#elif defined(__CYGWIN__)
|
||||
#include <Windows32/Base.h>
|
||||
#include <Windows32/Defines.h>
|
||||
#include <Windows32/Structures.h>
|
||||
#include <Windows32/CommonFunctions.h>
|
||||
#define HB_DONT_DEFINE_BASIC_TYPES
|
||||
#include <Windows32/Base.h>
|
||||
#include <Windows32/Defines.h>
|
||||
#include <Windows32/Structures.h>
|
||||
#include <Windows32/CommonFunctions.h>
|
||||
#define HB_DONT_DEFINE_BASIC_TYPES
|
||||
#endif
|
||||
|
||||
#include "extend.h"
|
||||
#include "inkey.h" /* For hb_releaseCPU() */
|
||||
|
||||
#if defined(HARBOUR_GCC_OS2)
|
||||
ULONG DosBeep (ULONG ulFrequency, ULONG ulDuration);
|
||||
ULONG DosBeep( ULONG ulFrequency, ULONG ulDuration );
|
||||
#endif
|
||||
|
||||
/* $DOC$
|
||||
@@ -198,7 +198,7 @@ void hb_tone( double frequency, double duration )
|
||||
#endif
|
||||
}
|
||||
|
||||
HARBOUR HB_TONE(void)
|
||||
HARBOUR HB_TONE( void )
|
||||
{
|
||||
double frequency, duration;
|
||||
if( PCOUNT > 0 && ISNUM( 1 ) )
|
||||
|
||||
@@ -76,8 +76,6 @@
|
||||
#define DF_YMD 2
|
||||
#define DF_EOT 3 /* End of table for Century */
|
||||
|
||||
static char * szBritish[] = { "DD/MM/YY", "DD/MM/YYYY" }; /* For @E */
|
||||
|
||||
extern HARBOUR HB_STR( void );
|
||||
|
||||
/* NOTE: This is called via its symbol name, so we should make sure */
|
||||
@@ -363,7 +361,7 @@ static char * NumPicture( char *szPic, ULONG ulPic, WORD wPicFlags, double dValu
|
||||
static char * DatePicture( char * szDate, WORD wPicFlags, char * szResult )
|
||||
{
|
||||
if( wPicFlags & PF_BRITISH )
|
||||
hb_dtoc( szDate, szResult, szBritish[ ( hb_set_century ? 1 : 0 ) ] );
|
||||
hb_dtoc( szDate, szResult, hb_set_century ? "DD/MM/YYYY" : "DD/MM/YY" );
|
||||
else
|
||||
hb_dtoc( szDate, szResult, hb_set.HB_SET_DATEFORMAT );
|
||||
|
||||
|
||||
@@ -790,7 +790,7 @@ static void hb_vmAliasPop( void )
|
||||
|
||||
default:
|
||||
hb_itemClear( pItem );
|
||||
hb_errRT_BASE( EG_BADALIAS, 1000, NULL, NULL );
|
||||
hb_errRT_BASE( EG_BADALIAS, 9999, NULL, NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -843,7 +843,7 @@ static void hb_vmAliasSwap( void )
|
||||
|
||||
default:
|
||||
hb_itemClear( pWorkArea );
|
||||
hb_errRT_BASE( EG_BADALIAS, 1000, NULL, NULL );
|
||||
hb_errRT_BASE( EG_BADALIAS, 9999, NULL, NULL );
|
||||
break;
|
||||
}
|
||||
memcpy( pWorkArea, pItem, sizeof( HB_ITEM ) );
|
||||
@@ -1066,7 +1066,12 @@ void hb_vmDo( WORD wParams )
|
||||
pFunc = hb_objGetMethod( pSelf, pSym );
|
||||
|
||||
if( ! pFunc )
|
||||
hb_errInternal( 9999, "Message %s not implemented for class %s", pSym->szName, hb_objGetClsName( pSelf ) );
|
||||
{
|
||||
if( pSym->szName[ 0 ] == '_' )
|
||||
hb_errRT_BASE( EG_NOVARMETHOD, 1005, NULL, pSym->szName + 1 );
|
||||
else
|
||||
hb_errRT_BASE( EG_NOMETHOD, 1004, NULL, pSym->szName );
|
||||
}
|
||||
|
||||
pFunc();
|
||||
}
|
||||
@@ -1612,28 +1617,31 @@ void hb_vmMinus( void )
|
||||
}
|
||||
else if( IS_STRING( pItem1 ) && IS_STRING( pItem2 ) )
|
||||
{
|
||||
ULONG ulLen = pItem1->item.asString.length;
|
||||
|
||||
pItem1->item.asString.value = (char*)hb_xrealloc( pItem1->item.asString.value, pItem1->item.asString.length + pItem2->item.asString.length + 1 );
|
||||
pItem1->item.asString.length += pItem2->item.asString.length;
|
||||
|
||||
while( ulLen && pItem1->item.asString.value[ulLen - 1] == ' ' )
|
||||
if( ( double ) ( ( double ) pItem1->item.asString.length + ( double ) pItem2->item.asString.length ) < ( double ) ULONG_MAX )
|
||||
{
|
||||
ulLen--;
|
||||
}
|
||||
ULONG ulLen = pItem1->item.asString.length;
|
||||
|
||||
memcpy( pItem1->item.asString.value + ulLen, pItem2->item.asString.value, pItem2->item.asString.length );
|
||||
ulLen += pItem2->item.asString.length;
|
||||
memset( pItem1->item.asString.value + ulLen, ' ', pItem1->item.asString.length - ulLen);
|
||||
pItem1->item.asString.value[ pItem1->item.asString.length ] = '\0';
|
||||
pItem1->item.asString.value = ( char * ) hb_xrealloc( pItem1->item.asString.value, pItem1->item.asString.length + pItem2->item.asString.length + 1 );
|
||||
pItem1->item.asString.length += pItem2->item.asString.length;
|
||||
|
||||
if( pItem2->item.asString.value )
|
||||
{
|
||||
hb_xfree( pItem2->item.asString.value );
|
||||
pItem2->item.asString.value = NULL;
|
||||
while( ulLen && pItem1->item.asString.value[ ulLen - 1 ] == ' ' )
|
||||
ulLen--;
|
||||
|
||||
memcpy( pItem1->item.asString.value + ulLen, pItem2->item.asString.value, pItem2->item.asString.length );
|
||||
ulLen += pItem2->item.asString.length;
|
||||
memset( pItem1->item.asString.value + ulLen, ' ', pItem1->item.asString.length - ulLen);
|
||||
pItem1->item.asString.value[ pItem1->item.asString.length ] = '\0';
|
||||
|
||||
if( pItem2->item.asString.value )
|
||||
{
|
||||
hb_xfree( pItem2->item.asString.value );
|
||||
pItem2->item.asString.value = NULL;
|
||||
}
|
||||
hb_stackPop();
|
||||
return;
|
||||
}
|
||||
hb_stackPop();
|
||||
return;
|
||||
else
|
||||
hb_errRT_BASE( EG_STROVERFLOW, 1210, NULL, "-" );
|
||||
}
|
||||
else if( IS_OBJECT( stack.pPos - 2 ) && hb_objHasMsg( stack.pPos - 2, "-" ) )
|
||||
hb_vmOperatorCall( stack.pPos - 2, stack.pPos - 1, "-" );
|
||||
@@ -1728,18 +1736,23 @@ void hb_vmPlus( void )
|
||||
|
||||
if( IS_STRING( pItem1 ) && IS_STRING( pItem2 ) )
|
||||
{
|
||||
pItem1->item.asString.value = (char*)hb_xrealloc( pItem1->item.asString.value, pItem1->item.asString.length + pItem2->item.asString.length + 1 );
|
||||
memcpy( pItem1->item.asString.value+ pItem1->item.asString.length,
|
||||
pItem2->item.asString.value, pItem2->item.asString.length );
|
||||
pItem1->item.asString.length += pItem2->item.asString.length;
|
||||
pItem1->item.asString.value[ pItem1->item.asString.length ] = '\0';
|
||||
if( pItem2->item.asString.value )
|
||||
if( ( double ) ( ( double ) pItem1->item.asString.length + ( double ) pItem2->item.asString.length ) < ( double ) ULONG_MAX )
|
||||
{
|
||||
hb_xfree( pItem2->item.asString.value );
|
||||
pItem2->item.asString.value = NULL;
|
||||
pItem1->item.asString.value = ( char * ) hb_xrealloc( pItem1->item.asString.value, pItem1->item.asString.length + pItem2->item.asString.length + 1 );
|
||||
memcpy( pItem1->item.asString.value+ pItem1->item.asString.length,
|
||||
pItem2->item.asString.value, pItem2->item.asString.length );
|
||||
pItem1->item.asString.length += pItem2->item.asString.length;
|
||||
pItem1->item.asString.value[ pItem1->item.asString.length ] = '\0';
|
||||
if( pItem2->item.asString.value )
|
||||
{
|
||||
hb_xfree( pItem2->item.asString.value );
|
||||
pItem2->item.asString.value = NULL;
|
||||
}
|
||||
hb_stackPop();
|
||||
return;
|
||||
}
|
||||
hb_stackPop();
|
||||
return;
|
||||
else
|
||||
hb_errRT_BASE( EG_STROVERFLOW, 1209, NULL, "+" );
|
||||
}
|
||||
|
||||
else if( IS_NUMERIC( pItem1 ) && IS_NUMERIC( pItem2 ) )
|
||||
@@ -1827,7 +1840,7 @@ static void hb_vmPopAliasedField( PHB_SYMB pSym )
|
||||
|
||||
default:
|
||||
hb_itemClear( pAlias );
|
||||
hb_errRT_BASE( EG_BADALIAS, 1000, NULL, NULL );
|
||||
hb_errRT_BASE( EG_BADALIAS, 9999, NULL, NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2037,7 +2050,7 @@ static void hb_vmPushAliasedField( PHB_SYMB pSym )
|
||||
|
||||
default:
|
||||
hb_itemClear( pAlias );
|
||||
hb_errRT_BASE( EG_BADALIAS, 1000, NULL, NULL );
|
||||
hb_errRT_BASE( EG_BADALIAS, 9999, NULL, NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user