From 74722fa1e4df7815ecf5d7f4513564df5779988c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 18 Sep 1999 03:13:31 +0000 Subject: [PATCH] 19990917-04:58 GMT+1 --- harbour/ChangeLog | 14 ++++ harbour/makefile.vc | 6 +- harbour/source/compiler/harbour.y | 2 +- harbour/source/rtl/console.c | 8 +- harbour/source/rtl/memofile.c | 118 ++++++++++++++++++++++++++++++ harbour/source/vm/hvm.c | 12 +++ 6 files changed, 154 insertions(+), 6 deletions(-) create mode 100644 harbour/source/rtl/memofile.c diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 367cc79399..43b5456658 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,17 @@ +19990917-04:58 GMT+1 Victor Szel + + * source/vm/hvm.c + + Added WORD typedef for HARBOUR_OBJ_GENERATION section. + * source/rtl/memofile.c + + Added, this time for sure. + * makefile.vc + ! Now in alphabetical order. + * source/compiler/harbour.y + + Now the compiler shows if a message is a YACC error. + * source/rtl/console.c + + hb_max_row() now returns 23 for UNIXes and 24 otherwise. + % fputs(" "...) -> fputc(' '...) + 19990917-03:22 GMT+1 Victor Szel * source/rtl/memofile.c diff --git a/harbour/makefile.vc b/harbour/makefile.vc index afc6af16e7..b034e23229 100644 --- a/harbour/makefile.vc +++ b/harbour/makefile.vc @@ -412,15 +412,15 @@ $(OBJ_DIR)\langapi.obj : $(RTL_DIR)\langapi.c $(OBJ_DIR)\math.obj : $(RTL_DIR)\math.c $(CC) $(CLIBFLAGS) -Fo$@ $** +$(OBJ_DIR)\memofile.obj : $(RTL_DIR)\memofile.c + $(CC) $(CLIBFLAGS) -Fo$@ $** + $(RTL_DIR)\memvarbl.c : $(RTL_DIR)\memvarbl.prg $(HARBOUR_EXE) $** $(HARBOURFLAGS) -o$@ $(OBJ_DIR)\memvarbl.obj : $(RTL_DIR)\memvarbl.c $(CC) $(CLIBFLAGS) -Fo$@ $** -$(OBJ_DIR)\memofile.obj : $(RTL_DIR)\memofile.c - $(CC) $(CLIBFLAGS) -Fo$@ $** - $(OBJ_DIR)\memvars.obj : $(RTL_DIR)\memvars.c $(CC) $(CLIBFLAGS) -Fo$@ $** diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 9ed7a2e200..d9ed073e3b 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -307,7 +307,7 @@ char * _szCErrors[] = "Memory allocation error", "Memory reallocation error", "Freeing a NULL memory pointer", - "%s", /* YACC error messages */ + "Parser says: \"%s\"", "Jump offset too long", "Can't create output file: \'%s\'", "Can't create preprocessed output file: \'%s\'", diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index a7c5615952..f1ce6a5275 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -156,7 +156,11 @@ USHORT hb_max_row( void ) #ifdef HARBOUR_USE_GTAPI return hb_gtMaxRow(); #else - return 23; /* NOTE: Intentionally 23 to match Unix terminals */ + #if defined(HB_OS_UNIX_COMPATIBLE) + return 23; + #else + return 24; + #endif #endif } @@ -498,7 +502,7 @@ void hb_setpos( USHORT row, USHORT col ) for( uiCount = s_uiDevRow; uiCount < row; uiCount++ ) fputs( s_szCrLf, stdout ); for( uiCount = s_uiDevCol; uiCount < col; uiCount++ ) - fputs( " ", stdout ); + fputc( ' ', stdout ); #endif s_uiDevRow = row; diff --git a/harbour/source/rtl/memofile.c b/harbour/source/rtl/memofile.c new file mode 100644 index 0000000000..4380c86fad --- /dev/null +++ b/harbour/source/rtl/memofile.c @@ -0,0 +1,118 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * MEMOWRIT()/MEMOREAD() functions + * + * Copyright 1999 Victor Szel + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version, with one exception: + * + * The exception is that if you link the Harbour Runtime Library (HRL) + * and/or the Harbour Virtual Machine (HVM) with other files to produce + * an executable, this does not by itself cause the resulting executable + * to be covered by the GNU General Public License. Your use of that + * executable is in no way restricted on account of linking the HRL + * and/or HVM code into it. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit + * their web site at http://www.gnu.org/). + * + */ + +#include "extend.h" +#include "itemapi.h" +#include "filesys.h" + +/* NOTE: CA-Clipper has 64K (65516 bytes exactly) limit on read, in Harbour + this limit is extended, so we are not *stricly* compatible here. */ + +HARBOUR HB_MEMOREAD( void ) +{ + PHB_ITEM pFileName = hb_param( 1, IT_STRING ); + + if( pFileName ) + { + FHANDLE fhnd = hb_fsOpen( ( BYTE * ) hb_itemGetCPtr( pFileName ), FO_READ | FO_SHARED | FO_PRIVATE ); + + if( fhnd != FS_ERROR ) + { + ULONG ulSize = hb_fsSeek( fhnd, -sizeof( BYTE ), FS_END ) + sizeof( BYTE ); + BYTE * pbyBuffer; + + /* Don't read the file terminating EOF character */ + + #if ! defined(HB_OS_UNIX_COMPATIBLE) + { + BYTE byEOF = HB_CHAR_NUL; + + hb_fsRead( fhnd, &byEOF, sizeof( BYTE ) ); + + if( byEOF == HB_CHAR_EOF ) + ulSize--; + } + #endif + + pbyBuffer = ( BYTE * ) hb_xgrab( ulSize + sizeof( char ) ); + + hb_fsSeek( fhnd, 0, FS_SET ); + hb_fsReadLarge( fhnd, pbyBuffer, ulSize ); + + hb_fsClose( fhnd ); + + hb_itemPutCPtr( hb_itemReturnPtr(), ( char * ) pbyBuffer, ulSize ); + } + else + hb_retc( "" ); + } + else + hb_retc( "" ); +} + +HARBOUR HB_MEMOWRIT( void ) +{ + PHB_ITEM pFileName = hb_param( 1, IT_STRING ); + PHB_ITEM pString = hb_param( 2, IT_STRING ); + BOOL bRetVal = FALSE; + + if( pFileName && pString ) + { + FHANDLE fhnd = hb_fsCreate( ( BYTE * ) hb_itemGetCPtr( pFileName ), FC_NORMAL ); + + if( fhnd != FS_ERROR ) + { + ULONG ulSize = hb_itemGetCLen( pString ); + + bRetVal = ( hb_fsWriteLarge( fhnd, ( BYTE * ) hb_itemGetCPtr( pString ), ulSize ) == ulSize ); + + /* NOTE: CA-Clipper will add the EOF even if the write failed. */ + /* NOTE: CA-Clipper will not return .F. when the EOF could not be written. */ + #if ! defined(HB_OS_UNIX_COMPATIBLE) + { + BYTE byEOF = HB_CHAR_EOF; + + hb_fsWrite( fhnd, &byEOF, sizeof( BYTE ) ); + } + #endif + + hb_fsClose( fhnd ); + } + } + + hb_retl( bRetVal ); +} + + diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index d1bfedbdc1..32584b79ae 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -78,6 +78,18 @@ static void hb_vmDebuggerEndProc( void ); /* notifies the debugger for an end static void hb_vmArrayNew( HB_ITEM_PTR, USHORT ); /* creates array */ #ifdef HARBOUR_OBJ_GENERATION + +/* TODO: Remove these (WORD/DWORD) when the compiler is cleaned up from them. */ +#if defined(__IBMCPP__) + #undef WORD /* 2 bytes unsigned */ + typedef unsigned short int WORD; +#else + #if ! defined(HB_DONT_DEFINE_BASIC_TYPES) + #undef WORD /* 2 bytes unsigned */ + typedef unsigned short int WORD; + #endif +#endif + static void hb_vmProcessObjSymbols ( void ); /* process Harbour generated OBJ symbols */ typedef struct