From 22159d57b5bc7cf13151c00f738790203446652f Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 13 Dec 2006 17:46:43 +0000 Subject: [PATCH] 2006-12-13 18:45 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/console.c * pacify false CG error messages - Chen Kedem modifications (sizeof(int) in #if replaced by hardcoded 4 for compilers which does not allow to use sizeof() in #if directives) * harbour/TODO - removed console.c cleanup note from TOFIX * harbour/include/hbcomp.h * harbour/include/hbexprb.c * harbour/include/hbexprc.c * harbour/source/common/expropt1.c * minor code cleanup --- harbour/ChangeLog | 15 ++++++++++++++ harbour/TODO | 19 ------------------ harbour/include/hbcomp.h | 4 ++++ harbour/include/hbexprb.c | 18 ++++------------- harbour/include/hbexprc.c | 7 ++++--- harbour/source/common/expropt1.c | 6 +++--- harbour/source/rtl/console.c | 34 ++++++++++++++++++-------------- 7 files changed, 49 insertions(+), 54 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 152721a4e9..f8dbb0a145 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,21 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2006-12-13 18:45 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/console.c + * pacify false CG error messages - Chen Kedem modifications (sizeof(int) + in #if replaced by hardcoded 4 for compilers which does not allow to + use sizeof() in #if directives) + + * harbour/TODO + - removed console.c cleanup note from TOFIX + + * harbour/include/hbcomp.h + * harbour/include/hbexprb.c + * harbour/include/hbexprc.c + * harbour/source/common/expropt1.c + * minor code cleanup + 2006-12-12 14:55 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbstack.h ! fixed typo in function name, should be: hb_stackLocalVariable() diff --git a/harbour/TODO b/harbour/TODO index fd64531e1a..82a1cb5505 100644 --- a/harbour/TODO +++ b/harbour/TODO @@ -190,23 +190,4 @@ Status...: Open. *** -Assign to: -Detail...: The Borland CodeGuard warn about Access overrun in some - of the console IO functions, it appears to be a fault in - the way CG works when passing a static char * to a BYTE * - function. Once the console IO functions would be optimozed, - please take a look at this too. - - --tt21.prg-- - proc main() - SET PRINTER TO devtest - SET DEVICE TO PRINTER - DepPos( 1, 1 ) - return - ------------ - -Status...: Open. - -*** - ======================================================================= diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index 5cd710cc06..104b58f636 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -361,6 +361,10 @@ extern FILE *hb_comp_errFile; #define HB_COMP_ISSUPPORTED(flag) ( HB_COMP_PARAM->supported & (flag) ) +#define HB_SUPPORT_XBASE ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_XBASE) ) +#define HB_SUPPORT_HARBOUR ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_HARBOUR) ) +#define HB_SUPPORT_ARRSTR ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_ARRSTR) ) + #if defined( HB_MACRO_SUPPORT ) # define HB_MACRO_GENFLAGS HB_COMPFLAG_RT_MACRO #else diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index ee6fff624a..cd194e04c0 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -70,16 +70,6 @@ /* Forward declarations */ -#if defined( HB_MACRO_SUPPORT ) - #define HB_SUPPORT_XBASE ( HB_COMP_ISSUPPORTED(HB_SM_XBASE) ) - #define HB_SUPPORT_HARBOUR ( HB_COMP_ISSUPPORTED(HB_SM_HARBOUR) ) - #define HB_SUPPORT_ARRSTR ( HB_COMP_ISSUPPORTED(HB_SM_ARRSTR) ) -#else - #define HB_SUPPORT_XBASE ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_XBASE) ) - #define HB_SUPPORT_HARBOUR ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_HARBOUR) ) - #define HB_SUPPORT_ARRSTR ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_ARRSTR) ) -#endif - /* forward declaration of callback functions */ static HB_EXPR_FUNC( hb_compExprUseDummy ); @@ -884,7 +874,7 @@ static HB_EXPR_FUNC( hb_compExprUseRef ) memcmp( szAlias, "MEMVAR", iLen ) == 0 && pExp->value.asAlias.pVar->ExprType == HB_ET_VARIABLE ) { /* @M-> @MEMVAR-> or @MEMVA-> or @MEMV-> */ -#if !defined(HB_MACRO_SUPPORT) +#if !defined(HB_MACRO_SUPPORT) HB_EXPR_PCODE2( hb_compGenVarPCode, HB_P_PUSHMEMVARREF, pExp->value.asAlias.pVar->value.asSymbol ); #else HB_EXPR_PCODE2( hb_compMemvarGenPCode, HB_P_MPUSHMEMVARREF, pExp->value.asAlias.pVar->value.asSymbol ); @@ -1559,9 +1549,9 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) } } - #ifndef HB_MACRO_SUPPORT - hb_compFunCallCheck( HB_COMP_PARAM, pName->value.asSymbol, usCount ); - #endif +#ifndef HB_MACRO_SUPPORT + hb_compFunCallCheck( HB_COMP_PARAM, pName->value.asSymbol, usCount ); +#endif if( ( strcmp( "AT", pName->value.asSymbol ) == 0 ) && usCount == 2 ) { diff --git a/harbour/include/hbexprc.c b/harbour/include/hbexprc.c index 2d158e06a9..ed6cf85d16 100644 --- a/harbour/include/hbexprc.c +++ b/harbour/include/hbexprc.c @@ -281,7 +281,7 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ) HB_EXPR_PCODE1( hb_compGenPCode1, bOpEq ); return; } - else if( pSelf->value.asOperator.pRight->ExprType == HB_ET_VARIABLE ) + else if( iType == HB_ET_VARIABLE ) { int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pRight->value.asSymbol ); @@ -291,6 +291,7 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ) /* NOTE: direct type change */ pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; pSelf->value.asOperator.pRight->ExprType = HB_ET_VARREF; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); switch( bOpEq ) @@ -314,7 +315,7 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ) } } } -#endif +#endif /* push old value */ HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); /* push increment value */ @@ -443,7 +444,7 @@ void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ) pSelf->value.asOperator.pLeft->ExprType = iOldType; return; } - else if( pSelf->value.asOperator.pRight->ExprType == HB_ET_VARIABLE ) + else if( iType == HB_ET_VARIABLE ) { int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pRight->value.asSymbol ); diff --git a/harbour/source/common/expropt1.c b/harbour/source/common/expropt1.c index 7b117ec2a7..7d1fecccab 100644 --- a/harbour/source/common/expropt1.c +++ b/harbour/source/common/expropt1.c @@ -391,6 +391,7 @@ HB_EXPR_PTR hb_compExprNewMacro( HB_EXPR_PTR pMacroExpr, { HB_EXPR_PTR pExpr; + pExpr = hb_compExprNew( HB_ET_MACRO, HB_COMP_PARAM ); if( szName ) { HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewMacro(%s)", szName)); @@ -407,7 +408,6 @@ HB_EXPR_PTR hb_compExprNewMacro( HB_EXPR_PTR pMacroExpr, * is pushed as: * "MY&VAR.1" */ - pExpr = hb_compExprNew( HB_ET_MACRO, HB_COMP_PARAM ); pExpr->value.asMacro.cMacroOp = cMacroOp; /* '&' if variable or 0 if text */ pExpr->value.asMacro.szMacro = szName; /* variable name or macro text */ pExpr->value.asMacro.pExprList = NULL; /* this is not a parenthesized expressions */ @@ -419,9 +419,9 @@ HB_EXPR_PTR hb_compExprNewMacro( HB_EXPR_PTR pMacroExpr, /* Macro expression: &( expression_list ) */ - pExpr = hb_compExprNew( HB_ET_MACRO, HB_COMP_PARAM ); - pExpr->value.asMacro.pExprList = pMacroExpr; + pExpr->value.asMacro.cMacroOp = 0; pExpr->value.asMacro.szMacro = NULL; /* this is used to distinguish &(...) from &ident */ + pExpr->value.asMacro.pExprList = pMacroExpr; pExpr->value.asMacro.SubType = HB_ET_MACRO_EXPR; } diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index fe31767b1a..72ba6aa00a 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -77,14 +77,29 @@ #include "hbset.h" #include "hb_io.h" +/* NOTE: Some C compilers like BCC32 optimize the call of small static buffers + * into an integer to read it faster. Later, programs like CodeGuard + * complain if the given buffer was smaller than an int. [ckedem] + */ + /* length of buffer for CR/LF characters */ -#define CRLF_BUFFER_LEN OS_EOL_LEN + 1 +#if !defined(OS_EOL_LEN) || OS_EOL_LEN < 4 +# define CRLF_BUFFER_LEN 4 +#else +# define CRLF_BUFFER_LEN OS_EOL_LEN + 1 +#endif + +#if defined(OS_UNIX_COMPATIBLE) && !defined(HB_EOL_CRLF) + static const char s_szCrLf[ CRLF_BUFFER_LEN ] = { HB_CHAR_LF, 0 }; + static const int s_iCrLfLen = 1; +#else + static const char s_szCrLf[ CRLF_BUFFER_LEN ] = { HB_CHAR_CR, HB_CHAR_LF, 0 }; + static const int s_iCrLfLen = 2; +#endif static BOOL s_bInit = FALSE; static USHORT s_uiPRow; static USHORT s_uiPCol; -static char s_szCrLf[ CRLF_BUFFER_LEN ] = { HB_CHAR_LF, 0 }; -static int s_iCrLfLen = 1; static FHANDLE s_hFilenoStdin = 0; static FHANDLE s_hFilenoStdout = 1; static FHANDLE s_hFilenoStderr = 2; @@ -117,17 +132,6 @@ void hb_conInit( void ) } #endif -#if defined(OS_UNIX_COMPATIBLE) && !defined(HB_EOL_CRLF) - s_szCrLf[ 0 ] = HB_CHAR_LF; - s_szCrLf[ 1 ] = '\0'; - s_iCrLfLen = 1; -#else - s_szCrLf[ 0 ] = HB_CHAR_CR; - s_szCrLf[ 1 ] = HB_CHAR_LF; - s_szCrLf[ 2 ] = '\0'; - s_iCrLfLen = 2; -#endif - /* * Some compilers open stdout and stderr in text mode, but * Harbour needs them to be open in binary mode. @@ -171,7 +175,7 @@ char * hb_conNewLine( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_conNewLine()")); - return s_szCrLf; + return ( char * ) s_szCrLf; } HB_FUNC( HB_OSNEWLINE )