From b274b820cf085e7b37a09412b399fd0cf467fae2 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 13 Feb 2004 22:33:52 +0000 Subject: [PATCH] 2004-02-13 23:36 UTC+0100 Viktor Szakats * source/vm/hvm.c ! hb_vmPopAliasedVar() - Fixed to be case-insensitive. % hb_vmPushAliasedVar() - Case-insensitive handling speed up. * unsigned long -> ULONG * source/rtl/idle.c * include/hbapi.h + Made hb_releaseCPU() public. * source/rtl/filesys.c * include/hbapifs.h + Added return value to hb_fsSetDevMode(), this way it's fully compatible with the CA-Clipper _tdevraw() call. * source/rtl/philes53.c ! FSETDEVMOD() now returns a numeric instead of NIL. The returned value is always 0 now. Note added about this incompatibility with C53. * source/common/hbver.c ! Mistyped defines related to compatibilty fixed. * source/rtl/strcase.c ! Incorrect assigment warnings fixed. --- harbour/ChangeLog | 27 +++++++++++++++++++++++++++ harbour/include/hbapi.h | 1 + harbour/include/hbapifs.h | 2 +- harbour/source/common/hbver.c | 6 +++--- harbour/source/rtl/filesys.c | 20 +++++++++++++++----- harbour/source/rtl/idle.c | 4 ++-- harbour/source/rtl/philes53.c | 6 ++++++ harbour/source/rtl/strcase.c | 4 ++-- harbour/source/vm/hvm.c | 29 ++++++++++++----------------- 9 files changed, 69 insertions(+), 30 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6854e82608..5573157d08 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,33 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2004-02-13 23:36 UTC+0100 Viktor Szakats + + * source/vm/hvm.c + ! hb_vmPopAliasedVar() - Fixed to be case-insensitive. + % hb_vmPushAliasedVar() - Case-insensitive handling speed up. + * unsigned long -> ULONG + + * source/rtl/idle.c + * include/hbapi.h + + Made hb_releaseCPU() public. + + * source/rtl/filesys.c + * include/hbapifs.h + + Added return value to hb_fsSetDevMode(), this way it's + fully compatible with the CA-Clipper _tdevraw() call. + + * source/rtl/philes53.c + ! FSETDEVMOD() now returns a numeric instead of NIL. The + returned value is always 0 now. Note added about this + incompatibility with C53. + + * source/common/hbver.c + ! Mistyped defines related to compatibilty fixed. + + * source/rtl/strcase.c + ! Incorrect assigment warnings fixed. + 2004-02-13 21:56 UTC+0100 Viktor Szakats * souce/rtl/gtapi.c diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 682885a6ae..cd7ec57250 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -590,6 +590,7 @@ extern HB_GARBAGE_FUNC( hb_codeblockDeleteGarbage ); /* clear a codeblock before extern HB_GARBAGE_FUNC( hb_arrayReleaseGarbage ); /* clear an array before releasing by the GC */ /* idle states */ +extern void hb_releaseCPU( void ); extern void hb_idleState( void ); /* services a single idle state */ extern void hb_idleReset( void ); /* services a single idle state */ extern void hb_idleShutDown( void ); /* closes all background tasks */ diff --git a/harbour/include/hbapifs.h b/harbour/include/hbapifs.h index 39f7c0ba0b..2bc6a681cc 100644 --- a/harbour/include/hbapifs.h +++ b/harbour/include/hbapifs.h @@ -135,7 +135,7 @@ extern BOOL hb_fsRmDir ( BYTE * pszDirName ); /* remove a directory */ extern BOOL hb_fsRename ( BYTE * pszOldName, BYTE * pszNewName ); /* rename a file */ extern ULONG hb_fsSeek ( FHANDLE hFileHandle, LONG lOffset, USHORT uiMode ); /* reposition an open file */ extern ULONG hb_fsTell ( FHANDLE hFileHandle ); /* retrieve the current position of a file */ -extern void hb_fsSetDevMode ( FHANDLE hFileHandle, USHORT uiDevMode ); /* change the device mode of a file (text/binary) */ +extern BOOL hb_fsSetDevMode ( FHANDLE hFileHandle, USHORT uiDevMode ); /* change the device mode of a file (text/binary) */ extern void hb_fsSetError ( USHORT uiError ); /* set the file system error number */ extern USHORT hb_fsWrite ( FHANDLE hFileHandle, BYTE * pBuff, USHORT ulCount ); /* write to an open file from a buffer (<=64K) */ extern ULONG hb_fsWriteLarge ( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount ); /* write to an open file from a buffer (>64K) */ diff --git a/harbour/source/common/hbver.c b/harbour/source/common/hbver.c index b829c258db..d2e567e71d 100644 --- a/harbour/source/common/hbver.c +++ b/harbour/source/common/hbver.c @@ -556,7 +556,7 @@ void hb_verBuildInfo( void ) hb_conOutErr( hb_conNewLine(), 0 ); hb_conOutErr( "Multisoft Flagship compatible extensions: ", 0 ); -#if defined( HB_FLAGSHIP_VO ) +#if defined( HB_COMPAT_FLAGSHIP ) hb_conOutErr( "Yes", 0 ); #else hb_conOutErr( "No", 0 ); @@ -564,7 +564,7 @@ void hb_verBuildInfo( void ) hb_conOutErr( hb_conNewLine(), 0 ); hb_conOutErr( "Microsoft FoxPro compatible extensions: ", 0 ); -#if defined( HB_FOXPRO_VO ) +#if defined( HB_COMPAT_FOXPRO ) hb_conOutErr( "Yes", 0 ); #else hb_conOutErr( "No", 0 ); @@ -572,7 +572,7 @@ void hb_verBuildInfo( void ) hb_conOutErr( hb_conNewLine(), 0 ); hb_conOutErr( "dBase compatible extensions: ", 0 ); -#if defined( HB_DBASE_VO ) +#if defined( HB_COMPAT_DBASE ) hb_conOutErr( "Yes", 0 ); #else hb_conOutErr( "No", 0 ); diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 1814e1f958..4090b6e0b3 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -784,8 +784,10 @@ void hb_fsClose( FHANDLE hFileHandle ) s_uiErrorLast = 6; } -void hb_fsSetDevMode( FHANDLE hFileHandle, USHORT uiDevMode ) +BOOL hb_fsSetDevMode( FHANDLE hFileHandle, USHORT uiDevMode ) { + BOOL bResult; + HB_TRACE(HB_TR_DEBUG, ("hb_fsSetDevMode(%p, %hu)", hFileHandle, uiDevMode)); #if defined(__BORLANDC__) || defined(__IBMCPP__) || defined(__DJGPP__) || defined(__CYGWIN__) || defined(__WATCOMC__) @@ -794,12 +796,15 @@ void hb_fsSetDevMode( FHANDLE hFileHandle, USHORT uiDevMode ) switch( uiDevMode ) { case FD_BINARY: - setmode( hFileHandle, O_BINARY ); + bResult = ( setmode( hFileHandle, O_BINARY ) != -1 ); break; case FD_TEXT: - setmode( hFileHandle, O_TEXT ); + bResult = ( setmode( hFileHandle, O_TEXT ) != -1 ); break; + + default: + bResult = FALSE; } s_uiErrorLast = errno; @@ -809,21 +814,26 @@ void hb_fsSetDevMode( FHANDLE hFileHandle, USHORT uiDevMode ) switch( uiDevMode ) { case FD_BINARY: - _setmode( hFileHandle, _O_BINARY ); + bResult = ( _setmode( hFileHandle, _O_BINARY ) != -1 ); break; case FD_TEXT: - _setmode( hFileHandle, _O_TEXT ); + bResult = ( _setmode( hFileHandle, _O_TEXT ) != -1 ); break; + + default: + bResult = FALSE; } s_uiErrorLast = errno; #else + bResult = FALSE; s_uiErrorLast = FS_ERROR; #endif + return bResult; } USHORT hb_fsRead( FHANDLE hFileHandle, BYTE * pBuff, USHORT uiCount ) diff --git a/harbour/source/rtl/idle.c b/harbour/source/rtl/idle.c index 4e622efc57..9f65c9ba82 100644 --- a/harbour/source/rtl/idle.c +++ b/harbour/source/rtl/idle.c @@ -92,9 +92,9 @@ static USHORT s_uiIdleMaxTask = 0; /* flag to indicate GarbageCollection should be done in idle state. */ BOOL hb_vm_bCollectGarbage = TRUE; -static void hb_releaseCPU( void ) +void hb_releaseCPU( void ) { - HB_TRACE(HB_TR_DEBUG, ("releaseCPU()")); + HB_TRACE(HB_TR_DEBUG, ("hb_releaseCPU()")); /* TODO: Add code to release time slices on all platforms */ diff --git a/harbour/source/rtl/philes53.c b/harbour/source/rtl/philes53.c index efe081f875..f7a5ac3eee 100644 --- a/harbour/source/rtl/philes53.c +++ b/harbour/source/rtl/philes53.c @@ -61,6 +61,12 @@ HB_FUNC( FSETDEVMOD ) { if( ISNUM( 1 ) && ISNUM( 2 ) ) hb_fsSetDevMode( hb_parni( 1 ), hb_parni( 2 ) ); + + /* NOTE: INCOMPATIBILITY! C53 will return the device flags + before applying the new setting, Harbour will + always return 0. [vszakats] */ + + hb_retni( 0 ); } #endif diff --git a/harbour/source/rtl/strcase.c b/harbour/source/rtl/strcase.c index 2e75af5031..66569ec0f2 100644 --- a/harbour/source/rtl/strcase.c +++ b/harbour/source/rtl/strcase.c @@ -105,7 +105,7 @@ char * hb_strncpyUpper( char * pDest, const char * pSource, ULONG ulLen ) /* some compilers implements toupper as a macro, and this has side effects! */ /* *pDest++ = toupper( *pSource++ ); */ - while( ulLen && (*pDest++ = toupper( *pSource ))) + while( ulLen && (*pDest++ = toupper( *pSource )) != '\0' ) { ulLen--; pSource++; @@ -138,7 +138,7 @@ char * hb_strncpyUpperTrim( char * pDest, const char * pSource, ULONG ulLen ) /* some compilers implements toupper as a macro, and this has side effects! */ /* *pDest++ = toupper( *pSource++ ); */ - while( ulLen && ulSLen && (*pDest++ = toupper( *pSource ))) + while( ulLen && ulSLen && (*pDest++ = toupper( *pSource ) ) != '\0' ) { ulSLen--; ulLen--; diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 6cced4719d..9366d95b7e 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -4298,30 +4298,26 @@ static void hb_vmPushAliasedVar( PHB_SYMB pSym ) if( HB_IS_STRING( pAlias ) ) { - /* We make a copy of the string as it may be a pcode string! */ - char * szAlias = ( char * ) hb_xgrab( pAlias->item.asString.length + 1 ); + char * szAlias = pAlias->item.asString.value; - hb_xmemcpy( szAlias, pAlias->item.asString.value, pAlias->item.asString.length + 1 ); - hb_strUpper( szAlias, pAlias->item.asString.length ); - - if( szAlias[ 0 ] == 'M' && szAlias[ 1 ] == '\0' ) + if( ( szAlias[ 0 ] == 'M' || szAlias[ 0 ] == 'm' ) && szAlias[ 1 ] == '\0' ) { /* M->variable */ hb_memvarGetValue( pAlias, pSym ); } else { - int iCmp = strncmp( szAlias, "MEMVAR", 4 ); + int iCmp = hb_strnicmp( szAlias, "MEMVAR", 4 ); if( iCmp == 0 ) - iCmp = strncmp( szAlias, "MEMVAR", pAlias->item.asString.length ); + iCmp = hb_strnicmp( szAlias, "MEMVAR", pAlias->item.asString.length ); if( iCmp == 0 ) { /* MEMVAR-> or MEMVA-> or MEMV-> */ hb_memvarGetValue( pAlias, pSym ); } else { /* field variable */ - iCmp = strncmp( szAlias, "FIELD", 4 ); + iCmp = hb_strnicmp( szAlias, "FIELD", 4 ); if( iCmp == 0 ) - iCmp = strncmp( szAlias, "FIELD", pAlias->item.asString.length ); + iCmp = hb_strnicmp( szAlias, "FIELD", pAlias->item.asString.length ); if( iCmp == 0 ) { /* FIELD-> */ hb_rddGetFieldValue( pAlias, pSym ); @@ -4332,7 +4328,6 @@ static void hb_vmPushAliasedVar( PHB_SYMB pSym ) } } } - hb_xfree( ( void * ) szAlias ); } else hb_vmPushAliasedField( pSym ); @@ -4629,7 +4624,7 @@ static void hb_vmPopAliasedVar( PHB_SYMB pSym ) { char * szAlias = pAlias->item.asString.value; - if( szAlias[ 0 ] == 'M' && szAlias[ 1 ] == '\0' ) + if( ( szAlias[ 0 ] == 'M' || szAlias[ 0 ] == 'm' ) && szAlias[ 1 ] == '\0' ) { /* M->variable */ hb_memvarSetValue( pSym, hb_stackItemFromTop( -2 ) ); hb_stackPop(); /* alias */ @@ -4637,9 +4632,9 @@ static void hb_vmPopAliasedVar( PHB_SYMB pSym ) } else { - int iCmp = strncmp( szAlias, "MEMVAR", 4 ); + int iCmp = hb_strnicmp( szAlias, "MEMVAR", 4 ); if( iCmp == 0 ) - iCmp = strncmp( szAlias, "MEMVAR", pAlias->item.asString.length ); + iCmp = hb_strnicmp( szAlias, "MEMVAR", pAlias->item.asString.length ); if( iCmp == 0 ) { /* MEMVAR-> or MEMVA-> or MEMV-> */ hb_memvarSetValue( pSym, hb_stackItemFromTop( -2 ) ); @@ -4648,9 +4643,9 @@ static void hb_vmPopAliasedVar( PHB_SYMB pSym ) } else { /* field variable */ - iCmp = strncmp( szAlias, "FIELD", 4 ); + iCmp = hb_strnicmp( szAlias, "FIELD", 4 ); if( iCmp == 0 ) - iCmp = strncmp( szAlias, "FIELD", pAlias->item.asString.length ); + iCmp = hb_strnicmp( szAlias, "FIELD", pAlias->item.asString.length ); if( iCmp == 0 ) { /* FIELD-> */ hb_rddPutFieldValue( hb_stackItemFromTop( -2 ), pSym ); @@ -4976,7 +4971,7 @@ void hb_vmRequestCancel( void ) { char buffer[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 2 ]; int i = 1, i2; - unsigned long ulLine; + ULONG ulLine; PHB_ITEM * pBase; hb_conOutErr( hb_conNewLine(), 0 );