From 35b7c865f08d67f1ac5eb452ff91a0a6f1fe4a7b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 9 Aug 1999 05:21:31 +0000 Subject: [PATCH] 19990809-06:23 GMT+1 --- harbour/ChangeLog | 20 +++++++++ harbour/include/hbdefs.h | 14 +++--- harbour/include/memvars.ch | 20 +++++---- harbour/source/Makefile | 1 + harbour/source/odbc/odbc.c | 2 +- harbour/source/rtl/errorapi.c | 72 ++++++++++++++++++++++-------- harbour/source/rtl/menuto.prg | 31 +++++-------- harbour/tests/working/copyfile.prg | 8 ++-- harbour/tests/working/copyfrom.txt | 7 --- 9 files changed, 108 insertions(+), 67 deletions(-) delete mode 100644 harbour/tests/working/copyfrom.txt diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c36d346a10..9849e50ced 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,23 @@ +19990809-06:23 GMT+1 Victor Szel + * include/memvars.ch + ! #ifdef _MEMVARS_CH guard added. + ! Changed all comments to ANSI C style, since it's included in C code, too. + * source/rtl/errorapi.c + + Fixed logic for _errLaunch(), it seem ready now, plus highly + Clipper compatible. + * source/Makefile + + runner added. + * source/odbc/odbc.c + ! Small typo fixed. + * source/rtl/menuto.prg + + Handles non-declared variables correctly. Uses __MVSCOPE(). + * include/hbdefs.h + * Small cleanup, typo fix. + * tests/working/copyfile.prg + tests/working/copyfile.txt (removed) + % copyfile.txt is no longer needed. + * Open error test uses a much more rare file name. + 19990808-20:55 GMT+2 Ryszard Glab *source/compiler/harbour.y diff --git a/harbour/include/hbdefs.h b/harbour/include/hbdefs.h index 68b3c083d1..2539c55983 100644 --- a/harbour/include/hbdefs.h +++ b/harbour/include/hbdefs.h @@ -32,30 +32,30 @@ #if ! defined(HB_DONT_DEFINE_BASIC_TYPES) +#undef BOOL /* boolean */ +typedef int BOOL; + #undef BYTE typedef unsigned char BYTE; /* 1 byte unsigned */ -#undef WORD /* 2 bytes unsigned */ -typedef unsigned short int WORD; - #undef SHORT /* 2 bytes signed */ typedef short int SHORT; +#undef WORD /* 2 bytes unsigned */ +typedef unsigned short int WORD; + #undef USHORT /* 2 bytes unsigned */ typedef unsigned short int USHORT; #undef LONG /* 4 bytes signed */ typedef long LONG; -#undef ULONG /* 4 bytes signed */ +#undef ULONG /* 4 bytes unsigned */ typedef unsigned long ULONG; #undef DWORD /* 4 bytes unsigned */ typedef unsigned long DWORD; -#undef BOOL /* boolean */ -typedef int BOOL; - #undef FALSE #undef TRUE #define FALSE 0 diff --git a/harbour/include/memvars.ch b/harbour/include/memvars.ch index e1c4c0d10a..66ec3a2d79 100644 --- a/harbour/include/memvars.ch +++ b/harbour/include/memvars.ch @@ -4,11 +4,15 @@ /* NOTE: This file is also used by C code. */ -// Values returned from __MVSCOPE function -// -#define MV_NOT_FOUND -2 //not found in the symbols table -#define MV_UNKNOWN -1 //not created yet -#define MV_ERROR 0 //information cannot be obtained -#define MV_PUBLIC 1 //PUBLIC variable -#define MV_PRIVATE_GLOBAL 2 //PRIVATE created outside of current function/procedure -#define MV_PRIVATE_LOCAL 3 //PRIVATE created in current function/procedure +#ifndef _MEMVARS_CH +#define _MEMVARS_CH + +/* Values returned from __MVSCOPE() function */ +#define MV_NOT_FOUND -2 /* not found in the symbols table */ +#define MV_UNKNOWN -1 /* not created yet */ +#define MV_ERROR 0 /* information cannot be obtained */ +#define MV_PUBLIC 1 /* PUBLIC variable */ +#define MV_PRIVATE_GLOBAL 2 /* PRIVATE created outside of current function/procedure */ +#define MV_PRIVATE_LOCAL 3 /* PRIVATE created in current function/procedure */ + +#endif /* _MEMVARS_CH */ diff --git a/harbour/source/Makefile b/harbour/source/Makefile index 1e4b972c73..e227135ad8 100644 --- a/harbour/source/Makefile +++ b/harbour/source/Makefile @@ -12,5 +12,6 @@ DIRS=\ vm \ rdd \ tools \ + runner \ include $(ROOT)config/dir.cf diff --git a/harbour/source/odbc/odbc.c b/harbour/source/odbc/odbc.c index ee789c6ed1..9fc21e11b0 100644 --- a/harbour/source/odbc/odbc.c +++ b/harbour/source/odbc/odbc.c @@ -73,7 +73,7 @@ HB_INIT_SYMBOLS_BEGIN( odbc__InitSymbols ) HB_INIT_SYMBOLS_END( odbc__InitSymbols ); #pragma odbc__InitSymbols -HARBOUR HB_SQLALLOCEN( void ) /* HB_SQLALLOCENNNECT( @hEnv ) --> nRetCode */ +HARBOUR HB_SQLALLOCEN( void ) /* HB_SQLALLOCENV( @hEnv ) --> nRetCode */ { HENV hEnv; RETCODE ret = SQLAllocEnv( &hEnv ); diff --git a/harbour/source/rtl/errorapi.c b/harbour/source/rtl/errorapi.c index 42c2aec657..6a38a42542 100644 --- a/harbour/source/rtl/errorapi.c +++ b/harbour/source/rtl/errorapi.c @@ -47,10 +47,10 @@ WORD hb_errLaunch( PHB_ITEM pError ) if ( pError ) { - /* TODO: Determine if there was a BREAK in error handler. */ - BOOL bBreak = FALSE; - WORD nSequenceLevel = 0; - USHORT uiFlags = hb_errGetFlags( pError ); + /* TODO: Determine if there was a BREAK in the error handler. */ + BOOL bBreak; + WORD nSequenceLevel; + USHORT uiFlags; if ( ! IS_BLOCK( &errorBlock ) ) { @@ -64,34 +64,68 @@ WORD hb_errLaunch( PHB_ITEM pError ) hb_vmPush( pError ); hb_vmDo( 1 ); + /* TODO: Detect these properly */ + bBreak = FALSE; + nSequenceLevel = 0; + + uiFlags = hb_errGetFlags( pError ); + if ( bBreak ) { - wRetVal = E_BREAK; - } - else if ( IS_LOGICAL( &stack.Return ) ) - { - wRetVal = stack.Return.item.asLogical.value ? E_RETRY : E_DEFAULT; + if ( nSequenceLevel ) + { + wRetVal = E_BREAK; + /* TODO: Initiate a jump to the closest RECOVER statement */ + } + else + { + /* TODO: QUIT correctly, without any message */ + exit( 1 ); + } } else { - wRetVal = E_DEFAULT; - } + BOOL bFailure = FALSE; - if ( ( wRetVal == E_BREAK && nSequenceLevel == 0 ) || - ( wRetVal == E_DEFAULT && !( uiFlags & EF_CANDEFAULT ) ) || - ( wRetVal == E_RETRY && !( uiFlags & EF_CANRETRY ) ) ) - { - /* TODO: Change to internal error: */ - printf("Error recovery failure, ???? (0)"); - exit( 1 ); /* TODO: quit correctly */ + /* 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( &stack.Return ) || + ( uiFlags & EF_CANSUBSTITUTE ) ) + { + bFailure = TRUE; + } + else + { + wRetVal = stack.Return.item.asLogical.value ? E_RETRY : E_DEFAULT; + + if ( ( wRetVal == E_DEFAULT && !( uiFlags & EF_CANDEFAULT ) ) || + ( wRetVal == E_RETRY && !( uiFlags & EF_CANRETRY ) ) ) + { + bFailure = TRUE; + } + } + + if ( bFailure ) + { + /* TODO: Change to internal error: */ + printf("Error recovery failure, ???? (0)"); + exit( 1 ); /* TODO: quit correctly */ + } } } else - wRetVal = E_RETRY; + { + wRetVal = E_RETRY; /* Clipper does this, undocumented */ + } return wRetVal; } +/* NOTE: This should be called when the EF_CANSUBSTITUE flag was set */ +/* Since it this case the error handler will return the value */ +/* to be substituted */ + /* TODO: PHB_ITEM hb_errLaunchExt( PHB_ITEM pError ) { diff --git a/harbour/source/rtl/menuto.prg b/harbour/source/rtl/menuto.prg index 9a4206463a..169cf6fa65 100644 --- a/harbour/source/rtl/menuto.prg +++ b/harbour/source/rtl/menuto.prg @@ -20,7 +20,7 @@ #include "setcurs.ch" #include "inkey.ch" #include "color.ch" - +#include "memvars.ch" static aLevel := {} static nPointer := 1 @@ -60,20 +60,17 @@ function __MenuTo( bBlock, cVariable ) local nSaveCursor local cSaveReadVar - local bOldError - local lBlockError + local lDeclared // Detect if a memvar was passed - bOldError := errorblock( {|| __Break( NIL ) } ) - begin sequence - n := eval( bBlock ) - lBlockError := .F. - recover - lBlockError := .T. - __mvPUBLIC( cVariable ) - end sequence - errorblock( bOldError ) + if __mvSCOPE( cVariable ) <= MV_ERROR + __mvPUBLIC( cVariable ) + lDeclared := .T. + else + lDeclared := .F. + n := eval( bBlock ) + endif // if no prompts were defined, exit with 0 @@ -226,7 +223,7 @@ function __MenuTo( bBlock, cVariable ) eval( bBlock, n ) - if lBlockError + if lDeclared release ( cVariable ) endif @@ -234,11 +231,3 @@ function __MenuTo( bBlock, cVariable ) return n -// Temp emulation of the BREAK() function. -// NOTE: xExpr is not handled - -static function __Break( xExpr ) - - break - - return nil diff --git a/harbour/tests/working/copyfile.prg b/harbour/tests/working/copyfile.prg index f1439055e9..3b011d890d 100644 --- a/harbour/tests/working/copyfile.prg +++ b/harbour/tests/working/copyfile.prg @@ -5,9 +5,9 @@ FUNCTION Main() -// ? "1", __copyfile("COPYFROM.TXT") -? "2", __copyfile("COPYFROM.TXT", "COPYTO.TXT") -? "3", __copyfile("C.PRG", "B.PRG") -? "4", __copyfile("COPYFROM.TXT", "..") +// ? "1", __copyfile("COPYFROM.PRG") +? "2", __copyfile("COPYFROM.PRG", "COPYTO.TMP") +? "3", __copyfile("_NOTHERE.$$$", "COPYTO.TMP") +? "4", __copyfile("COPYFROM.PRG", "..") RETURN NIL diff --git a/harbour/tests/working/copyfrom.txt b/harbour/tests/working/copyfrom.txt deleted file mode 100644 index 03ad7acd74..0000000000 --- a/harbour/tests/working/copyfrom.txt +++ /dev/null @@ -1,7 +0,0 @@ -; Test file for COPYFILE.PRG -; Don't delete - -dslkfjgs;ldfg -dsfg;lkdsflgksd -gsdfl;gkjdsfg -df;lkgjsdfg