2001-06-07 10:15 GMT+3 Alexander Kresin <alex@belacy.belgorod.su>

This commit is contained in:
Alexander S.Kresin
2001-06-07 06:18:10 +00:00
parent 79c73dc499
commit 63d7b791a4
6 changed files with 93 additions and 5 deletions

View File

@@ -1,3 +1,20 @@
2001-06-07 10:15 GMT+3 Alexander Kresin <alex@belacy.belgorod.su>
* include/hbpp.h
* source/pp/ppcore.c
+ hb_pp_Free() added ( separated from hb_pp_Init() )
* source/pp/pplib.c
+ __PP_INIT() added
+ __PP_FREE() added
+ __PPADDRULE() added
* __PPADDRULE( cString ) can be called to preprocess a directive
( #include, #command, etc. )
__PP_FREE() should be called if __PPADDRULE() or __PP_INIT() was used
to free memory, allocated for pp tables.
* tests/testpre.prg
* modified to demonstrate __ppAddRule() and __pp_Free() using
* source/rdd/dbfntx/dbfntx1.c
* bug fixed in ntxOrderListAdd()
2001-06-06 16:00 UTC-0400 David G. Holm <dholm@jsd-llc.com>
* contrib/libct/charmix.c

View File

@@ -103,6 +103,8 @@ typedef HB_INCLUDE_FUNC * HB_INCLUDE_FUNC_PTR;
extern void hb_pp_SetRules( HB_INCLUDE_FUNC_PTR hb_compInclude, BOOL hb_comp_bQuiet );
extern int hb_pp_ReadRules( void );
extern void hb_pp_Init( void );
extern void hb_pp_Free( void );
extern void CloseInclude( void );
extern int hb_pp_ParseDirective( char * ); /* Parsing preprocessor directives ( #... ) */
extern int hb_pp_ParseExpression( char *, char * ); /* Parsing a line ( without preprocessor directive ) */
extern int hb_pp_WrStr( FILE *, char * );

View File

@@ -131,7 +131,6 @@ static int NextWord( char **, char *, BOOL );
static int NextName( char **, char * );
static int NextParm( char **, char * );
static BOOL OpenInclude( char *, PATHNAMES *, PHB_FNAME, BOOL bStandardOnly, char * );
void CloseInclude( void );
#define ISNAME( c ) ( isalnum( ( int ) c ) || ( c ) == '_' || ( c ) > 0x7E )
#define MAX_NAME 255
@@ -335,12 +334,12 @@ void hb_pp_SetRules( HB_INCLUDE_FUNC_PTR hb_compInclude, BOOL hb_comp_bQuiet )
}
}
void hb_pp_Init( void )
void hb_pp_Free( void )
{
DEFINES * stdef;
COMMANDS * stcmd;
HB_TRACE(HB_TR_DEBUG, ("hb_pp_Init()"));
HB_TRACE(HB_TR_DEBUG, ("hb_pp_Free()"));
while( s_kolAddDefs )
{
@@ -372,6 +371,13 @@ void hb_pp_Init( void )
hb_xfree( stcmd );
s_kolAddTras--;
}
}
void hb_pp_Init( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_pp_Init()"));
hb_pp_Free();
s_ParseState = 0;
s_maxCondCompile = 5;
@@ -3766,6 +3772,7 @@ static BOOL OpenInclude( char * szFileName, PATHNAMES * pSearch, PHB_FNAME pMain
return FALSE;
}
void CloseInclude( void )
{
PFILE pFile;

View File

@@ -100,6 +100,53 @@ static jmp_buf s_env;
/* TODO: This function should return an error code. The preprocessed sting
* should be returned by a reference.
*/
HB_FUNC( __PP_INIT )
{
hb_pp_Table();
hb_pp_Init();
hb_comp_files.iFiles = 0;
}
HB_FUNC( __PP_FREE )
{
hb_pp_Free();
if( hb_pp_aCondCompile )
hb_xfree( hb_pp_aCondCompile );
}
HB_FUNC( __PPADDRULE )
{
if( ISCHAR( 1 ) )
{
char * ptr = hb_parc( 1 );
char * hb_buffer;
HB_SKIPTABSPACES( ptr );
if( *ptr == '#' )
{
if( !hb_pp_aCondCompile )
{
hb_pp_Table();
hb_pp_Init();
hb_comp_files.iFiles = 0;
}
hb_pp_ParseDirective( ptr + 1 );
if( hb_comp_files.pLast )
{
hb_buffer = ( char* ) hb_xgrab( HB_PP_STR_SIZE );
while( hb_pp_Internal( NULL,hb_buffer ) > 0 );
CloseInclude();
hb_xfree( hb_buffer );
}
hb_retl( 1 );
}
else
hb_retl( 0 );
}
else
hb_retl( 0 );
}
HB_FUNC( __PREPROCESS )
{
if( ISCHAR( 1 ) )

View File

@@ -2620,6 +2620,9 @@ static ERRCODE ntxOrderListAdd( NTXAREAP pArea, LPDBORDERINFO pOrderInfo )
HB_TRACE(HB_TR_DEBUG, ("ntxOrderListAdd(%p, %p)", pArea, pOrderInfo));
if( SELF_GOCOLD( ( AREAP ) pArea ) == FAILURE )
return FAILURE;
szFileName = ( char * ) hb_xgrab( _POSIX_PATH_MAX + 3 );
szFileName[ 0 ] = '\0';
strcpy( szFileName, hb_itemGetCPtr( pOrderInfo->atomBagName ) );

View File

@@ -33,12 +33,20 @@ FUNCTION Main()
qOut( __Preprocess( cString ) )
qOut( "" )
cString := 'CLOSE ALL'
cString := "#xcommand DEFAULT <v1> := <x1> => IF <v1> == NIL ; <v1> := <x1> ; END"
qOut( cString )
IF __ppAddRule( cString )
qOut( "Rule added successfully !" )
ELSE
qOut( "Rule addition failed ..." )
ENDIF
cString := 'DEFAULT x := 100'
qOut( cString )
qOut( __Preprocess( cString ) )
qOut( "" )
qOut( chr(13)+chr(10)+"Press <Enter>..." )
qOut( "Press <Enter>..." )
__Accept( "" )
CLS
@@ -69,3 +77,7 @@ FUNCTION Main()
NEXT
RETURN( NIL )
Exit PROCEDURE ExitTest
__PP_Free()
Return