diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6c67646e46..190a110f98 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,30 @@ +19990901-17:20 GMT+1 Victor Szel + * source/rtl/set.c + funclist.txt + + SetCancel() function added. + * source/vm/hvm.c + ! hb_vmRequestCancel() now diplays correctly on DOS/DJGPP, since it's + using hb_consoleGetNewLine() to display a newline instead of '\n'. + * source/runner/runlib.c + ! __HRBRUN() now handles if the error launcher returns with an E_BREAK. + * source/rtl/copyfile.c + ! The error launching now also reacts to a BREAK correctly. + * source/compiler/harbour.l + ! At one place BREAK was not converted to uppercase, so the generated pcode + was faulty. RTL_TEST.PRG didn't link because of that. + (Ryszard, is this the correct fix ?) + * source/rtl/errorapi.c + ! szOperation now can be NULL. This caused some error launchings to GPF, + for example BADALIAS calls in HVM.C. + * IS_*() internal macros changed to hb_itemType() calls. + * source/rtl/filesys.c + + Added runtime error 2018 to DISKSPACE(). + * source/vm/hvm.c + ! Fixed a variable name which went out sync between the last two CVS + sessions. + * source/rtl/inkey.c + + Added copyright info. + 19990901-15:40 GMT+1 Victor Szel * source/compiler/harbour.y + It will now recognize and accept filenames specified via the diff --git a/harbour/funclist.txt b/harbour/funclist.txt index d0571b5d39..3707bc0f6c 100644 --- a/harbour/funclist.txt +++ b/harbour/funclist.txt @@ -210,7 +210,7 @@ SECONDS ;R; SELECT ;R; SET ;R; SETBLINK ;S; -SETCANCEL ;N; +SETCANCEL ;R; SETCOLOR ;S; SETCURSOR ;S; SETKEY ;R; diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index 0d72cf4949..312f2cf2de 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -41,8 +41,8 @@ #include "hbdefs.h" /* Functions defined in harbour.y */ -char *yy_strupr( char * ); -char * yy_strdup( char *p ); +char * yy_strupr( char * p ); +char * yy_strdup( char * p ); extern void hb_xfree( void * pMem ); /* frees memory */ /* YACC functions */ @@ -229,7 +229,7 @@ Separator {SpaceTab} BEGIN BREAK_; else { - yylval.string = yy_strdup( yytext ); + yylval.string = yy_strupr( yy_strdup( yytext ) ); _iState =IDENTIFIER; return IDENTIFIER; } @@ -244,7 +244,7 @@ Separator {SpaceTab} * There are no resons to limit this use in Harbour. */ /* -{Separator}*[\[] { +{Separator}*[\[] { if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; GenError( _szCErrors, 'E', ERR_SYNTAX, yytext, NULL ); } diff --git a/harbour/source/rtl/copyfile.c b/harbour/source/rtl/copyfile.c index 20db2dc24c..a47152ec5c 100644 --- a/harbour/source/rtl/copyfile.c +++ b/harbour/source/rtl/copyfile.c @@ -43,7 +43,9 @@ static BOOL hb_fsCopy( char * szSource, char * szDest, ULONG * pulWrittenTotal ) while( ( fhndSource = hb_fsOpen( ( BYTE * ) szSource, FO_READ ) ) == FS_ERROR ) { - if( hb_errRT_BASE_Ext1( EG_OPEN, 2012, NULL, szSource, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ) == E_DEFAULT ) + WORD wResult = hb_errRT_BASE_Ext1( EG_OPEN, 2012, NULL, szSource, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ); + + if( wResult == E_DEFAULT || wResult == E_BREAK ) { ulWrittenTotal = ( ULONG ) -1L; break; @@ -54,7 +56,9 @@ static BOOL hb_fsCopy( char * szSource, char * szDest, ULONG * pulWrittenTotal ) { while( ( fhndDest = hb_fsCreate( ( BYTE * ) szDest, FC_NORMAL ) ) == FS_ERROR ) { - if( hb_errRT_BASE_Ext1( EG_CREATE, 2012, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ) == E_DEFAULT ) + WORD wResult = hb_errRT_BASE_Ext1( EG_CREATE, 2012, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ); + + if( wResult == E_DEFAULT || wResult == E_BREAK ) { ulWrittenTotal = ( ULONG ) -2L; break; @@ -79,7 +83,9 @@ static BOOL hb_fsCopy( char * szSource, char * szDest, ULONG * pulWrittenTotal ) { while( ( usWritten = hb_fsWrite( fhndDest, buffer, usRead ) ) != usRead ) { - if( hb_errRT_BASE_Ext1( EG_WRITE, 2016, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ) == E_DEFAULT ) + WORD wResult = hb_errRT_BASE_Ext1( EG_WRITE, 2016, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ); + + if( wResult == E_DEFAULT || wResult == E_BREAK ) { bRetVal = FALSE; break; diff --git a/harbour/source/rtl/errorapi.c b/harbour/source/rtl/errorapi.c index 551aa1454b..1a9495d23d 100644 --- a/harbour/source/rtl/errorapi.c +++ b/harbour/source/rtl/errorapi.c @@ -114,7 +114,7 @@ WORD hb_errLaunch( PHB_ITEM pError ) /* Check if we have a valid error handler */ - if( ! IS_BLOCK( &s_errorBlock ) ) + if( hb_itemType( &s_errorBlock ) != IT_BLOCK ) hb_errInternal( 9999, "No ERRORBLOCK() for error", NULL, NULL ); /* Check if the error launcher was called too many times recursively */ @@ -161,7 +161,7 @@ WORD hb_errLaunch( PHB_ITEM pError ) /* If the error block didn't return a logical value, */ /* or the canSubstitute flag has been set, consider it as a failure */ - if( ! IS_LOGICAL( pResult ) || ( uiFlags & EF_CANSUBSTITUTE ) ) + if( hb_itemType( pResult ) != IT_LOGICAL || ( uiFlags & EF_CANSUBSTITUTE ) ) bFailure = TRUE; else { @@ -206,7 +206,7 @@ PHB_ITEM hb_errLaunchSubst( PHB_ITEM pError ) /* Check if we have a valid error handler */ - if( ! IS_BLOCK( &s_errorBlock ) ) + if( hb_itemType( &s_errorBlock ) != IT_BLOCK ) hb_errInternal( 9999, "No ERRORBLOCK() for error", NULL, NULL ); /* Check if the error launcher was called too many times recursively */ @@ -495,13 +495,12 @@ static WORD hb_errRT_New( { PHB_ITEM pError = hb_errNew(); WORD wRetVal; - hb_errPutSeverity( pError, uiSeverity ); hb_errPutSubSystem( pError, szSubSystem ); hb_errPutGenCode( pError, ulGenCode ); hb_errPutSubCode( pError, ulSubCode ); hb_errPutDescription( pError, szDescription ? szDescription : hb_langDGetErrorDesc( ulGenCode ) ); - hb_errPutOperation( pError, szOperation ); + hb_errPutOperation( pError, szOperation ? szOperation : "" ); hb_errPutOsCode( pError, uiOsCode ); hb_errPutFlags( pError, uiFlags ); @@ -530,7 +529,7 @@ static PHB_ITEM hb_errRT_New_Subst( hb_errPutGenCode( pError, ulGenCode ); hb_errPutSubCode( pError, ulSubCode ); hb_errPutDescription( pError, szDescription ? szDescription : hb_langDGetErrorDesc( ulGenCode ) ); - hb_errPutOperation( pError, szOperation ); + hb_errPutOperation( pError, szOperation ? szOperation : "" ); hb_errPutOsCode( pError, uiOsCode ); hb_errPutFlags( pError, uiFlags | EF_CANSUBSTITUTE ); diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 80d15afd69..3a51a7f7f7 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -1007,24 +1007,33 @@ HARBOUR HB_DIRREMOVE( void ) HARBOUR HB_DISKSPACE( void ) { - USHORT nDrive = ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ? - ( USHORT )( toupper( *hb_parc( 1 ) ) - 'A' + 1 ) : 0; + ULONG ulSpaceFree = 0; + USHORT uiDrive = ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ? + ( USHORT )( toupper( *hb_parc( 1 ) ) - 'A' + 1 ) : 0; #ifdef DOS struct diskfree_t disk; + unsigned uiResult; - _dos_getdiskfree( nDrive, &disk ); + while( ( uiResult = _dos_getdiskfree( uiDrive, &disk ) ) != 0 ) + { + WORD wResult = hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, EF_CANDEFAULT ) - hb_retnl( ( LONG ) ( ( ULONG ) disk.avail_clusters * - ( ULONG ) disk.sectors_per_cluster * - ( ULONG ) disk.bytes_per_sector ) ); + if( wResult == E_DEFAULT || wResult == E_BREAK ) + break; + } + + if( uiResult != 0 ) + ulSpaceFree = ( ( ULONG ) disk.avail_clusters * + ( ULONG ) disk.sectors_per_cluster * + ( ULONG ) disk.bytes_per_sector ); #else - HB_SYMBOL_UNUSED( nDrive ); - - hb_retnl( 0 ); + HB_SYMBOL_UNUSED( uiDrive ); #endif + + hb_retnl( ( LONG ) ulSpaceFree ); } HARBOUR HB_DISKCHANGE( void ) diff --git a/harbour/source/rtl/inkey.c b/harbour/source/rtl/inkey.c index af640c1304..e7d83ea862 100644 --- a/harbour/source/rtl/inkey.c +++ b/harbour/source/rtl/inkey.c @@ -38,6 +38,14 @@ V 1.1 David G. Holm Committed to CVS. V 1.0 David G. Holm Initial version. */ + +/* Harbour Project source code + http://www.Harbour-Project.org/ + The following functions are Copyright 1999 Victor Szel : + HB___KEYPUT() + See doc/hdr_tpl.txt, Version 1.2 or later, for licensing terms. +*/ + /* Note: The following #ifdef block for __IBMCPP__ must be ahead of any and all #include statements and requires that Harbour includes are ahead of platform includes. @@ -400,7 +408,7 @@ void hb_inkeyPoll( void ) /* Poll the console keyboard to stuff the Harbour #endif if( ch ) { - if( ch == 302 ) + if( ch == 302 ) /* K_ALT_C */ hb_vmRequestCancel( ); /* Alt-C was pressed */ hb_inkeyPut( ch ); } @@ -605,8 +613,8 @@ HARBOUR HB___KEYBOARD( void ) } while( size-- ) - { - if( *fPtr ) + { + if( *fPtr ) hb_inkeyPut( *fPtr ); ++fPtr; } diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index e0b92af99a..b0d7bbd2fd 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -326,6 +326,14 @@ static int open_handle( char * file_name, BOOL bMode, char * def_ext, HB_set_enu #endif } +HARBOUR HB_SETCANCEL( void ) +{ + hb_retl( hb_set.HB_SET_CANCEL ); + + if( ISLOG( 1 ) ) + hb_set.HB_SET_CANCEL = hb_parl( 1 ); +} + /* $DOC$ * $FUNCNAME$ __SETCENTURY( [ | ] ) --> lPreviousValue * $ARGUMENTS$ optional or (not case sensitive) diff --git a/harbour/source/runner/runlib.c b/harbour/source/runner/runlib.c index 2544eaeb7c..58fb1f6ed7 100644 --- a/harbour/source/runner/runlib.c +++ b/harbour/source/runner/runlib.c @@ -109,17 +109,17 @@ HARBOUR HB___HRBRUN( void ) } else { - char *szFileName = hb_parc( 1 ); - FILE *file; + char * szFileName = hb_parc( 1 ); + FILE * file; /* Open as binary */ while ( ( file = hb_hrbFileOpen( szFileName ) ) == NULL ) { - if( hb_errRT_BASE_Ext1( EG_OPEN, 9999, NULL, szFileName, 0, EF_CANDEFAULT | EF_CANRETRY ) == E_DEFAULT ) - { + WORD wResult = hb_errRT_BASE_Ext1( EG_OPEN, 9999, NULL, szFileName, 0, EF_CANDEFAULT | EF_CANRETRY ); + + if( wResult == E_DEFAULT && wResult == E_BREAK ) break; - } } if( file ) @@ -191,6 +191,7 @@ HARBOUR HB___HRBRUN( void ) if( !pDynSym ) { hb_errRT_BASE( EG_ARG, 9999, "Unknown or unregistered symbol", pSymRead[ ul ].szName ); + return; } pSymRead[ ul ].pFunPtr = pDynSym->pFunPtr; } diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index e327e8e34b..151ee711fe 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -2973,7 +2973,9 @@ void hb_vmRequestCancel( void ) { if( hb_set.HB_SET_CANCEL ) { - printf( "\nCancelled at: %s (%i)\n", stack.pBase->item.asSymbol.value->szName, stack.pBase->item.asSymbol.lineno ); + printf( hb_consoleGetNewLine() ); + printf( "Cancelled at: %s (%i)", stack.pBase->item.asSymbol.value->szName, stack.pBase->item.asSymbol.lineno ); + printf( hb_consoleGetNewLine() ); s_wActionRequest = HB_QUIT_REQUESTED; } }