From ac72ee1208fb86a85d0e74807a87e5f2f873607a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 18 Sep 1999 01:49:19 +0000 Subject: [PATCH] 19990917-03:22 GMT+1 --- harbour/ChangeLog | 32 ++++++- harbour/funclist.txt | 4 +- harbour/include/itemapi.h | 1 + harbour/makefile.b16 | 3 +- harbour/makefile.b31 | 3 +- harbour/makefile.b32 | 3 +- harbour/makefile.b40 | 3 +- harbour/makefile.vc | 4 + harbour/source/rtl/Makefile | 1 + harbour/source/rtl/console.c | 4 +- harbour/source/rtl/itemapi.c | 15 ++++ harbour/source/rtl/tget.prg | 2 + harbour/source/tools/io.c | 134 ----------------------------- harbour/tests/working/rtl_test.prg | 41 +++++++-- 14 files changed, 101 insertions(+), 149 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 44b956905e..367cc79399 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,9 +1,37 @@ +19990917-03:22 GMT+1 Victor Szel + + * source/rtl/memofile.c + source/rtl/Makefile + makefile.* + funclist.txt + + MEMOREAD()/MEMOWRIT() functions added. + (Borland/MSVC makefiles modified, but not tested) + * tests/working/rtl_test.prg + + MEMOREAD()/MEMOWRIT() tests added. + * include/itemapi.h + source/rtl/itemapi.c + + hb_itemPutCPtr() Item API function added, to make it possible to + attach a buffer directly to a string item in a standard way, this + way one memcpy()/strcpy() can be saved, this can be used when the caller + have already allocated a buffer. Recommended when the expected string + size is very large. The allocated buffer size must be ulLen + 1. + * source/tools/io.c + - CD(), MD(), RD(), DISKFREE() removed since these are in the standard + RTL. + * source/rtl/tget.prg + ! Insert() fix by Kwon,Oh-Chul + * source/rtl/console.c + ! HB___ACCEPTSTR() one missing underscore added. + ! SAVESCREEN() pBuffer type changed back to void *, since xgrab() would not + be compatible, (char*) casts would not be needed, and gtSave() would have + to complain...in theory at least. + (What was the compiler (and which one) complaining about ?) + 19990917-21:10 EDT David G. Holm * include/extend.h % Changed local pointers in hb_xmemcpy() and hb_xmemset() from void * to BYTE * to keep Borland C compiler happy. - 19990917-18:00 EDT David G. Holm * include/extend.h @@ -99,7 +127,7 @@ % Internal vmDo() call replaced with standard API functions. ! Internal error removed, direct buffer string modification resolved. * source/rtl/objfunc.prg - + Explcitly repeated function names in the __ERR*() call changed to + + Explcitly repeated function names in the __ERR*() calls changed to PROCNAME(0). * source/vm/hvm.c include/ctoharb.h diff --git a/harbour/funclist.txt b/harbour/funclist.txt index 2a6310f55c..bcbf4132b2 100644 --- a/harbour/funclist.txt +++ b/harbour/funclist.txt @@ -160,10 +160,10 @@ MAXCOL ;R; MAXROW ;R; MEMOEDIT ;N; MEMOLINE ;N; -MEMOREAD ;N; +MEMOREAD ;R; MEMORY ;N; MEMOTRAN ;R; -MEMOWRIT ;N; +MEMOWRIT ;R; MEMVARBLOCK ;R; MIN ;R; MLCOUNT ;N; diff --git a/harbour/include/itemapi.h b/harbour/include/itemapi.h index bdd64484e5..c74c428f8a 100644 --- a/harbour/include/itemapi.h +++ b/harbour/include/itemapi.h @@ -72,6 +72,7 @@ extern PHB_ITEM hb_itemNew ( PHB_ITEM pNull ); extern USHORT hb_itemPCount ( void ); extern PHB_ITEM hb_itemParam ( USHORT uiParam ); extern PHB_ITEM hb_itemPutC ( PHB_ITEM pItem, char * szText ); +extern PHB_ITEM hb_itemPutCPtr ( PHB_ITEM pItem, char * szText, ULONG ulLen ); extern PHB_ITEM hb_itemPutCL ( PHB_ITEM pItem, char * szText, ULONG ulLen ); extern PHB_ITEM hb_itemPutDS ( PHB_ITEM pItem, char * szDate ); extern PHB_ITEM hb_itemPutDL ( PHB_ITEM pItem, long lJulian ); diff --git a/harbour/makefile.b16 b/harbour/makefile.b16 index 3152bb7743..8219b5c295 100644 --- a/harbour/makefile.b16 +++ b/harbour/makefile.b16 @@ -19,7 +19,7 @@ harbour.lib : arrays.obj asort.obj classes.obj codebloc.obj dates.obj \ dates2.obj datesx.obj \ debug.obj descend.obj devoutp.obj dynsym.obj environ.obj terror.obj \ errorapi.obj errorsys.obj harbinit.obj extend.obj files.obj fm.obj \ - hardcr.obj initsymb.obj itemapi.obj math.obj memvars.obj \ + hardcr.obj initsymb.obj itemapi.obj math.obj memofile.obj memvars.obj \ mathx.obj mtran.obj objfunc.obj set.obj setcolor.obj stringp.obj \ strings.obj stringsx.obj tclass.obj transfrm.obj @@ -56,6 +56,7 @@ initsymb.obj : initsymb.c extend.h hbdefs.h itemapi.obj : itemapi.c extend.h hbdefs.h math.obj : math.c extend.h hbdefs.h mathx.obj : mathx.c extend.h hbdefs.h +memofile.obj : memofile.c extend.h hbdefs.h memvars.obj : memvars.c extend.h hbdefs.h mtran.obj : mtran.c extend.h hbdefs.h objfunc.obj : objfunc.c extend.h hbdefs.h diff --git a/harbour/makefile.b31 b/harbour/makefile.b31 index 92a51df616..f7a240f403 100644 --- a/harbour/makefile.b31 +++ b/harbour/makefile.b31 @@ -22,7 +22,7 @@ harbour.lib : arrays.obj asort.obj classes.obj codebloc.obj copyfile.obj \ dates.obj descend.obj devoutp.obj dir.obj dynsym.obj environ.obj \ terror.obj errorapi.obj errorsys.obj harbinit.obj extend.obj \ filesys.obj gtapi.obj hardcr.obj initsymb.obj itemapi.obj \ - math.obj memvars.obj mtran.obj msguk.obj objfunc.obj \ + math.obj memofile.obj memvars.obj mtran.obj msguk.obj objfunc.obj \ set.obj setcolor.obj strings.obj symbols.obj \ tclass.obj transfrm.obj @@ -66,6 +66,7 @@ harbinit.obj : harbinit.prg extend.h hbdefs.h init.h pcode.h hardcr.obj : hardcr.c extend.h hbdefs.h itemapi.obj : itemapi.c extend.h hbdefs.h ctoharb.h itemapi.h set.h dates.h math.obj : math.c extend.h hbdefs.h +memofile.obj : memofile.c extend.h hbdefs.h memvars.obj : memvars.c extend.h hbdefs.h mtran.obj : mtran.c extend.h hbdefs.h objfunc.obj : objfunc.prg extend.h hbdefs.h init.h pcode.h diff --git a/harbour/makefile.b32 b/harbour/makefile.b32 index 8b9f4087b6..ce2288bf70 100644 --- a/harbour/makefile.b32 +++ b/harbour/makefile.b32 @@ -23,7 +23,7 @@ harbour.lib : achoice.obj adir.obj alert.obj arrays.obj asort.obj \ dir.obj do.obj dynsym.obj environ.obj terror.obj \ errorapi.obj errorsys.obj harbinit.obj extend.obj fileread.obj filesys.obj fm.obj \ hardcr.obj hb_f.obj hvm.obj initsymb.obj inkey.obj itemapi.obj \ - langapi.obj math.obj mathx.obj memvars.obj menuto.obj mtran.obj msges.obj \ + langapi.obj math.obj mathx.obj memofile.obj memvars.obj menuto.obj mtran.obj msges.obj \ objfunc.obj readvar.obj xsavescr.obj memvarbl.obj \ set.obj setcolor.obj setkey.obj strfmt.obj strings.obj symbols.obj stringp.obj \ stringsx.obj tbcolumn.obj tbrowse.obj tbrwtext.obj tclass.obj tget.obj tgetlist.obj tone.obj transfrm.obj @@ -66,6 +66,7 @@ itemapi.obj : itemapi.c extend.h hbdefs.h langapi.obj : langapi.c extend.h hbdefs.h math.obj : math.c extend.h hbdefs.h mathx.obj : mathx.c extend.h hbdefs.h +memofile.obj : memofile.c extend.h hbdefs.h memvars.obj : memvars.c extend.h hbdefs.h menuto.obj : menuto.c extend.h hbdefs.h msges.obj : msges.c extend.h hbdefs.h diff --git a/harbour/makefile.b40 b/harbour/makefile.b40 index a506530db5..dfd40186e8 100644 --- a/harbour/makefile.b40 +++ b/harbour/makefile.b40 @@ -21,7 +21,7 @@ harbour.lib : arrays.obj asort.obj classes.obj codebloc.obj alert.obj \ dir.obj dynsym.obj environ.obj terror.obj menu.obj \ errorapi.obj errorsys.obj harbinit.obj extend.obj files.obj \ hardcr.obj hb_f.obj initsymb.obj inkey.obj itemapi.obj memvars.obj \ - math.obj mathx.obj msguk.obj mtran.obj objfunc.obj \ + memofile.obj math.obj mathx.obj msguk.obj mtran.obj objfunc.obj \ set.obj setcolor.obj symbols.obj strings.obj stringp.obj \ stringsx.obj tclass.obj transfrm.obj copyfile.obj @@ -55,6 +55,7 @@ inkey.obj : inkey.c extend.h hbdefs.h itemapi.obj : itemapi.c extend.h hbdefs.h math.obj : math.c extend.h hbdefs.h memvars.obj : memvars.c extend.h hbdefs.h +memofile.obj : memofile.c extend.h hbdefs.h mathx.obj : mathx.c extend.h hbdefs.h msguk.obj : msguk.c extend.h hbdefs.h mtran.obj : mtran.c extend.h hbdefs.h diff --git a/harbour/makefile.vc b/harbour/makefile.vc index f84cc2f531..afc6af16e7 100644 --- a/harbour/makefile.vc +++ b/harbour/makefile.vc @@ -89,6 +89,7 @@ HARBOUR_LIB_OBJS = \ $(OBJ_DIR)\itemapi.obj \ $(OBJ_DIR)\langapi.obj \ $(OBJ_DIR)\math.obj \ + $(OBJ_DIR)\memofile.obj \ $(OBJ_DIR)\memvarbl.obj \ $(OBJ_DIR)\memvars.obj \ $(OBJ_DIR)\menuto.obj \ @@ -417,6 +418,9 @@ $(RTL_DIR)\memvarbl.c : $(RTL_DIR)\memvarbl.prg $(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/rtl/Makefile b/harbour/source/rtl/Makefile index b554d1849c..882a5ada5b 100644 --- a/harbour/source/rtl/Makefile +++ b/harbour/source/rtl/Makefile @@ -25,6 +25,7 @@ C_SOURCES=\ itemapi.c \ langapi.c \ math.c \ + memofile.c \ memvars.c \ mouseapi.c \ mtran.c \ diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index 9da078f53e..a7c5615952 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -1043,7 +1043,7 @@ HARBOUR HB_SAVESCREEN( void ) #ifdef HARBOUR_USE_GTAPI USHORT uiX; USHORT uiCoords[ 4 ]; - char * pBuffer; + void * pBuffer; uiCoords[ 0 ] = 0; uiCoords[ 1 ] = 0; @@ -1196,7 +1196,7 @@ HARBOUR HB___ACCEPT( void ) /* Internal Clipper function used in ACCEPT command hb_retc( s_szAcceptResult ); } -HARBOUR HB__ACCEPTSTR( void ) +HARBOUR HB___ACCEPTSTR( void ) { hb_retc( s_szAcceptResult ); } diff --git a/harbour/source/rtl/itemapi.c b/harbour/source/rtl/itemapi.c index 35c9d182cf..d4beb61220 100644 --- a/harbour/source/rtl/itemapi.c +++ b/harbour/source/rtl/itemapi.c @@ -395,6 +395,21 @@ PHB_ITEM hb_itemPutCL( PHB_ITEM pItem, char * szText, ULONG ulLen ) return pItem; } +PHB_ITEM hb_itemPutCPtr( PHB_ITEM pItem, char * szText, ULONG ulLen ) +{ + if( pItem ) + hb_itemClear( pItem ); + else + pItem = hb_itemNew( NULL ); + + pItem->type = IT_STRING; + pItem->item.asString.length = ulLen; + pItem->item.asString.value = szText; + pItem->item.asString.value[ ulLen ] = '\0'; + + return pItem; +} + char * hb_itemGetC( PHB_ITEM pItem ) { if( pItem && IS_STRING( pItem ) ) diff --git a/harbour/source/rtl/tget.prg b/harbour/source/rtl/tget.prg index 685373529c..a746dc14f0 100644 --- a/harbour/source/rtl/tget.prg +++ b/harbour/source/rtl/tget.prg @@ -455,6 +455,8 @@ METHOD Insert(cChar) CLASS TGet ::BadDate := .f. endif + ::Display() // Kwon,Oh-Chul + return Self //---------------------------------------------------------------------------// diff --git a/harbour/source/tools/io.c b/harbour/source/tools/io.c index f65ba1e80e..58a5543e4c 100644 --- a/harbour/source/tools/io.c +++ b/harbour/source/tools/io.c @@ -10,125 +10,6 @@ #include #endif -/* $DOC$ - * $FUNCNAME$ - * CD() - * $CATEGORY$ - * DOS - * $ONELINER$ - * $SYNTAX$ - * CD() - * $ARGUMENTS$ - * DIR TO BE CHANGED - * $RETURNS$ - * .T. IF SUCEFUL - * .F. IF NOT - * - * $DESCRIPTION$ - * CHANGE THE CURRENT DIRECTORY - * $EXAMPLES$ - * IF CD("OLA") - * RETURN(.T.) - * ELSE - * RETURN(.F.) - * ENDIF - * - * $SEEALSO$ - * - * $INCLUDE$ - * extend.h dos.h dir.h bios.h - * $END$ - */ - -HARBOUR HB_CD( void ) -{ -#ifdef __DOS__ - hb_retni( ISCHAR( 1 ) ? chdir( hb_parc( 1 ) ) : 0 ); -#else - hb_retni( 0 ); -#endif -} - -/* $DOC$ - * $FUNCNAME$ - * MD() - * $CATEGORY$ - * DOS - * $ONELINER$ - * - * $SYNTAX$ - * MD() - * $ARGUMENTS$ - * DIRECTORY TO BE CREATED - * $RETURNS$ - * .T. IF SUCEFUL - * .F. IF NOT - * - * $DESCRIPTION$ - * CREATE A DIRECTORY - * $EXAMPLES$ - * IF MD("OLA") - * RETURN(.T.) - * ELSE - * RETURN(.F.) - * ENDIF - * - * $SEEALSO$ - * - * $INCLUDE$ - * extend.h dos.h dir.h bios.h - * $END$ - */ - -HARBOUR HB_MD(void) -{ -#ifdef __DOS__ - hb_retni( ISCHAR( 1 ) ? mkdir( hb_parc( 1 ) ) : 0 ); -#else - hb_retni( 0 ); -#endif -} - -/* $DOC$ - * $FUNCNAME$ - * RD() - * $CATEGORY$ - * DOS - * $ONELINER$ - * - * $SYNTAX$ - * RD() - * $ARGUMENTS$ - * DIR TO BE DELETED - * $RETURNS$ - * .T. IF SUCEFUL - * .F. IF NOT - * - * $DESCRIPTION$ - * REMOVE A DIRECTORY - * $EXAMPLES$ - * IF RD("OLA") - * RETURN(.T.) - * ELSE - * RETURN(.F.) - * ENDIF - * - * $SEEALSO$ - * - * $INCLUDE$ - * extend.h dos.h dir.h bios.h - * $END$ - */ - -HARBOUR HB_RD( void ) -{ -#ifdef __DOS__ - hb_retni( ISCHAR( 1 ) ? rmdir( hb_parc( 1 ) ) : 0 ); -#else - hb_retni( 0 ); -#endif -} - HARBOUR HB_DISKUSED( void ) { #ifdef DOS @@ -150,21 +31,6 @@ HARBOUR HB_DISKUSED( void ) #endif } -HARBOUR HB_DISKFREE( void ) -{ -#ifdef DOS - struct diskfree_t disk; - - _dos_getdiskfree( 0, &disk ); - - hb_retnl( ( long ) disk.avail_clusters * - ( long ) disk.sectors_per_cluster * - ( long ) disk.bytes_per_sector ); -#else - hb_retnl( 0 ); -#endif -} - HARBOUR HB_DISKFULL( void ) { #ifdef DOS diff --git a/harbour/tests/working/rtl_test.prg b/harbour/tests/working/rtl_test.prg index 8ad0abce07..b4a6d8a3bd 100644 --- a/harbour/tests/working/rtl_test.prg +++ b/harbour/tests/working/rtl_test.prg @@ -73,6 +73,7 @@ STATIC s_nEndTime STATIC scString STATIC scStringE STATIC scStringZ +STATIC scStringW STATIC snIntZ STATIC snDoubleZ STATIC snIntP @@ -98,6 +99,7 @@ MEMVAR mxNotHere /* Please don't declare this variable, since it's used to test MEMVAR mcString MEMVAR mcStringE MEMVAR mcStringZ +MEMVAR mcStringW MEMVAR mnIntZ MEMVAR mnDoubleZ MEMVAR mnIntP @@ -1671,10 +1673,10 @@ STATIC FUNCTION Main_MISC() to hide different path handling, since Harbour is platform independent. */ - TEST_LINE( __copyfile("$$COPYFR.TMP") , "E BASE 2010 Argument error __COPYFILE " ) - TEST_LINE( __copyfile("$$COPYFR.TMP", "$$COPYTO.TMP") , NIL ) - TEST_LINE( __copyfile("_NOTHERE.$$$", "$$COPYTO.TMP") , "E BASE 2012 Open error _NOTHERE.$$$ F:DR" ) - TEST_LINE( __copyfile("$$COPYFR.TMP", "*INVALID*.") , "E BASE 2012 Create error *INVALID*. F:DR" ) + TEST_LINE( __CopyFile("$$COPYFR.TMP") , "E BASE 2010 Argument error __COPYFILE " ) + TEST_LINE( __CopyFile("$$COPYFR.TMP", "$$COPYTO.TMP") , NIL ) + TEST_LINE( __CopyFile("_NOTHERE.$$$", "$$COPYTO.TMP") , "E BASE 2012 Open error _NOTHERE.$$$ F:DR" ) + TEST_LINE( __CopyFile("$$COPYFR.TMP", "*INVALID*.") , "E BASE 2012 Create error *INVALID*. F:DR" ) FErase("$$COPYFR.TMP") FErase("$$COPYTO.TMP") @@ -1949,6 +1951,24 @@ STATIC FUNCTION Main_MISC() TEST_LINE( MEMVARBLOCK( "mxNotHere" ) , NIL ) TEST_LINE( MEMVARBLOCK( "mcString" ) , "{||...}" ) + /* MEMOWRITE()/MEMOREAD() */ + + TEST_LINE( MemoWrit() , .F. ) + TEST_LINE( MemoWrit("$$MEMOFI.TMP") , .F. ) + TEST_LINE( MemoWrit("$$MEMOFI.TMP","") , .T. ) + TEST_LINE( MemoRead("$$MEMOFI.TMP") , "" ) + TEST_LINE( MemoWrit("$$MEMOFI.TMP",scStringZ) , .T. ) + TEST_LINE( MemoRead("$$MEMOFI.TMP") , "A"+Chr(0)+"B" ) + TEST_LINE( MemoWrit("$$MEMOFI.TMP",Chr(26)) , .T. ) + TEST_LINE( MemoRead("$$MEMOFI.TMP") , ""+Chr(26)+"" ) + TEST_LINE( MemoWrit("$$MEMOFI.TMP",scStringW) , .T. ) + TEST_LINE( MemoRead("$$MEMOFI.TMP") , ""+Chr(13)+""+Chr(10)+""+Chr(10)+""+Chr(9)+"" ) + TEST_LINE( MemoWrit("*INVALI*.TMP",scStringZ) , .F. ) + TEST_LINE( MemoRead() , "" ) + TEST_LINE( MemoRead("*INVALI*.TMP") , "" ) + + FErase("$$MEMOFI.TMP") + RETURN NIL #ifdef __HARBOUR__ @@ -2101,6 +2121,7 @@ STATIC FUNCTION TEST_BEGIN( cParam ) scString := "HELLO" scStringE := "" scStringZ := "A" + Chr( 0 ) + "B" + scStringW := Chr(13)+Chr(10)+Chr(141)+Chr(10)+Chr(9) snIntZ := 0 snDoubleZ := 0.0 snIntP := 10 @@ -2147,6 +2168,7 @@ STATIC FUNCTION TEST_BEGIN( cParam ) PUBLIC mcString := "HELLO" PUBLIC mcStringE := "" PUBLIC mcStringZ := "A" + Chr( 0 ) + "B" + PUBLIC mcStringW := Chr(13)+Chr(10)+Chr(141)+Chr(10)+Chr(9) PUBLIC mnIntZ := 0 PUBLIC mnDoubleZ := 0.0 PUBLIC mnIntP := 10 @@ -2267,7 +2289,16 @@ STATIC FUNCTION XToStr( xValue ) LOCAL cType := ValType( xValue ) DO CASE - CASE cType == "C" ; RETURN '"' + StrTran( xValue, Chr(0), '"+Chr(0)+"' ) + '"' + CASE cType == "C" + + xValue := StrTran( xValue, Chr(0), '"+Chr(0)+"' ) + xValue := StrTran( xValue, Chr(9), '"+Chr(9)+"' ) + xValue := StrTran( xValue, Chr(10), '"+Chr(10)+"' ) + xValue := StrTran( xValue, Chr(13), '"+Chr(13)+"' ) + xValue := StrTran( xValue, Chr(26), '"+Chr(26)+"' ) + + RETURN '"' + xValue + '"' + CASE cType == "N" ; RETURN LTrim( Str( xValue ) ) CASE cType == "D" ; RETURN 'SToD("' + DToS( xValue ) + '")' CASE cType == "L" ; RETURN iif( xValue, ".T.", ".F." )