diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 04861103a3..e291869d72 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -7,6 +7,29 @@ For example: 2002-12-01 23:12 UTC+0100 Foo Bar */ + * source/rtl/transform.c + ! Transform("","@" ) -> memory allocation error, fixed by adding 1 byte + to hb_xgrab() + * source/rtl/descend.c + ! Descend("" ) -> memory allocation error, fixed by adding 1 byte to + - Removed two wrapper functions to hb_fsSetDevMode + which were there to maintain supposed compatibility +2002-01-03 23:26 UTC+0100 Viktor Szakats + + * source/rtl/filesys.c + ! Fix to previous change. + + * source/compiler/harbour.y + * source/macro/macro.y + ! hb_fsCommit() fixed Win32 branch, and put it + it made BCC551 fail with Bison 1.30, even even with the + supplied harbour.simple file, which makes Bison 1.30 blow. + Now we again have the usual warning, but at least it + compiles under every Bison/.simple combinations again. + +2002-01-03 23:11 UTC+0100 Viktor Szakats + + * include/hbapifs.h * source/rtl/filesys.c - Removed two wrapper functions to hb_fsSetDevMode which were there to maintain supposed compatibility diff --git a/harbour/include/hbapifs.h b/harbour/include/hbapifs.h index cc94498689..7af8a7657a 100644 --- a/harbour/include/hbapifs.h +++ b/harbour/include/hbapifs.h @@ -61,11 +61,9 @@ extern "C" { #endif #define FS_ERROR F_ERROR -#ifdef __WIN32__ -typedef long FHANDLE; -#else + typedef int FHANDLE; -#endif + /* File locking flags */ #define FL_LOCK 0x0000 /* Lock a region */ #define FL_UNLOCK 0x0001 /* Unlock a region */ @@ -129,8 +127,6 @@ extern BOOL hb_fsRename ( BYTE * pszOldName, BYTE * pszNewName ); /* ren 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 void hb_fsSetDevRaw ( FHANDLE hFileHandle ); /* change the device mode of a file to raw (binary) */ -extern void hb_fsSetDevText ( FHANDLE hFileHandle ); /* change the device mode of a file to text */ 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/include/hbundoc.api b/harbour/include/hbundoc.api index a08d8be4d0..dd6da539af 100644 --- a/harbour/include/hbundoc.api +++ b/harbour/include/hbundoc.api @@ -82,7 +82,7 @@ #define _tcreat hb_fsCreate #define _tcurdir hb_fsCurDir #define _tcurdrv hb_fsCurDrv -#define _tdevraw hb_fsSetDevRaw +#define _tdevraw hb_fsSetDevMode #define _terror hb_fsError #define _tisdevice hb_fsIsDevice #define _tisdrv hb_fsIsDrv diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 4d1dc2c3b2..e590a51ef5 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -367,7 +367,7 @@ FHANDLE hb_fsOpen( BYTE * pFilename, USHORT uiFlags ) HB_TRACE(HB_TR_DEBUG, ("hb_fsOpen(%p, %hu)", pFilename, uiFlags)); -#if defined(__WIN32__) +#if defined(X__WIN32__) { DWORD dwFlags = 0; @@ -398,7 +398,7 @@ FHANDLE hb_fsOpen( BYTE * pFilename, USHORT uiFlags ) if( hFile == ( HANDLE ) INVALID_HANDLE_VALUE ) errno = GetLastError(); - hFileHandle=(long)hFile; + hFileHandle=(int)hFile; s_uiErrorLast = errno; } @@ -472,7 +472,7 @@ FHANDLE hb_fsCreate( BYTE * pFilename, USHORT uiAttr ) s_uiErrorLast = 0; -#if defined(__WIN32__) +#if defined(X__WIN32__) { DWORD dwFlags = FILE_ATTRIBUTE_ARCHIVE; @@ -492,9 +492,9 @@ FHANDLE hb_fsCreate( BYTE * pFilename, USHORT uiAttr ) GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, dwFlags, NULL ); - if( hFile == ( HANDLE ) INVALID_HANDLE_VALUE ) + if( hFile == ( FHANDLE ) INVALID_HANDLE_VALUE ) errno = GetLastError(); - hFileHandle=(long)hFile; + hFileHandle=(int)hFile; s_uiErrorLast = errno; } @@ -568,7 +568,7 @@ void hb_fsClose( FHANDLE hFileHandle ) errno = 0; - #if defined(__WIN32__) + #if defined(X__WIN32__) CloseHandle( ( HANDLE ) hFileHandle ); #else close( hFileHandle ); @@ -629,16 +629,6 @@ void hb_fsSetDevMode( FHANDLE hFileHandle, USHORT uiDevMode ) } -void hb_fsSetDevRaw( FHANDLE hFileHandle ) -{ - hb_fsSetDevMode( hFileHandle, FD_BINARY ); -} - -void hb_fsSetDevText( FHANDLE hFileHandle ) -{ - hb_fsSetDevMode( hFileHandle, FD_TEXT ); -} - USHORT hb_fsRead( FHANDLE hFileHandle, BYTE * pBuff, USHORT uiCount ) { USHORT uiRead; @@ -649,7 +639,7 @@ USHORT hb_fsRead( FHANDLE hFileHandle, BYTE * pBuff, USHORT uiCount ) errno = 0; - #if defined(__WIN32__) + #if defined(X__WIN32__) { DWORD dwRead = 0; BOOL bError; @@ -687,7 +677,7 @@ USHORT hb_fsWrite( FHANDLE hFileHandle, BYTE * pBuff, USHORT uiCount ) errno = 0; - #if defined(__WIN32__) + #if defined(X__WIN32__) { DWORD dwWritten = 0; BOOL bError; @@ -734,7 +724,7 @@ ULONG hb_fsReadLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount ) errno = 0; - #if defined(__WIN32__) + #if defined(X__WIN32__) { BOOL bError; bError=ReadFile( ( HANDLE ) hFileHandle, pBuff, ulCount, &ulRead, NULL ); @@ -807,7 +797,7 @@ ULONG hb_fsWriteLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount ) errno = 0; - #if defined(__WIN32__) + #if defined(X__WIN32__) { BOOL bError; bError=WriteFile( ( HANDLE ) hFileHandle, pBuff, ulCount, &ulWritten, NULL ); @@ -910,10 +900,10 @@ ULONG hb_fsSeek( FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags ) /* get current offset */ errno = 0; - #if defined(__WIN32__) + #if defined(X__WIN32__) ulPos = SetFilePointer( ( HANDLE ) hFileHandle, 0, NULL, FILE_CURRENT ); - if ((DWORD)ulPos ==0xFFFFFFFF) + if ((DWORD)ulPos = (DWORD)-1) errno=GetLastError(); #else ulPos = lseek( hFileHandle, 0, SEEK_CUR ); @@ -952,9 +942,9 @@ ULONG hb_fsSeek( FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags ) #elif defined(HB_FS_FILE_IO) errno = 0; - #if defined(__WIN32__) + #if defined(X__WIN32__) ulPos = SetFilePointer( ( HANDLE ) hFileHandle, lOffset, NULL, (DWORD)Flags ); - if ((DWORD)ulPos ==0xFFFFFFFF) + if ((DWORD)ulPos = (DWORD)-1) errno=GetLastError(); #else @@ -988,9 +978,9 @@ ULONG hb_fsTell( FHANDLE hFileHandle ) #if defined(HB_FS_FILE_IO) errno = 0; - #if defined(__WIN32__) + #if defined(X__WIN32__) ulPos = SetFilePointer( ( HANDLE ) hFileHandle, 0, NULL, FILE_CURRENT ); - if ((DWORD)ulPos ==0xFFFFFFFF) + if ((DWORD)ulPos = (DWORD)-1) errno=GetLastError(); #else @@ -1247,30 +1237,10 @@ void hb_fsCommit( FHANDLE hFileHandle ) { HB_TRACE(HB_TR_DEBUG, ("hb_fsCommit(%p)", hFileHandle)); -#if defined(__WATCOMC__) +#if defined(HB_OS_WIN_32) - _dos_commit( hFileHandle ); - -#elif defined(HB_FS_FILE_IO) && !defined(HB_OS_OS2) && !defined(HB_OS_UNIX) - - { - int dup_handle; - - errno = 0; - #if defined(__WIN32__) - { - BOOL bSuccess; - bSuccess=FlushFileBuffers( (HANDLE) hFileHandle ); - if (!bSuccess) - errno=((int)GetLastError()); - } - #else - dup_handle = dup( hFileHandle ); - if( dup_handle != -1 ) - close( dup_handle ); - #endif - s_uiErrorLast = errno; - } + bResult = FlushFileBuffers( ( HANDLE ) hFileHandle ); + s_uiErrorLast = ( USHORT ) GetLastError(); #elif defined(HB_OS_OS2) @@ -1298,6 +1268,24 @@ void hb_fsCommit( FHANDLE hFileHandle ) s_uiErrorLast = ( fsync( hFileHandle ) < -1 ) ? FS_ERROR : 0; #endif +#elif defined(__WATCOMC__) + + _dos_commit( hFileHandle ); + +#elif defined(HB_FS_FILE_IO) && !defined(HB_OS_OS2) && !defined(HB_OS_UNIX) + + { + int dup_handle; + + errno = 0; + + dup_handle = dup( hFileHandle ); + if( dup_handle != -1 ) + close( dup_handle ); + + s_uiErrorLast = errno; + } + #else s_uiErrorLast = FS_ERROR; diff --git a/harbour/source/rtl/profiler.prg b/harbour/source/rtl/profiler.prg index 976fb6b198..2b2a5f68ca 100644 --- a/harbour/source/rtl/profiler.prg +++ b/harbour/source/rtl/profiler.prg @@ -2,7 +2,7 @@ * $Id$ */ -/* +/* * Harbour Project source code: * Profiler reporting classes * @@ -147,7 +147,7 @@ Local n @ 3, 0 Say " Total Ticks: " + str( oProfile:totalTicks() ) @ 4, 0 Say "Total Seconds: " + str( oProfile:totalSeconds() ) -Return NIL +Return( NIL ) Static Function DrawScreen( cTitle ) @@ -155,16 +155,16 @@ Static Function DrawScreen( cTitle ) @ 0, 0 Say padr( cTitle, maxcol() + 1 ) Color "n/w" -Return NIL +Return( NIL ) Function DoNothingForTwoSeconds() inkey( 2 ) -Return NIL +Return( NIL ) Function CallMe500Times() -Return NIL +Return( NIL ) Static Function Browser( oBrowse ) Local lBrowsing := .T. @@ -178,34 +178,34 @@ Local nKey Do Case - Case nKey == K_ESC - lBrowsing := .F. + Case nKey == K_ESC + lBrowsing := .F. - Case nKey == K_DOWN - oBrowse:down() + Case nKey == K_DOWN + oBrowse:down() - Case nKey == K_UP - oBrowse:up() + Case nKey == K_UP + oBrowse:up() - Case nKey == K_LEFT - oBrowse:left() + Case nKey == K_LEFT + oBrowse:left() - Case nKey == K_RIGHT - oBrowse:right() + Case nKey == K_RIGHT + oBrowse:right() - Case nKey == K_PGDN - oBrowse:pageDown() + Case nKey == K_PGDN + oBrowse:pageDown() - Case nKey == K_PGUP - oBrowse:pageUp() + Case nKey == K_PGUP + oBrowse:pageUp() - // And so on.... (not really necessary for this test) + // And so on.... (not really necessary for this test) EndCase - + EndDo -Return NIL +Return( NIL ) #endif @@ -220,13 +220,13 @@ Create Class HBProfileEntity Var nCalls ReadOnly Var nTicks ReadOnly - Access nSeconds + Access nSeconds Access nMeanTicks Access nMeanSeconds Method init Method describe - + End Class ///// @@ -237,27 +237,27 @@ Method init( cName, aInfo ) Class HBProfileEntity ::nCalls := aInfo[ 1 ] ::nTicks := aInfo[ 2 ] -Return self +Return( self ) ///// Access nSeconds Class HBProfileEntity -Return HB_Clocks2Secs( ::nTicks ) +Return( HB_Clocks2Secs( ::nTicks ) ) ///// Access nMeanTicks Class HBProfileEntity -Return iif( ::nCalls == 0, 0, ::nTicks / ::nCalls ) +Return( if( ::nCalls == 0, 0, ::nTicks / ::nCalls ) ) ///// Access nMeanSeconds Class HBProfileEntity -Return iif( ::nCalls == 0, 0, ::nSeconds / ::nCalls ) +Return( if( ::nCalls == 0, 0, ::nSeconds / ::nCalls ) ) ///// Method describe Class HBProfileEntity -Return "Base Entity" +Return( "Base Entity" ) //////////////////////////////////////////////////////////////////////////// // Class: HBProfileFunction @@ -273,7 +273,7 @@ End Class ///// Method describe Class HBProfileFunction -Return "Function" +Return( "Function" ) //////////////////////////////////////////////////////////////////////////// // Class: HBProfileMethod @@ -289,7 +289,7 @@ End Class ///// Method describe Class HBProfileMethod -Return "Method" +Return( "Method" ) //////////////////////////////////////////////////////////////////////////// // Class: HBProfile @@ -327,7 +327,7 @@ Local lProfile := __setProfiler( .F. ) __setProfiler( lProfile ) -Return self +Return( self ) ///// @@ -335,13 +335,13 @@ Method reset Class HBProfile ::aProfile := {} -Return self +Return( self ) ///// Method ignoreSymbol( cSymbol ) Class HBProfile Local cProfPrefix := "HBPROFILE" -Return ( left( cSymbol, len( cProfPrefix ) ) == cProfPrefix ) .Or. ( cSymbol == "__SETPROFILER" ) +Return( ( left( cSymbol, len( cProfPrefix ) ) == cProfPrefix ) .Or. ( cSymbol == "__SETPROFILER" ) ) ///// @@ -391,7 +391,7 @@ Local n // Collect class members. nMembers := len( aMembers := __classSel( n ) ) - + For nMember := 1 To nMembers // If we've got a member name... @@ -403,14 +403,14 @@ Local n Next EndIf - + ++n - + EndDo __setProfiler( lProfile ) -Return self +Return( self ) ///// @@ -421,7 +421,7 @@ Local lProfile := __setProfiler( .F. ) __setProfiler( lProfile ) -Return self +Return( self ) ///// @@ -432,7 +432,7 @@ Local lProfile := __setProfiler( .F. ) __setProfiler( lProfile ) -Return self +Return( self ) ///// @@ -443,7 +443,7 @@ Local lProfile := __setProfiler( .F. ) __setProfiler( lProfile ) -Return self +Return( self ) ///// @@ -454,7 +454,7 @@ Local lProfile := __setProfiler( .F. ) __setProfiler( lProfile ) -Return self +Return( self ) ///// @@ -465,7 +465,7 @@ Local lProfile := __setProfiler( .F. ) __setProfiler( lProfile ) -Return self +Return( self ) ///// @@ -477,7 +477,7 @@ Local nCalls := 0 __setProfiler( lProfile ) -Return nCalls +Return( nCalls ) ///// @@ -489,7 +489,7 @@ Local nTicks := 0 __setProfiler( lProfile ) -Return nTicks +Return( nTicks ) ///// @@ -501,7 +501,7 @@ Local nSeconds := 0 __setProfiler( lProfile ) -Return nSeconds +Return( nSeconds ) //////////////////////////////////////////////////////////////////////////// // Class: HBProfileReport @@ -522,7 +522,7 @@ Create Class HBProfileReport Method init Method generate - + End Class ///// @@ -534,7 +534,7 @@ Local lProfile := __setProfiler( .F. ) __setProfiler( lProfile ) -Return self +Return( self ) ///// @@ -542,13 +542,13 @@ Method writeLines( aLines ) Class HBProfileReport aeval( aLines, {|c| qout( c ) } ) -Return self +Return( self ) ///// Method header Class HBProfileReport -Return { "Name Type Calls Ticks Seconds",; - "=================================== ========== ======== =========== ===========" } +Return( { "Name Type Calls Ticks Seconds",; + "=================================== ========== ======== =========== ===========" } ) ///// @@ -556,16 +556,16 @@ Method emitHeader Class HBProfileReport ::writeLines( ::header() ) -Return self +Return( self ) ///// Method line( oEntity ) Class HBProfileReport -Return { padr( oEntity:cName, 35 ) + " " + ; - padr( oEntity:describe(), 8 ) + " " + ; - padl( oEntity:nCalls, 10 ) + " " + ; - padl( oEntity:nTicks, 11 ) + " " + ; - str( oEntity:nSeconds, 11, 2 ) } +Return( { padr( oEntity:cName, 35 ) + " " + ; + padr( oEntity:describe(), 8 ) + " " + ; + padl( oEntity:nCalls, 10 ) + " " + ; + padl( oEntity:nTicks, 11 ) + " " + ; + str( oEntity:nSeconds, 11, 2 ) } ) ///// @@ -573,7 +573,7 @@ Method emitLine( oEntity ) Class HBProfileReport ::writeLines( ::line( oEntity ) ) -Return self +Return( self ) ///// @@ -582,11 +582,11 @@ Local lProfile := __setProfiler( .F. ) Default bFilter To {|| .T. } - ::emitHeader():oProfile:forEach( {|o| iif( eval( bFilter, o ), ::emitLine( o ), NIL ) } ) + ::emitHeader():oProfile:forEach( {|o| if( eval( bFilter, o ), ::emitLine( o ), NIL ) } ) __setProfiler( lProfile ) -Return self +Return( self ) //////////////////////////////////////////////////////////////////////////// // Class: HBProfileReportToFile @@ -613,7 +613,7 @@ Method writeLines( aLines ) Class HBProfileReportToFile aeval( aLines, {|c| fwrite( ::hFile, c + HB_OSNewLine() ) } ) EndIf -Return self +Return( self ) ///// @@ -631,7 +631,7 @@ Local lProfile := __setProfiler( .F. ) __setProfiler( lProfile ) -Return self +Return( self ) //////////////////////////////////////////////////////////////////////////// // Class: HBProfileReportToArray @@ -656,7 +656,7 @@ Method writeLines( aLines ) Class HBProfileReportToArray aeval( aLines, {|c| aadd( ::aReport, c ) } ) -Return self +Return( self ) ///// @@ -665,7 +665,7 @@ Method generate( bFilter ) Class HBProfileReportToArray ::aReport := {} ::super:generate( bFilter ) -Return ::aReport +Return( ::aReport ) //////////////////////////////////////////////////////////////////////////// // Class: HBProfileReportToString @@ -685,7 +685,7 @@ Local cReport := "" aeval( ::super:generate( bFilter ), {|c| cReport += c + HB_OSNewLine() } ) -Return cReport +Return( cReport ) //////////////////////////////////////////////////////////////////////////// // Class: HBProfileReportToTBrowse @@ -714,7 +714,7 @@ Method emitHeader Class HBProfileReportToTBrowse // No header required. -Return self +Return( self ) ///// @@ -723,7 +723,7 @@ Method emitLine( oEntity ) Class HBProfileReportToTBrowse // Don't "emit" anything, simply add the entity to the array. aadd( ::aReport, oEntity ) -Return self +Return( self ) ///// @@ -743,15 +743,15 @@ Local oBrowse oBrowse:goTopBlock := {|| ::nEntity := 1 } oBrowse:goBottomBlock := {|| ::nEntity := len( ::aReport ) } oBrowse:skipBlock := {|nSkip, nPos| nPos := ::nEntity, ; - ::nEntity := iif( nSkip > 0, ; + ::nEntity := if( nSkip > 0, ; min( len( ::aReport ), ::nEntity + nSkip ), ; max( 1, ::nEntity + nSkip ) ), ::nEntity - nPos } - ::addColumns( oBrowse ) + ::addColumns( oBrowse ) __setProfiler( lProfile ) -Return oBrowse +Return( oBrowse ) ///// @@ -765,13 +765,13 @@ Method addColumns( oBrowse ) Class HBProfileReportToTBrowse oBrowse:addColumn( tbcolumnnew( "Mean;Ticks", {|| str( ::currentEntity():nMeanTicks, 11, 2 ) } ) ) oBrowse:addColumn( tbcolumnnew( "Mean;Seconds", {|| str( ::currentEntity():nMeanSeconds, 11, 2 ) } ) ) -Return self +Return( self ) ///// Method currentEntity Class HBProfileReportToTBrowse -Return ::aReport[ ::nEntity ] +Return( ::aReport[ ::nEntity ] ) -/* +/* * profiler.prg ends here. */ diff --git a/harbour/source/vm/memvars.c b/harbour/source/vm/memvars.c index b689738d0f..c9ab5895c4 100644 --- a/harbour/source/vm/memvars.c +++ b/harbour/source/vm/memvars.c @@ -1152,9 +1152,9 @@ HB_FUNC( __MVDBGINFO ) HB_FUNC( __MVEXIST ) { HB_ITEM_PTR pName = hb_param( 1, HB_IT_STRING ); - PHB_DYNS pDyn = NULL; + PHB_DYNS pDyn; - hb_retl( pName && ( pDyn = hb_memvarFindSymbol( pName ) ) && pDyn->hMemvar ); + hb_retl( pName && ( pDyn = hb_memvarFindSymbol( pName ) ) != NULL && pDyn->hMemvar ); } HB_FUNC( __MVGET )