2004-04-02 13:15 UTC+0100 Ryszard Glab <rglab@imid.med.pl>

* include/hbexpra.c
   * include/hbexprop.h
   * source/common/expropt1.c
   * source/compiler/expropta.c
   * source/macro/macro.y
   * source/macro/macroa.c
   * source/vm/macro.c
      * fixed to release memory in cases where invalid
      syntax was macro compiled

   * source/vm/itemapi.c
      * fixed to correctly check for infinity on Unix
      STR(LOG(-1)) no longer core dumps

   * source/rtl/filesys.c
   * source/rdd/hbdbsort.c
      * fixed to suppres warnings

   * source/pp/ppcore.c
   * utils/hbtest/rt_misc.prg
      * Clipper preproceses '**' into '^' - harbour too
This commit is contained in:
Ryszard Glab
2004-04-02 11:14:37 +00:00
parent 531456f903
commit b79d50c582
13 changed files with 159 additions and 51 deletions

View File

@@ -8,12 +8,35 @@
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2004-03-02 12:17 UTC+0100 Antonio Linares <alinares@fivetechsoft.com>
2004-04-02 13:15 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
* include/hbexpra.c
* include/hbexprop.h
* source/common/expropt1.c
* source/compiler/expropta.c
* source/macro/macro.y
* source/macro/macroa.c
* source/vm/macro.c
* fixed to release memory in cases where invalid
syntax was macro compiled
* source/vm/itemapi.c
* fixed to correctly check for infinity on Unix
STR(LOG(-1)) no longer core dumps
* source/rtl/filesys.c
* source/rdd/hbdbsort.c
* fixed to suppres warnings
* source/pp/ppcore.c
* utils/hbtest/rt_misc.prg
* Clipper preproceses '**' into '^' - harbour too
2004-04-02 12:17 UTC+0100 Antonio Linares <alinares@fivetechsoft.com>
* source/rtl/fstemp.c
* source/rdd/dbfntx/dbfntx1.c
- Two linux linking time warnings removed
2004-03-01 11:15 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
2004-04-01 11:15 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
* include/hbexprb.c
* include/hbmacro.ch
* fixed support for strings as array of bytes

View File

@@ -133,6 +133,46 @@ static HB_CBVAR_PTR hb_compExprCBVarNew( char *, BYTE );
/* ************************************************************************ */
HB_EXPR_PTR hb_compExprNew( int iType )
{
HB_EXPR_PTR pExpr;
HB_TRACE(HB_TR_DEBUG, ("hb_compExprNew(%i)", iType));
#if defined( HB_MACRO_SUPPORT )
pExpr = hb_macroExprNew();
#else
pExpr = ( HB_EXPR_PTR ) HB_XGRAB( sizeof( HB_EXPR ) );
#endif
pExpr->ExprType = iType;
pExpr->pNext = NULL;
pExpr->ValType = HB_EV_UNKNOWN;
pExpr->Counter = 1;
return pExpr;
}
/* Delete self - all components will be deleted somewhere else
*/
void hb_compExprClear( HB_EXPR_PTR pExpr )
{
#if defined( HB_MACRO_SUPPORT )
HB_SYMBOL_UNUSED( pExpr );
#else
if( --pExpr->Counter == 0 )
HB_XFREE( pExpr );
#endif
}
#if defined( HB_MACRO_SUPPORT )
void hb_compExprKill( HB_EXPR_PTR pExpr, HB_MACRO_DECL )
{
HB_TRACE(HB_TR_DEBUG, ("hb_compExprKill()"));
if( pExpr->ExprType != HB_ET_NONE )
HB_EXPR_USE( pExpr, HB_EA_DELETE );
}
#endif
/* Delete all components and delete self
*/
#if defined( HB_MACRO_SUPPORT )
@@ -145,7 +185,11 @@ void hb_compExprDelete( HB_EXPR_PTR pExpr )
if( --pExpr->Counter == 0 )
{
HB_EXPR_USE( pExpr, HB_EA_DELETE );
#if defined( HB_MACRO_SUPPORT )
pExpr->ExprType = HB_ET_NONE;
#else
HB_XFREE( pExpr );
#endif
}
}
@@ -157,7 +201,11 @@ void hb_compExprFree( HB_EXPR_PTR pExpr, HB_MACRO_DECL )
if( --pExpr->Counter == 0 )
{
HB_EXPR_USE( pExpr, HB_EA_DELETE );
#if defined( HB_MACRO_SUPPORT )
pExpr->ExprType = HB_ET_NONE;
#else
HB_XFREE( pExpr );
#endif
}
HB_SYMBOL_UNUSED( HB_MACRO_VARNAME );
}

View File

@@ -274,6 +274,7 @@ typedef HB_EXPR_PTR HB_EXPR_ACTION( HB_EXPR_PTR pSelf, int iMessage, void * pMa
#define HB_MACRO_VARNAME pMacro
extern HB_EXPR_PTR hb_macroExprNew( void );
#else
#define HB_EXPR_FUNC( proc ) HB_EXPR_PTR proc( HB_EXPR_PTR pSelf, int iMessage )
@@ -388,6 +389,7 @@ BOOL hb_compExprIsValidMacro( char *, BOOL *, HB_MACRO_DECL );
#ifdef HB_MACRO_SUPPORT
void hb_compExprKill( HB_EXPR_PTR, HB_MACRO_DECL );
HB_EXPR_PTR hb_compExprNewArrayAt( HB_EXPR_PTR, HB_EXPR_PTR, HB_MACRO_DECL );
HB_EXPR_PTR hb_compExprSetOperand( HB_EXPR_PTR, HB_EXPR_PTR, HB_MACRO_DECL );
HB_EXPR_PTR hb_compExprGenPop( HB_EXPR_PTR, HB_MACRO_DECL );

View File

@@ -130,30 +130,6 @@ static char * s_OperTable[] = {
/* ************************************************************************* */
HB_EXPR_PTR hb_compExprNew( int iType )
{
HB_EXPR_PTR pExpr;
HB_TRACE(HB_TR_DEBUG, ("hb_compExprNew(%i)", iType));
pExpr = ( HB_EXPR_PTR ) HB_XGRAB( sizeof( HB_EXPR ) );
pExpr->ExprType = iType;
pExpr->pNext = NULL;
pExpr->ValType = HB_EV_UNKNOWN;
pExpr->Counter = 1;
return pExpr;
}
/* Delete self - all components will be deleted somewhere else
*/
void hb_compExprClear( HB_EXPR_PTR pExpr )
{
if( --pExpr->Counter == 0 )
HB_XFREE( pExpr );
}
/* Increase a reference counter (this allows to share the same expression
* in more then one context)
*/

View File

@@ -5,6 +5,6 @@
/* hbexpra.c is also included from ../macro/macro.c
* However it produces a slighty different code if used in
* macro compiler (there is an additional parameter passed to some functions)
* 1.10 - ignore this magic number - this is used to force compilation
* 1.11 - ignore this magic number - this is used to force compilation
*/
#include "hbexpra.c"

View File

@@ -109,7 +109,6 @@ extern void yyerror( char * ); /* parsing error management function */
#define HB_MACRO_CHECK( pExpr ) \
if( ! ( HB_MACRO_DATA->status & HB_MACRO_CONT ) ) \
{ \
hb_compExprDelete( pExpr, HB_MACRO_PARAM ); \
YYABORT; \
}
@@ -118,7 +117,6 @@ extern void yyerror( char * ); /* parsing error management function */
{ pSet = (pExpr); }\
else \
{ \
hb_compExprDelete( (pExpr), HB_MACRO_PARAM ); \
YYABORT; \
}
@@ -227,38 +225,37 @@ int yylex( YYSTYPE *, HB_MACRO_PTR );
Main : Expression '\n' {
HB_MACRO_DATA->exprType = hb_compExprType( $1 );
if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_PUSH )
hb_compExprDelete( hb_compExprGenPush( $1, HB_MACRO_PARAM ), HB_MACRO_PARAM );
hb_compExprGenPush( $1, HB_MACRO_PARAM );
else
hb_compExprDelete( hb_compExprGenPop( $1, HB_MACRO_PARAM ), HB_MACRO_PARAM );
hb_compExprGenPop( $1, HB_MACRO_PARAM );
hb_compGenPCode1( HB_P_ENDPROC, HB_MACRO_PARAM );
}
| Expression {
HB_MACRO_DATA->exprType = hb_compExprType( $1 );
if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_PUSH )
hb_compExprDelete( hb_compExprGenPush( $1, HB_MACRO_PARAM ), HB_MACRO_PARAM );
hb_compExprGenPush( $1, HB_MACRO_PARAM );
else
hb_compExprDelete( hb_compExprGenPop( $1, HB_MACRO_PARAM ), HB_MACRO_PARAM );
hb_compExprGenPop( $1, HB_MACRO_PARAM );
hb_compGenPCode1( HB_P_ENDPROC, HB_MACRO_PARAM );
}
| AsParamList {
HB_MACRO_DATA->exprType = hb_compExprType( $1 );
if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_PUSH )
hb_compExprDelete( hb_compExprGenPush( $1, HB_MACRO_PARAM ), HB_MACRO_PARAM );
hb_compExprGenPush( $1, HB_MACRO_PARAM );
else
hb_compExprDelete( hb_compExprGenPop( $1, HB_MACRO_PARAM ), HB_MACRO_PARAM );
hb_compExprGenPop( $1, HB_MACRO_PARAM );
hb_compGenPCode1( HB_P_ENDPROC, HB_MACRO_PARAM );
}
| Expression error {
HB_TRACE(HB_TR_DEBUG, ("macro -> invalid expression: %s", HB_MACRO_DATA->string));
hb_macroError( EG_SYNTAX, HB_MACRO_PARAM );
hb_compExprDelete( $1, HB_MACRO_PARAM );
YYABORT;
YYABORT;
}
| error {
HB_TRACE(HB_TR_DEBUG, ("macro -> invalid syntax: %s", HB_MACRO_DATA->string));
hb_macroError( EG_SYNTAX, HB_MACRO_PARAM );
YYABORT;
YYABORT;
}
;
@@ -356,11 +353,11 @@ FieldAlias : FIELD ALIASOP { $$ = hb_compExprNewAlias( hb_strdup(
/* ignore _FIELD-> or FIELD-> if a real alias is specified
*/
FieldVarAlias : FieldAlias VarAlias { hb_compExprDelete( $1, HB_MACRO_PARAM ); $$ = $2; }
| FieldAlias NumAlias { hb_compExprDelete( $1, HB_MACRO_PARAM ); $$ = $2; }
| FieldAlias PareExpListAlias { hb_compExprDelete( $1, HB_MACRO_PARAM ); $$ = $2; }
| FieldAlias MacroVarAlias { hb_compExprDelete( $1, HB_MACRO_PARAM ); $$ = $2; }
| FieldAlias MacroExprAlias { hb_compExprDelete( $1, HB_MACRO_PARAM ); $$ = $2; }
FieldVarAlias : FieldAlias VarAlias { $$ = $2; }
| FieldAlias NumAlias { $$ = $2; }
| FieldAlias PareExpListAlias { $$ = $2; }
| FieldAlias MacroVarAlias { $$ = $2; }
| FieldAlias MacroExprAlias { $$ = $2; }
;
AliasId : IDENTIFIER { $$ = hb_compExprNewVar( $1 ); }
@@ -494,7 +491,6 @@ RootParamList : EmptyExpression ',' {
{
HB_TRACE(HB_TR_DEBUG, ("macro -> invalid expression: %s", HB_MACRO_DATA->string));
hb_macroError( EG_SYNTAX, HB_MACRO_PARAM );
hb_compExprDelete( $1, HB_MACRO_PARAM );
YYABORT;
}
}

View File

@@ -5,7 +5,7 @@
/* hbexpra.c is also included from ../compiler/expropta.c
* However it produces a slighty different code if used in
* macro compiler (there is an additional parameter passed to some functions)
* 1.10 - ignore this magic number - this is used to force compilation
* 1.11 - ignore this magic number - this is used to force compilation
*/
#define HB_MACRO_SUPPORT

View File

@@ -2355,6 +2355,19 @@ static int getExpReal( char * expreal, char ** ptri, BOOL prlist, int maxrez, BO
continue;
/* END - Ron Pinkas added 2000-05-03 */
}
else if( **ptri=='*' && *(*ptri+1) == '*' )
{
/* Clipper replaces ** with ^ operator */
if( expreal != NULL )
{
*expreal++ = '^';
}
(*ptri) +=2;
lens++;
cLastChar = '^';
State = STATE_EXPRES;
continue;
}
else
/* Ron Pinkas end 2000-06-02 */
State = STATE_EXPRES;

View File

@@ -50,6 +50,7 @@
*
*/
#define HB_EXTERNAL_RDDDBF_USE
#include "hbdbsort.h"
BOOL hb_dbQSortInit( LPDBQUICKSORT pQuickSort, LPDBSORTINFO pSortInfo, USHORT uiRecordLen )

View File

@@ -2021,8 +2021,7 @@ BYTE HB_EXPORT * hb_fileNameConv(char *str) {
char *filename;
char *dirname=str;
size_t dirlen;
char * szFileTrim =str;
ULONG ulPos;
/* char * szFileTrim =str; */
// Look for filename (Last "\" or DIRSEPARATOR)
if( hb_set.HB_SET_DIRSEPARATOR != '\\' ) {

View File

@@ -1139,7 +1139,7 @@ BOOL hb_itemStrBuf( char *szResult, PHB_ITEM pNumber, int iSize, int iDec )
hb_mathSetHandler (fOldMathHandler);
s_bInfinityInit = TRUE;
}
#elif defined(_MSC_VER) || defined(__DJGPP__) || defined(__MINGW32__) || defined(__RSXNT__) || defined(__EMX__) || (__BORLANDC__ > 1040) /* Use this only above Borland C++ 3.1 */
#elif defined(_MSC_VER) || defined(__DJGPP__) || defined(__GNUC__)|| defined(__MINGW32__) || defined(__RSXNT__) || defined(__EMX__) || (__BORLANDC__ > 1040) /* Use this only above Borland C++ 3.1 */
/* Nothing to do here, because these platforms have a function
that returns 0 if the value is not a finite number */
#else
@@ -1169,7 +1169,7 @@ BOOL hb_itemStrBuf( char *szResult, PHB_ITEM pNumber, int iSize, int iDec )
|| !_finite( dNumber )
#elif defined(_MSC_VER) || (__BORLANDC__ > 1040) /* Use this only above Borland C++ 3.1 */
|| !_finite(dNumber)
#elif defined(__DJGPP__) || defined(__MINGW32__)
#elif defined(__DJGPP__) || defined(__MINGW32__) || defined(__GNUC__)
|| !finite( dNumber )
#elif defined(__RSXNT__) || defined(__EMX__)
|| !isfinite( dNumber )

View File

@@ -68,14 +68,43 @@
*/
BOOL hb_comp_bShortCuts = TRUE;
typedef struct HB_MEXPR_ {
HB_EXPR Expression;
struct HB_MEXPR_ *pPrev;
} HB_MEXPR, *HB_MEXPR_PTR;
/* various flags for macro compiler */
static ULONG s_macroFlags = HB_SM_SHORTCUTS;
static HB_MEXPR_PTR s_macroAlloc = NULL;
static void hb_macroUseAliased( HB_ITEM_PTR, HB_ITEM_PTR, int, BYTE );
static void hb_compMemvarCheck( char * szVarName, HB_MACRO_DECL );
/* ************************************************************************* */
/* Allocates memory for Expression holder structure and stores it
* on the linked list
*/
HB_EXPR_PTR hb_macroExprNew()
{
HB_MEXPR_PTR pMExpr;
pMExpr = (HB_MEXPR_PTR) hb_xgrab( sizeof( HB_MEXPR ) );
if( s_macroAlloc == NULL )
{
s_macroAlloc = pMExpr;
pMExpr->pPrev = NULL;
}
else
{
pMExpr->pPrev = s_macroAlloc;
s_macroAlloc = pMExpr;
}
return &s_macroAlloc->Expression;
}
/* ************************************************************************* */
/* Compile passed string into a pcode buffer
*
* 'pMacro' - pointer to HB_MACRO structure that will hold all information
@@ -86,6 +115,9 @@ static void hb_compMemvarCheck( char * szVarName, HB_MACRO_DECL );
*/
static int hb_macroParse( HB_MACRO_PTR pMacro, char * szString )
{
int iResult;
HB_MEXPR_PTR pMacroExprList;
/* update the current status for logical shortcuts */
hb_comp_bShortCuts = pMacro->supported & HB_SM_SHORTCUTS;
@@ -112,7 +144,25 @@ static int hb_macroParse( HB_MACRO_PTR pMacro, char * szString )
*/
pMacro->exprType = HB_ET_NONE;
return hb_macroYYParse( pMacro );
/* Deallocate all memory used by expression optimizer */
pMacroExprList = s_macroAlloc; /* save current list for recurse entry */
s_macroAlloc = NULL;
iResult = hb_macroYYParse( pMacro );
if( s_macroAlloc )
{
HB_MEXPR_PTR pMExpr;
do
{
hb_compExprKill( &s_macroAlloc->Expression, pMacro );
pMExpr = s_macroAlloc->pPrev;
hb_xfree( s_macroAlloc );
s_macroAlloc = pMExpr;
}
while( s_macroAlloc );
}
s_macroAlloc = pMacroExprList;
return iResult;
}
/* releases all memory allocated for macro evaluation

View File

@@ -767,7 +767,7 @@ STATIC FUNCTION HB_TString()
oClass:AddInline( "/" , {| self, nVal | Left( ::cValue, Len( ::cValue ) / nVal ) } )
oClass:AddInline( "%" , {| self, cTest | ::cValue + " % " + cTest } )
oClass:AddInline( "^" , {| self, cTest | ::cValue + " ^ " + cTest } )
oClass:AddInline( "**" , {| self, cTest | ::cValue + " ** " + cTest } )
oClass:AddInline( "**" , {| self, cTest | ::cValue + " ^ " + cTest } )
oClass:AddInline( "!" , {| self | Descend( ::cValue ) } )
oClass:AddInline( ".NOT.", {| self | Descend( ::cValue ) } )
oClass:AddInline( ".AND.", {| self, cTest | ::cValue + " AND " + cTest } )