*** empty log message ***

This commit is contained in:
Viktor Szakats
1999-07-30 13:10:41 +00:00
parent b3cbca9ba1
commit 6ff00ea612
14 changed files with 181 additions and 166 deletions

View File

@@ -1,3 +1,34 @@
19990730-14:55 CET Victor Szel <info@szelvesz.hu>
! source/hbpp/preproc.c - defines _pFileName.
! source/hbpp/hbppmain.c - Definition of pFileName
changed scope and name to _pFileName, so that
OpenInclude() can use it. (not tested)
! source/rtl/alert.prg -
Added left out original author info.
Added missing #includes.
! source/rtl/Makefile - Added alert.prg
! source/rdd/Makefile - Added new RDD stuff.
! source/hbpp/preproc.c/HB_PREPROCESS()
Fixed unterminated result string problem.
Fixed return value inconsistencies.
Fixed to not use internals.
Code cleanup.
+ include/hbdefs.h - Added MIN() and MAX() macros.
* source/hbpp/harb.h - Removed.
* source/hbpp/preproc.c renamed to hbpplib.c
source/hbpp/Makefile
(Please update other makefiles accordingly)
* include/hbpp.h
source/hbpp/hbpp.c
source/hbpp/hbppint.c
source/hbpp/hbpplib.c
source/hbpp/hbppmain.c
source/compiler/harbour.y
Common declarations moved to one place, hbpp.h
* source/hbpp/hbpp.c
isname() -> ISNAME()
* tests/working/testpre.prg - Small cleanup.
19990730-08:50 EDT Paul Tucker <ptucker@sympatico.ca>
* makefile.vc
* added dbfntx support (not nulsys yet)

View File

@@ -60,6 +60,13 @@ typedef int BOOL;
#undef PVOID
typedef void * PVOID;
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#define LOBYTE(w) ((BYTE)(w))
#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
#define LOWORD(l) ((WORD)(l))

View File

@@ -7,7 +7,22 @@
#ifndef HB_PP_H_
#define HB_PP_H_
/* ------------------------------------------ */
#include "hbsetup.h"
#include "hbdefs.h"
typedef struct _PATHNAMES { /* the list of pathnames to search with #include */
char *szPath;
struct _PATHNAMES *pNext;
} PATHNAMES;
typedef struct /* support for filenames */
{
char _buffer[ _POSIX_PATH_MAX+3 ];
char *path;
char *name;
char *extension;
} FILENAME;
struct _DEFINES;
typedef struct _DEFINES
{
@@ -26,4 +41,51 @@ typedef struct
char *value;
} COMMANDS, TRANSLATES;
#define STR_SIZE 8192
#define BUFF_SIZE 2048
#define INITIAL_ACOM_SIZE 200
#define SKIPTABSPACES(sptr) while ( *sptr == ' ' || *sptr == '\t' ) (sptr)++
#define PATH_DELIMITER "/\\"
#define IS_PATH_SEP( c ) (strchr(PATH_DELIMITER, (c))!=NULL)
#define OPT_DELIMITER "/-"
#define IS_OPT_SEP( c ) (strchr(OPT_DELIMITER, (c))!=NULL)
/* HBPP.C exported functions */
extern int ParseDirective( char* );
extern int ParseExpression( char*, char* );
extern int pp_RdStr(FILE*,char *,int,int,char*,int*,int*);
extern int pp_WrStr(FILE*,char *);
extern int strolen ( char* );
extern int strocpy (char*, char* );
extern char* strodup ( char * );
extern DEFINES *AddDefine( char * szDefine, char * szValue ); /* add a new Lex define from the command line */
/* HBPP.C exported variables */
extern int lInclude;
extern int *aCondCompile, nCondCompile;
extern int nline;
extern COMMANDS *aCommnew ;
extern TRANSLATES *aTranslates ;
/* Needed support modules, but not contained in HBPP.C */
extern FILENAME *SplitFilename( char * ); /* splits filename into a path, a name and an extension */
extern char *MakeFilename( char *, FILENAME *); /* joins a path, a name an an extension int filename */
extern void * OurMalloc( LONG lSize ); /* our malloc with error control */
extern void * _xgrab( ULONG ); /* allocates fixed memory */
extern void * _xrealloc( void *, ULONG ); /* reallocates memory */
extern void _xfree( void * ); /* frees fixed memory */
/* Needed support variables, but not contained in HBPP.C */
extern PATHNAMES *_pIncludePath;
extern FILENAME *_pFileName;
extern DEFINES *topDefine;
#endif /* HB_PP_H_ */

View File

@@ -81,11 +81,6 @@ typedef struct
int iFiles; /* number of files currently opened */
} FILES; /* structure to control several opened PRGs and CHs */
typedef struct _PATHNAMES { /* the list of pathnames to search with #include */
char *szPath;
struct _PATHNAMES *pNext;
} PATHNAMES;
int Include( char * szFileName, PATHNAMES *pSearchPath ); /* end #include support */
/*
@@ -125,14 +120,6 @@ static void LoopLoop( void );
static void LoopExit( void );
static void LoopHere( void );
typedef struct /* support for filenames */
{
char _buffer[ _POSIX_PATH_MAX+3 ];
char *path;
char *name;
char *extension;
} FILENAME;
typedef struct __EXTERN
{
char * szName;
@@ -152,7 +139,6 @@ extern "C" int yywrap( void );
#else
int yywrap( void ); /* manages the EOF of current processed file */
#endif
DEFINES *AddDefine( char * szDefine, char * szValue ); /* add a new Lex define from the command line */
/* Following line added for preprocessor */
void Hbpp_init ( void );

View File

@@ -7,7 +7,7 @@ ROOT = ../../
C_SOURCES=\
hbpp.c \
hbppint.c \
preproc.c \
hbpplib.c \
table.c \
LIB=hbpp

View File

@@ -1,37 +0,0 @@
/*
* $Id$
*/
#ifndef HB_HARB_H_
#define HB_HARB_H_
#include "hbsetup.h"
#include "hbdefs.h"
#include "hbpp.h" /* includes common definitions shared by preprocessor and harbour.y */
#define PATH_DELIMITER "/\\"
#define IS_PATH_SEP( c ) (strchr(PATH_DELIMITER, (c))!=NULL)
#define OPT_DELIMITER "/-"
#define IS_OPT_SEP( c ) (strchr(OPT_DELIMITER, (c))!=NULL)
typedef struct _PATHNAMES { /* the list of pathnames to search with #include */
char *szPath;
struct _PATHNAMES *pNext;
} PATHNAMES;
typedef struct /* support for filenames */
{
char _buffer[ _POSIX_PATH_MAX+3 ];
char *path;
char *name;
char *extension;
} FILENAME;
FILENAME *SplitFilename( char * ); /* splits filename into a path, a name and an extension */
char *MakeFilename( char *, FILENAME *); /* joins a path, a name an an extension int filename */
void * OurMalloc( LONG lSize ); /* our malloc with error control */
void * _xgrab( ULONG ); /* allocates fixed memory */
void * _xrealloc( void *, ULONG ); /* reallocates memory */
void _xfree( void * ); /* frees fixed memory */
#endif /* HB_HARB_H_ */

View File

@@ -45,7 +45,7 @@
#include <stdio.h>
#include <ctype.h>
#include "harb.h"
#include "hbpp.h"
#include "hberrors.h"
int Hp_Parse( FILE*, FILE* );
@@ -96,14 +96,9 @@ int NextParm ( char**, char* );
int Include( char *, PATHNAMES *, FILE** );
BOOL OpenInclude( char *, PATHNAMES *, FILE**, BOOL bStandardOnly );
#define isname(c) (isalnum(c) || (c)=='_' || (c) > 0x7e)
#define SKIPTABSPACES(sptr) while ( *sptr == ' ' || *sptr == '\t' ) (sptr)++
#define ISNAME(c) (isalnum(c) || (c)=='_' || (c) > 0x7e)
#define MAX_NAME 255
#define BUFF_SIZE 2048
#define STR_SIZE 8192
#define PATTERN_SIZE 2048
#define FALSE 0
#define TRUE 1
#define STATE_INIT 0
#define STATE_NORMAL 1
@@ -128,12 +123,6 @@ int nline=0;
int Repeate;
char groupchar;
extern PATHNAMES *_pIncludePath;
extern FILENAME *_pFileName;
extern DEFINES *topDefine;
#define INITIAL_ACOM_SIZE 200
extern COMMANDS aCommands[] ;
extern int kolcomm;
COMMANDS *aCommnew ;
@@ -355,7 +344,7 @@ int ComSearch(char *cmdname, int ncmd)
{
for ( j=0; (*(aCommnew[i].name+j)==toupper(*(cmdname+j))) &&
(*(aCommnew[i].name+j)!='\0') &&
((aCommnew[i].com_or_xcom)? 1:(j<4 || isname(*(cmdname+j+1)))); j++ );
((aCommnew[i].com_or_xcom)? 1:(j<4 || ISNAME(*(cmdname+j+1)))); j++ );
if ( (*(aCommnew[i].name+j)==toupper(*(cmdname+j))) ||
( !aCommnew[i].com_or_xcom && j >= 4 && *(aCommnew[i].name+j)!='\0') )
return kolcomm+i;
@@ -365,7 +354,7 @@ int ComSearch(char *cmdname, int ncmd)
{
for ( j=0; (*(aCommands[i].name+j)==toupper(*(cmdname+j))) &&
(*(aCommands[i].name+j)!='\0') &&
((aCommands[i].com_or_xcom)? 1:(j<4 || isname(*(cmdname+j+1)))); j++ );
((aCommands[i].com_or_xcom)? 1:(j<4 || ISNAME(*(cmdname+j+1)))); j++ );
if ( (*(aCommands[i].name+j)==toupper(*(cmdname+j))) ||
( !aCommands[i].com_or_xcom && j >= 4 && *(aCommands[i].name+j)!='\0'
&& *(cmdname+j) == '\0' ) )
@@ -382,7 +371,7 @@ int TraSearch(char *cmdname, int ncmd)
{
for ( j=0; *(aTranslates[i].name+j)==toupper(*(cmdname+j)) &&
*(aTranslates[i].name+j)!='\0' &&
((aTranslates[i].com_or_xcom)? 1:(j<4 || isname(*(cmdname+j+1)))); j++ );
((aTranslates[i].com_or_xcom)? 1:(j<4 || ISNAME(*(cmdname+j+1)))); j++ );
if ( *(aTranslates[i].name+j)==toupper(*(cmdname+j)) ||
( !aTranslates[i].com_or_xcom && j >= 4 &&
*(aTranslates[i].name+j)!='\0' && *(cmdname+j) == '\0' ) )
@@ -628,12 +617,12 @@ int ParseExpression( char* sLine, char* sOutLine )
if ( kolpass < 3 )
{
ptri = sLine + isdvig;
if ( isname(*ptri) )
if ( ISNAME(*ptri) )
NextName( &ptri, sToken, NULL);
else
{
i = 0;
while ( *ptri != ' ' && *ptri != '\t' && *ptri != '\0' && !isname(*ptri) )
while ( *ptri != ' ' && *ptri != '\t' && *ptri != '\0' && !ISNAME(*ptri) )
{
*(sToken+i) = *ptri++;
i++;
@@ -642,7 +631,7 @@ int ParseExpression( char* sLine, char* sOutLine )
}
SKIPTABSPACES( ptri );
if ( *ptri != ':' && *ptri != '=' && (isname(*ptri) || *(ptri+1) != '=')
if ( *ptri != ':' && *ptri != '=' && (ISNAME(*ptri) || *(ptri+1) != '=')
&& (ndef=ComSearch(sToken,0)) >= 0 )
{
ptro = sOutLine;
@@ -745,7 +734,7 @@ void WorkPseudoF ( char** ptri, char** ptro, DEFINES *stdef )
while ( (ifou = pp_strAt( parfict, lenfict, ptrb, lenres-(ptrb-*ptro) )) > 0 )
{
ptrb = ptrb+ifou-1;
if ( !isname(*(ptrb-1)) && !isname(*(ptrb+lenfict)) )
if ( !ISNAME(*(ptrb-1)) && !ISNAME(*(ptrb+lenfict)) )
{
pp_Stuff ( parreal, ptrb, lenreal, lenfict, lenres );
lenres += lenreal - lenfict;
@@ -1085,7 +1074,7 @@ int getExpReal ( char *expreal, char **ptri, int prlist, int maxrez )
break;
case STATE_ID:
case STATE_ID_END:
if ( ( (isname(**ptri) || **ptri=='\\') && State == STATE_ID_END ) ||
if ( ( (ISNAME(**ptri) || **ptri=='\\') && State == STATE_ID_END ) ||
**ptri==',' || **ptri=='\'' || **ptri=='\"')
{
if ( **ptri == ',' )
@@ -1120,7 +1109,7 @@ int getExpReal ( char *expreal, char **ptri, int prlist, int maxrez )
case STATE_EXPRES_ID:
if ( **ptri == '\'' ) State = STATE_QUOTE1;
else if ( **ptri == '\"' ) State = STATE_QUOTE2;
else if ( isname(**ptri) ) State = STATE_EXPRES_ID;
else if ( ISNAME(**ptri) ) State = STATE_EXPRES_ID;
else if ( **ptri == ' ' && State == STATE_EXPRES_ID ) State = STATE_ID_END;
else if ( **ptri == '(' ) { StBr1++; State = STATE_BRACKET; }
else if ( **ptri == '[' ) { StBr2++; State = STATE_BRACKET; }
@@ -1158,7 +1147,7 @@ void SkipOptional( char** ptri, char *ptro, int* lenres, int* pnbr)
char exppatt[MAX_NAME];
int lenpatt;
while ( isname(**ptri) ) (*ptri)++;
while ( ISNAME(**ptri) ) (*ptri)++;
SKIPTABSPACES( *ptri );
while ( **ptri != ']' || nbr )
{
@@ -1505,8 +1494,8 @@ int md_strAt(char *szSub, int lSubLen, char *szText, int checkPrth)
lSubPos++;
lPos++;
if ( lSubPos >= lSubLen &&
( ( isname(*szSub) && lPos>lSubPos && isname(*(szText+lPos-lSubPos-1)) ) ||
( isname(*(szSub+lSubLen-1)) && isname(*(szText+lPos)) ) ) )
( ( ISNAME(*szSub) && lPos>lSubPos && ISNAME(*(szText+lPos-lSubPos-1)) ) ||
( ISNAME(*(szSub+lSubLen-1)) && ISNAME(*(szText+lPos)) ) ) )
lSubPos = 0;
}
else if( lSubPos ) lSubPos = 0;
@@ -1626,7 +1615,7 @@ int strotrim ( char *stroka )
else if ( *stroka == '\"' ) State = STATE_QUOTE2;
}
/* if ( State != STATE_NORMAL || (*stroka != ' ' && *stroka != '\t') ||
( (isname(lastc) || lastc=='>') && (isname(*(stroka+1)) || *(stroka+1)=='<') ) )
( (ISNAME(lastc) || lastc=='>') && (ISNAME(*(stroka+1)) || *(stroka+1)=='<') ) )
*/
if ( State != STATE_NORMAL || (*stroka != ' ' && *stroka != '\t') ||
( *stroka==' ' && lastc != ' ' && lastc != ',' && lastc != '(' && *(stroka+1)!=',') )
@@ -1658,7 +1647,7 @@ int NextWord ( char** sSource, char* sDest, int lLower )
int NextName ( char** sSource, char* sDest, char **sOut )
{
int lenName = 0, State = STATE_NORMAL;
while ( **sSource != '\0' && ( !isname(**sSource) || State != STATE_NORMAL ) )
while ( **sSource != '\0' && ( !ISNAME(**sSource) || State != STATE_NORMAL ) )
{
if ( State == STATE_QUOTE1 )
{ if ( **sSource == '\'' ) State = STATE_NORMAL; }
@@ -1671,7 +1660,7 @@ int NextName ( char** sSource, char* sDest, char **sOut )
(*sSource)++;
}
while ( **sSource != '\0' && isname(**sSource) )
while ( **sSource != '\0' && ISNAME(**sSource) )
{
if ( sOut !=NULL ) *(*sOut)++ = **sSource;
*sDest++ = *(*sSource)++;

View File

@@ -45,32 +45,12 @@
#endif
#endif
#include <stdio.h>
#include "harb.h"
extern int ParseDirective( char* );
extern int ParseExpression( char*, char* );
extern int pp_RdStr(FILE*,char *,int,int,char*,int*,int*);
extern int pp_WrStr(FILE*,char *);
extern int strolen ( char* );
extern int strocpy (char*, char* );
#include "hbpp.h"
void Hbpp_init ( void );
int PreProcess( FILE*, FILE*, char *);
int Hp_Parse( FILE*, FILE* );
#define SKIPTABSPACES(sptr) while ( *sptr == ' ' || *sptr == '\t' ) (sptr)++
extern int lInclude;
extern int *aCondCompile, nCondCompile;
extern int nline;
#define BUFF_SIZE 2048
#define STR_SIZE 8192
#define INITIAL_ACOM_SIZE 200
extern COMMANDS *aCommnew ;
extern TRANSLATES *aTranslates ;
int iBuffer, lenBuffer;
int lPpo = 0;
char sLine[STR_SIZE], sOutLine[STR_SIZE];

View File

@@ -35,18 +35,14 @@
*/
#include <ctype.h>
#include "hbsetup.h"
#include <stdio.h>
#include "hbpp.h"
#include "extend.h"
#include "itemapi.h"
#include "init.h"
#include "harb.h"
#define SKIPTABSPACES(sptr) while ( *sptr == ' ' || *sptr == '\t' ) (sptr)++
#define STR_SIZE 8192
extern int ParseExpression( char*, char* );
PATHNAMES *_pIncludePath = NULL;
FILENAME *_pFileName = NULL;
HARBOUR HB_PREPROCESS(void);
@@ -61,29 +57,31 @@ HB_INIT_SYMBOLS_END( Preprocess__InitSymbols );
and external include files */
HARBOUR HB_PREPROCESS(void)
{
if (ISCHAR(1))
{
char *pText = hb_xgrab(STR_SIZE);
char *pOut = hb_xgrab(STR_SIZE);
char *ptr = pText;
int resParse;
if( hb_pcount() == 1 )
memcpy(pText, hb_parc(1), MIN(hb_parclen(1), STR_SIZE));
memset(pOut, 0, STR_SIZE);
SKIPTABSPACES( ptr );
if ( (resParse = ParseExpression( ptr, pOut )) > 0 )
{
PHB_ITEM pItem = hb_param( 1, IT_STRING );
extern int strolen( char* );
char szText[STR_SIZE];
char szOut[STR_SIZE];
memcpy(szText, pItem->item.asString.value, strolen(pItem->item.asString.value)+1);
if(pItem)
{
char *ptr = szText;
SKIPTABSPACES( ptr );
if ( (resParse = ParseExpression( ptr, szOut )) > 0 )
{
// Some error here?
}
}
hb_retc( szOut );
// Some error here?
}
hb_retc(pOut);
hb_xfree(pText);
hb_xfree(pOut);
}
else
hb_retc("");
}
void GenError( char* _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 )

View File

@@ -34,41 +34,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "harb.h"
#include "hbpp.h"
int Hp_Parse( FILE*, FILE* );
extern int ParseDirective( char* );
extern int ParseExpression( char*, char* );
extern int pp_RdStr(FILE*,char *,int,int,char*,int*,int*);
extern int pp_WrStr(FILE*,char *);
extern DEFINES* AddDefine ( char*, char* );
extern int strolen ( char* );
extern char* strodup ( char * );
void AddSearchPath( char *, PATHNAMES * * ); /* add pathname to a search list */
#define SKIPTABSPACES(sptr) while ( *sptr == ' ' || *sptr == '\t' ) (sptr)++
extern int lInclude;
extern int *aCondCompile, nCondCompile;
extern int nline;
#define BUFF_SIZE 2048
#define STR_SIZE 8192
#define INITIAL_ACOM_SIZE 200
extern COMMANDS *aCommnew ;
extern TRANSLATES *aTranslates ;
char sLine[STR_SIZE], sOutLine[STR_SIZE];
PATHNAMES *_pIncludePath = NULL;
void AddSearchPath( char *, PATHNAMES * * ); /* add pathname to a search list */
FILENAME *_pFileName = NULL;
int main (int argc,char* argv[])
{
FILE *handl_i,*handl_o;
char szFileName[ _POSIX_PATH_MAX ];
char * szDefText;
FILENAME *pFileName =NULL;
int iArg = 1, i;
FILE *handl_i,*handl_o;
char szFileName[ _POSIX_PATH_MAX ];
char * szDefText;
int iArg = 1, i;
while( iArg < argc )
{
@@ -102,21 +83,21 @@ int iArg = 1, i;
break;
}
}
else pFileName =SplitFilename( argv[ iArg ] );
else _pFileName =SplitFilename( argv[ iArg ] );
iArg++;
}
if( pFileName )
if( _pFileName )
{
if( !pFileName->extension ) pFileName->extension =".prg";
MakeFilename( szFileName, pFileName );
if( !_pFileName->extension ) _pFileName->extension =".prg";
MakeFilename( szFileName, _pFileName );
if ((handl_i = fopen(szFileName, "r")) == NULL)
{ printf("\nCan't open %s\n",szFileName); return 1; }
}
else { printf("\nFile name absent\n"); return 1; }
pFileName->extension =".ppo";
MakeFilename( szFileName, pFileName );
_pFileName->extension =".ppo";
MakeFilename( szFileName, _pFileName );
if ((handl_o = fopen(szFileName, "wt" )) == NULL)
{ printf("\nCan't open %s\n",szFileName); return 1; }
@@ -398,4 +379,4 @@ void GenError( char* _szErrors[], char cPrefix, int iError, char * szError1, cha
sprintf( szLine, _szErrors[ iError - 1 ], szError1, szError2 );
printf( "%s\n\n", szLine );
exit( 1 );
}
}

View File

@@ -7,9 +7,13 @@ ROOT = ../../
C_SOURCES=\
dbcmd.c \
dbf1.c \
sdf1.c \
delim1.c \
PRG_SOURCES=\
dbf0.prg \
sdf0.prg \
delim0.prg \
rddsys.prg \
LIB=rdd

View File

@@ -33,6 +33,7 @@ C_SOURCES=\
msgxxx.c \
PRG_SOURCES=\
alert.prg \
asort.prg \
devoutp.prg \
error.prg \

View File

@@ -1,4 +1,18 @@
Func Alert(cMessage, aOptions, nDelay)
/* $Id$
Harbour Project source code
www - http://www.Harbour-Project.org
Written by Vladimir Kazimirchik <v_kazimirchik@yahoo.com>
http://i.am/kzm
Released into public domain.
*/
#include "box.ch"
#include "inkey.ch"
Function Alert(cMessage, aOptions, nDelay)
Local nRet := 0
Local aSay, nPos, nWidth, nOpWidth, nInitRow, nInitCol, iEval, nChoice

View File

@@ -1,6 +1,6 @@
FUNCTION Main()
LOCAL cString := "@ 10, 10 SAY 'Hello!'"
LOCAL cString
LOCAL i, j, aScript
CLS
@@ -9,10 +9,9 @@ FUNCTION Main()
qOut( "======================================" )
qOut( "" )
cString := "@ 10, 10 SAY 'Hello!'"
qOut( cString )
cString := Preprocess( cString )
qOut( cString )
qOut( Preprocess( cString ) )
qOut( "" )
cString := "? 'Hello mom'"