2017-09-08 16:00 UTC Viktor Szakats (vszakats users.noreply.github.com)
* *
* partial sync with the 3.4 fork codebase. These are the things
synces for the most part:
- copyright headers
- grammar/typos in comments and some readmes
- comment/whitespace/decorations
- variable scoping in C files
- DO CASE/SWITCH and some other alternate syntax usage
- minimal amount of human readable text in strings
- minor code updates
- HB_TRACE() void * casts for pointers and few other changes to
avoid C compiler warnings
- various other, minor code cleanups
- only Harbour/C code/headers were touched in src, utils, contrib,
include. No 3rd party code, no make files, and with just a few
exceptions, no 'tests' code was touched.
- certain components were not touched were 3.4 diverged too much
already, like f.e. hbmk2, hbssl, hbcurl, hbexpat
- the goal was that no actual program logic should be altered by
these changes. Except some possible minor exceptions, any such
change is probably a bug in this patch.
It's a massive patch, if you find anything broken after it, please
open an Issue with the details. Build test was done on macOS.
The goal is make it easier to see what actual code/logic was changed
in 3.4 compared to 3.2 and to make patches easier to apply in both
ways.
This commit is contained in:
@@ -44,4 +44,4 @@ directories, much like shell's \fB\s-1PATH\s0\fR. It's used by
|
||||
\fBhbpp\fR as default search paths for included files.
|
||||
|
||||
.SH AUTHOR
|
||||
Przemyslaw Czerpak, The Harbour Project (http://harbour-project.org)
|
||||
Przemyslaw Czerpak, The Harbour Project
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* preprocessor static rules generator.
|
||||
* It creates .c file with tables for defines/[x]translates/[x]commands
|
||||
* found in given .ch or .prg file
|
||||
* Preprocessor static rules generator.
|
||||
* It creates .c file with tables for defines/[x]translates/[x]commands
|
||||
* found in given .ch or .prg file
|
||||
*
|
||||
* Copyright 2006 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
*
|
||||
@@ -193,8 +193,8 @@ static void hb_pp_generateRules( FILE * fout, PHB_PP_STATE pState, const char *
|
||||
{
|
||||
int iDefs = 0, iTrans = 0, iCmds = 0;
|
||||
|
||||
fprintf( fout, "/*\n * $" "Id" "$\n */\n\n/*\n"
|
||||
" * Build in preprocessor rules.\n"
|
||||
fprintf( fout, "/*\n"
|
||||
" * Built-in preprocessor rules.\n"
|
||||
" *\n"
|
||||
" * Copyright 2006-2016 Przemyslaw Czerpak <druzus / at / priv.onet.pl>\n"
|
||||
" *\n"
|
||||
@@ -321,7 +321,6 @@ static char * hb_pp_escapeString( char * szString )
|
||||
static int hb_pp_generateVerInfo( char * szVerFile, int iRevID, char * szChangeLogID, char * szLastEntry )
|
||||
{
|
||||
int iResult = 0;
|
||||
char * pszEnv;
|
||||
FILE * fout;
|
||||
|
||||
fout = hb_fopen( szVerFile, "w" );
|
||||
@@ -334,6 +333,7 @@ static int hb_pp_generateVerInfo( char * szVerFile, int iRevID, char * szChangeL
|
||||
}
|
||||
else
|
||||
{
|
||||
char * pszEnv;
|
||||
char * pszEscaped;
|
||||
|
||||
fprintf( fout, "/*\n"
|
||||
|
||||
@@ -193,7 +193,7 @@ static const HB_PP_OPERATOR s_operators[] =
|
||||
{ "%" , 1, "%" , HB_PP_TOKEN_MOD | HB_PP_TOKEN_STATIC },
|
||||
{ "^" , 1, "^" , HB_PP_TOKEN_POWER | HB_PP_TOKEN_STATIC }
|
||||
/* unused: ? ~ " ' ` */
|
||||
/* not accesible: " ' ` */
|
||||
/* not accessible: " ' ` */
|
||||
/* illegal in Clipper: ~ */
|
||||
};
|
||||
|
||||
@@ -270,7 +270,7 @@ static const HB_PP_OPERATOR * hb_pp_operatorFind( PHB_PP_STATE pState,
|
||||
}
|
||||
|
||||
pOperator = s_operators;
|
||||
i = sizeof( s_operators ) / sizeof( HB_PP_OPERATOR );
|
||||
i = HB_SIZEOFARRAY( s_operators );
|
||||
|
||||
do
|
||||
{
|
||||
@@ -394,13 +394,12 @@ static void hb_pp_tokenListFree( PHB_PP_TOKEN * pTokenPtr )
|
||||
|
||||
static int hb_pp_tokenListFreeCmd( PHB_PP_TOKEN * pTokenPtr )
|
||||
{
|
||||
PHB_PP_TOKEN pToken;
|
||||
HB_BOOL fStop = HB_FALSE;
|
||||
int iLines = 0;
|
||||
|
||||
while( *pTokenPtr && ! fStop )
|
||||
{
|
||||
pToken = *pTokenPtr;
|
||||
PHB_PP_TOKEN pToken = *pTokenPtr;
|
||||
*pTokenPtr = pToken->pNext;
|
||||
if( HB_PP_TOKEN_TYPE( pToken->type ) == HB_PP_TOKEN_EOL )
|
||||
++iLines;
|
||||
@@ -777,15 +776,15 @@ static HB_BOOL hb_pp_canQuote( HB_BOOL fQuote, char * pBuffer, HB_SIZE nLen,
|
||||
|
||||
static HB_BOOL hb_pp_hasCommand( char * pBuffer, HB_SIZE nLen, HB_SIZE * pnAt, int iCmds, ... )
|
||||
{
|
||||
HB_SIZE n = 0, nl;
|
||||
char * cmd;
|
||||
HB_SIZE n = 0;
|
||||
va_list va;
|
||||
int i;
|
||||
|
||||
va_start( va, iCmds );
|
||||
for( i = 0; i < iCmds && n < nLen; ++i )
|
||||
{
|
||||
cmd = va_arg( va, char * );
|
||||
HB_SIZE nl;
|
||||
char * cmd = va_arg( va, char * );
|
||||
nl = strlen( cmd );
|
||||
while( n < nLen && HB_PP_ISBLANK( pBuffer[ n ] ) )
|
||||
++n;
|
||||
@@ -884,8 +883,7 @@ static void hb_pp_dumpEnd( PHB_PP_STATE pState )
|
||||
static void hb_pp_getLine( PHB_PP_STATE pState )
|
||||
{
|
||||
PHB_PP_TOKEN * pInLinePtr, * pEolTokenPtr;
|
||||
char * pBuffer, ch;
|
||||
HB_SIZE nLen, n;
|
||||
char * pBuffer;
|
||||
HB_BOOL fDump = HB_FALSE;
|
||||
int iLines = 0, iStartLine;
|
||||
|
||||
@@ -904,6 +902,8 @@ static void hb_pp_getLine( PHB_PP_STATE pState )
|
||||
|
||||
do
|
||||
{
|
||||
HB_SIZE nLen, n;
|
||||
|
||||
hb_membufFlush( pState->pBuffer );
|
||||
hb_pp_readLine( pState );
|
||||
pBuffer = hb_membufPtr( pState->pBuffer );
|
||||
@@ -936,7 +936,7 @@ static void hb_pp_getLine( PHB_PP_STATE pState )
|
||||
n = 0;
|
||||
while( n < nLen || fDump )
|
||||
{
|
||||
ch = pBuffer[ 0 ];
|
||||
char ch = pBuffer[ 0 ];
|
||||
if( pState->iStreamDump )
|
||||
{
|
||||
fDump = HB_FALSE;
|
||||
@@ -1226,7 +1226,8 @@ static void hb_pp_getLine( PHB_PP_STATE pState )
|
||||
nLen += hb_membufLen( pState->pBuffer ) - u;
|
||||
pBuffer = hb_membufPtr( pState->pBuffer ) + u - n;
|
||||
--n;
|
||||
while( ++n < nLen && pBuffer[ n ] != ch ) {}
|
||||
while( ++n < nLen && pBuffer[ n ] != ch )
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1262,7 +1263,7 @@ static void hb_pp_getLine( PHB_PP_STATE pState )
|
||||
}
|
||||
else if( ch == '*' && pState->pFile->iTokens == 0 )
|
||||
{
|
||||
/* strip the rest of line with // or && comment */
|
||||
/* strip the rest of line with * comment */
|
||||
n = nLen;
|
||||
}
|
||||
else if( ch == '/' && nLen > 1 && pBuffer[ 1 ] == '*' )
|
||||
@@ -1306,7 +1307,7 @@ static void hb_pp_getLine( PHB_PP_STATE pState )
|
||||
;
|
||||
|
||||
/*
|
||||
* In Clipper note can be used only as 1-st token and after
|
||||
* In Clipper note can be used only as 1st token and after
|
||||
* statement separator ';' it does not work like a single line
|
||||
* comment.
|
||||
*/
|
||||
@@ -3182,7 +3183,7 @@ static HB_BOOL hb_pp_matchPatternNew( PHB_PP_STATE pState, PHB_PP_TOKEN * pToken
|
||||
return HB_FALSE;
|
||||
}
|
||||
/* replace the order for these optional tokens to keep
|
||||
the ones with keywords 1-st */
|
||||
the ones with keywords 1st */
|
||||
( *pTokenPtr )->pMTokens = *pLastPtr;
|
||||
*pLastPtr = pOptTok;
|
||||
}
|
||||
@@ -3414,7 +3415,7 @@ static void hb_pp_directiveNew( PHB_PP_STATE pState, PHB_PP_TOKEN pToken,
|
||||
{
|
||||
if( pMatch )
|
||||
{
|
||||
/* Clipper PP makes sth like that for result pattern of
|
||||
/* Clipper PP makes something like that for result pattern of
|
||||
#[x]translate and #[x]command */
|
||||
if( pStart->spaces > 1 )
|
||||
pStart->spaces = 1;
|
||||
@@ -3821,7 +3822,7 @@ static HB_BOOL hb_pp_tokenMatch( PHB_PP_TOKEN pMatch, PHB_PP_TOKEN * pTokenPtr,
|
||||
|
||||
/*
|
||||
* Here we are strictly Clipper compatible. Clipper accepts dummy
|
||||
* restrict marker which starts from comma, <id: ,[ sth,...]>
|
||||
* restrict marker which starts from comma, <id: ,[ something,...]>
|
||||
* which always match empty expression. The same effect can be
|
||||
* reached by giving ,, in the world list on other positions.
|
||||
*/
|
||||
@@ -4208,15 +4209,14 @@ static PHB_PP_TOKEN * hb_pp_matchResultAdd( PHB_PP_STATE pState,
|
||||
{
|
||||
PHB_PP_RESULT pMarkerResult = hb_pp_matchResultGet( pRule, usMatch, pMatch->index );
|
||||
PHB_PP_TOKEN pToken, pStop;
|
||||
HB_BOOL fSpaces, fFirst;
|
||||
|
||||
if( HB_PP_TOKEN_TYPE( pMatch->type ) == HB_PP_RMARKER_REGULAR )
|
||||
{
|
||||
if( pMarkerResult )
|
||||
{
|
||||
HB_BOOL fFirst = HB_TRUE;
|
||||
pToken = pMarkerResult->pFirstToken;
|
||||
pStop = pMarkerResult->pNextExpr;
|
||||
fFirst = HB_TRUE;
|
||||
if( pToken != pStop )
|
||||
{
|
||||
do
|
||||
@@ -4243,7 +4243,7 @@ static PHB_PP_TOKEN * hb_pp_matchResultAdd( PHB_PP_STATE pState,
|
||||
pStop = pMarkerResult->pNextExpr;
|
||||
if( pToken != pStop )
|
||||
{
|
||||
fSpaces = HB_FALSE;
|
||||
HB_BOOL fSpaces = HB_FALSE;
|
||||
do
|
||||
{
|
||||
hb_pp_tokenStr( pToken, pState->pBuffer, fSpaces, HB_FALSE, 0 );
|
||||
@@ -4389,7 +4389,7 @@ static char * hb_pp_tokenListStr( PHB_PP_TOKEN pToken, PHB_PP_TOKEN pStop,
|
||||
static void hb_pp_patternReplace( PHB_PP_STATE pState, PHB_PP_RULE pRule,
|
||||
PHB_PP_TOKEN * pTokenPtr, const char * szType )
|
||||
{
|
||||
PHB_PP_TOKEN pFinalResult = NULL, * pResultPtr, pToken, pSource;
|
||||
PHB_PP_TOKEN pFinalResult = NULL, * pResultPtr, pSource;
|
||||
|
||||
pResultPtr = hb_pp_patternStuff( pState, pRule, 0, pRule->pResult, &pFinalResult );
|
||||
|
||||
@@ -4424,7 +4424,7 @@ static void hb_pp_patternReplace( PHB_PP_STATE pState, PHB_PP_RULE pRule,
|
||||
/* Free the matched tokens */
|
||||
while( pSource != pRule->pNextExpr )
|
||||
{
|
||||
pToken = pSource;
|
||||
PHB_PP_TOKEN pToken = pSource;
|
||||
pSource = pSource->pNext;
|
||||
hb_pp_tokenFree( pToken );
|
||||
}
|
||||
@@ -4549,13 +4549,12 @@ static HB_BOOL hb_pp_processDefine( PHB_PP_STATE pState, PHB_PP_TOKEN * pFirstPt
|
||||
|
||||
static HB_BOOL hb_pp_processTranslate( PHB_PP_STATE pState, PHB_PP_TOKEN * pFirstPtr )
|
||||
{
|
||||
PHB_PP_TOKEN * pTokenPtr;
|
||||
HB_BOOL fSubst = HB_FALSE, fRepeat;
|
||||
int iCycle = 0;
|
||||
|
||||
do
|
||||
{
|
||||
pTokenPtr = pFirstPtr;
|
||||
PHB_PP_TOKEN * pTokenPtr = pFirstPtr;
|
||||
fRepeat = HB_FALSE;
|
||||
while( ! HB_PP_TOKEN_ISEOS( *pTokenPtr ) )
|
||||
{
|
||||
@@ -5434,7 +5433,6 @@ static void hb_pp_preprocessToken( PHB_PP_STATE pState )
|
||||
void hb_pp_initRules( PHB_PP_RULE * pRulesPtr, int * piRules,
|
||||
const HB_PP_DEFRULE pDefRules[], int iDefRules )
|
||||
{
|
||||
const HB_PP_DEFRULE * pDefRule;
|
||||
PHB_PP_MARKER pMarkers;
|
||||
PHB_PP_RULE pRule;
|
||||
|
||||
@@ -5443,7 +5441,7 @@ void hb_pp_initRules( PHB_PP_RULE * pRulesPtr, int * piRules,
|
||||
|
||||
while( --iDefRules >= 0 )
|
||||
{
|
||||
pDefRule = pDefRules + iDefRules;
|
||||
const HB_PP_DEFRULE * pDefRule = pDefRules + iDefRules;
|
||||
if( pDefRule->markers > 0 )
|
||||
{
|
||||
HB_USHORT marker;
|
||||
@@ -5641,7 +5639,6 @@ void hb_pp_setStdBase( PHB_PP_STATE pState )
|
||||
*/
|
||||
void hb_pp_initDynDefines( PHB_PP_STATE pState, HB_BOOL fArchDefs )
|
||||
{
|
||||
char szDefine[ 65 ];
|
||||
char szResult[ 65 ];
|
||||
int iYear, iMonth, iDay, i;
|
||||
long lDate, lTime;
|
||||
@@ -5650,6 +5647,8 @@ void hb_pp_initDynDefines( PHB_PP_STATE pState, HB_BOOL fArchDefs )
|
||||
{
|
||||
static const char * s_szPlatform = "__PLATFORM__%s";
|
||||
|
||||
char szDefine[ 65 ];
|
||||
|
||||
if( hb_verPlatformMacro() )
|
||||
{
|
||||
hb_snprintf( szDefine, sizeof( szDefine ), s_szPlatform, hb_verPlatformMacro() );
|
||||
@@ -5728,7 +5727,6 @@ void hb_pp_readRules( PHB_PP_STATE pState, const char * szRulesFile )
|
||||
char szFileName[ HB_PATH_MAX ];
|
||||
PHB_PP_FILE pFile = pState->pFile;
|
||||
PHB_FNAME pFileName;
|
||||
HB_BOOL fError = HB_FALSE;
|
||||
|
||||
pFileName = hb_fsFNameSplit( szRulesFile );
|
||||
if( ! pFileName->szExtension )
|
||||
@@ -5745,6 +5743,8 @@ void hb_pp_readRules( PHB_PP_STATE pState, const char * szRulesFile )
|
||||
}
|
||||
else
|
||||
{
|
||||
HB_BOOL fError = HB_FALSE;
|
||||
|
||||
pState->iFiles++;
|
||||
pState->usLastType = HB_PP_TOKEN_NUL;
|
||||
while( hb_pp_tokenGet( pState ) )
|
||||
|
||||
@@ -44,9 +44,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "hbpp.h"
|
||||
#include "hbapi.h"
|
||||
#include "hbpp.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapifs.h"
|
||||
#include "hbapierr.h"
|
||||
@@ -58,7 +57,7 @@ static void hb_pp_ErrorMessage( void * cargo, const char * const szMsgTable[],
|
||||
char cPrefix, int iCode,
|
||||
const char * szParam1, const char * szParam2 )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_pp_ErrorGen(%p, %p, %c, %d, %s, %s)", cargo, szMsgTable, cPrefix, iCode, szParam1, szParam2 ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_pp_ErrorGen(%p, %p, %c, %d, %s, %s)", cargo, ( const void * ) szMsgTable, cPrefix, iCode, szParam1, szParam2 ) );
|
||||
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
@@ -148,18 +147,19 @@ PHB_PP_STATE hb_pp_Param( int iParam )
|
||||
|
||||
/*
|
||||
* initialize new PP context and return pointer to it.
|
||||
* __pp_Init( [<cIncludePath>], [<cStdChFile> ] [, <lArchDefs>] ) -> <pPP>
|
||||
* __pp_Init( [<cIncludePath>], [<cStdChFile> ] [, <lArchDefs>] ) --> <pPP>
|
||||
* when <cStdChFile> is empty string ("") then no default rules are used
|
||||
* only the dynamically created #defines like __HARBOUR__, __DATE__, __TIME__
|
||||
*/
|
||||
HB_FUNC( __PP_INIT )
|
||||
{
|
||||
PHB_PP_STATE * pStatePtr, pState = hb_pp_new();
|
||||
PHB_PP_STATE pState = hb_pp_new();
|
||||
|
||||
if( pState )
|
||||
{
|
||||
PHB_PP_STATE * pStatePtr;
|
||||
const char * szPath = hb_parc( 1 ), * szStdCh = hb_parc( 2 );
|
||||
HB_BOOL fArchDefs = hb_parldef( 3, 1 );
|
||||
HB_BOOL fArchDefs = hb_parldef( 3, HB_TRUE );
|
||||
PHB_ITEM ppItem;
|
||||
|
||||
pStatePtr = ( PHB_PP_STATE * ) hb_gcAllocate( sizeof( PHB_PP_STATE ),
|
||||
@@ -190,7 +190,7 @@ HB_FUNC( __PP_INIT )
|
||||
|
||||
/*
|
||||
* add new (or replace previous) include paths.
|
||||
* __pp_Path( <pPP>, <cPath> [, <lClearPrev>] ) -> NIL
|
||||
* __pp_Path( <pPP>, <cPath> [, <lClearPrev>] ) --> NIL
|
||||
*/
|
||||
HB_FUNC( __PP_PATH )
|
||||
{
|
||||
@@ -202,7 +202,7 @@ HB_FUNC( __PP_PATH )
|
||||
|
||||
/*
|
||||
* reset the PP context (remove all rules added by user or preprocessed code)
|
||||
* __pp_Reset( <pPP> ) -> NIL
|
||||
* __pp_Reset( <pPP> ) --> NIL
|
||||
*/
|
||||
HB_FUNC( __PP_RESET )
|
||||
{
|
||||
@@ -214,7 +214,7 @@ HB_FUNC( __PP_RESET )
|
||||
|
||||
/*
|
||||
* preprocess and execute new preprocessor directive
|
||||
* __pp_AddRule( <pPP>, <cDirective> ) -> <lOK>
|
||||
* __pp_AddRule( <pPP>, <cDirective> ) --> <lOK>
|
||||
*/
|
||||
HB_FUNC( __PP_ADDRULE )
|
||||
{
|
||||
@@ -239,7 +239,7 @@ HB_FUNC( __PP_ADDRULE )
|
||||
hb_pp_parseLine( pState, szText, &nLen );
|
||||
|
||||
/* probably for parsing #included files the old code was making
|
||||
sth like that */
|
||||
something like that */
|
||||
do
|
||||
{
|
||||
if( hb_vmRequestQuery() != 0 )
|
||||
@@ -256,7 +256,7 @@ HB_FUNC( __PP_ADDRULE )
|
||||
|
||||
/*
|
||||
* preprocess given code and return result
|
||||
* __pp_Process( <pPP>, <cCode> ) -> <cPreprocessedCode>
|
||||
* __pp_Process( <pPP>, <cCode> ) --> <cPreprocessedCode>
|
||||
*/
|
||||
HB_FUNC( __PP_PROCESS )
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* .prg interface to preprocessor
|
||||
* __pp_StdRules() function
|
||||
* intentionally in separate file to not force linking
|
||||
* standard PP rules table when user does not need them
|
||||
* __pp_StdRules() function
|
||||
* intentionally in separate file to not force linking
|
||||
* standard PP rules table when user does not need them
|
||||
*
|
||||
* Copyright 2006 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
*
|
||||
@@ -47,8 +47,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbpp.h"
|
||||
#include "hbapi.h"
|
||||
#include "hbpp.h"
|
||||
|
||||
HB_FUNC( __PP_STDRULES )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user