From 6ef5fd19a8df63d3c8d938627e71fdbc816ec45a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 2 Feb 2011 21:10:15 +0000 Subject: [PATCH] 2011-02-02 22:08 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * config/postinst.hbs * MAKEDIR() -> HB_DIRCREATE(). Warning: Make a 'make clean' _before_ updating to this revision. Or, do a fresh checkout and build that. Or, do a clean rebuild twice. (otherwise plain 'make clean' will end with an error) - examples/pp - Deleted obsolete PP code. ; NOTE: Now that HB_BUILD_CONTRIB_DYN=yes works pretty much okay on both win and linux, I will delete this tool meant as a temporary workaround for those requiring dynamic versions of Harbour libs: bin/hbmk2l2d.hbs If you need it, make a copy of it locally, though most pbly nobody ever used this. --- harbour/ChangeLog | 21 +- harbour/config/postinst.hbs | 2 +- harbour/examples/pp/hbppcomp.c | 631 ----- harbour/examples/pp/hbppcore.c | 4810 -------------------------------- harbour/examples/pp/hbppdef.h | 217 -- harbour/examples/pp/hbpptbl.c | 450 --- harbour/examples/pp/hbpragma.c | 425 --- harbour/examples/pp/pp.1 | 30 - harbour/examples/pp/pp.c | 520 ---- harbour/examples/pp/pp.hbp | 9 - 10 files changed, 21 insertions(+), 7094 deletions(-) delete mode 100644 harbour/examples/pp/hbppcomp.c delete mode 100644 harbour/examples/pp/hbppcore.c delete mode 100644 harbour/examples/pp/hbppdef.h delete mode 100644 harbour/examples/pp/hbpptbl.c delete mode 100644 harbour/examples/pp/hbpragma.c delete mode 100644 harbour/examples/pp/pp.1 delete mode 100644 harbour/examples/pp/pp.c delete mode 100644 harbour/examples/pp/pp.hbp diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 965dbafa90..6a3aa64620 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,25 @@ The license applies to all entries newer than 2009-04-28. */ +2011-02-02 22:08 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * config/postinst.hbs + * MAKEDIR() -> HB_DIRCREATE(). + Warning: Make a 'make clean' _before_ updating to this revision. + Or, do a fresh checkout and build that. + Or, do a clean rebuild twice. + (otherwise plain 'make clean' will end with an error) + + - examples/pp + - Deleted obsolete PP code. + + ; NOTE: Now that HB_BUILD_CONTRIB_DYN=yes works pretty much + okay on both win and linux, I will delete this + tool meant as a temporary workaround for those + requiring dynamic versions of Harbour libs: + bin/hbmk2l2d.hbs + If you need it, make a copy of it locally, though + most pbly nobody ever used this. + 2011-02-02 18:14 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg + Added -manifest= hbmk2 option for -hbexe/-hbdyn targets on @@ -267,7 +286,7 @@ * examples/hbdoc2/gentpl.prg * Replaced MakeDir() with universally available hb_DirCreate(). ; TODO: same in config/postinst.hbs (delayed to avoid a million - false bug reports) + false bug reports) [DONE] * src/rtl/Makefile + src/rtl/hbfilehi.prg diff --git a/harbour/config/postinst.hbs b/harbour/config/postinst.hbs index 1d2d71062f..8b1405e53c 100644 --- a/harbour/config/postinst.hbs +++ b/harbour/config/postinst.hbs @@ -425,7 +425,7 @@ STATIC FUNCTION DirBuild( cDir ) IF hb_FileExists( cDirTemp ) RETURN .F. ELSEIF ! hb_DirExists( cDirTemp ) - IF MakeDir( cDirTemp ) != 0 + IF hb_DirCreate( cDirTemp ) != 0 RETURN .F. ENDIF ENDIF diff --git a/harbour/examples/pp/hbppcomp.c b/harbour/examples/pp/hbppcomp.c deleted file mode 100644 index 9f44ca360e..0000000000 --- a/harbour/examples/pp/hbppcomp.c +++ /dev/null @@ -1,631 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Preprocessor & Compiler integration module - * - * Copyright 1999 Alexander S.Kresin - * www - http://harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -/* - * Avoid tracing in preprocessor/compiler. - */ -#if ! defined( HB_TRACE_UTILS ) - #if defined( HB_TRACE_LEVEL ) - #undef HB_TRACE_LEVEL - #endif -#endif - -#include -#include -#include - -#include "hbppdef.h" -#include "hbcomp.h" - -static void pp_ParseBuffer( PFILE, int * ); -static char * pp_TextCommand( char * ptr, int * pLen ); -static void pp_TextBlockFinish( void ); -static void pp_StreamBlockFinish( void ); - -#if ! defined( HB_PP_DEBUG_MEMORY ) -static char s_szLine[ HB_PP_STR_SIZE ]; -static char s_szOutLine[ HB_PP_STR_SIZE ]; -#else -static char * s_szLine = NULL; -static char * s_szOutLine = NULL; -#endif -int hb_pp_LastOutLine = 1; -static char * s_TextOutFunc = NULL; -static char * s_TextEndFunc = NULL; -static char * s_TextStartFunc = NULL; - -/* - HB_BOOL bDebug = HB_FALSE; - */ - -void hb_pp_InternalFree( void ) -{ -#if defined( HB_PP_DEBUG_MEMORY ) - if( s_szLine ) - { - hb_xfree( s_szLine ); - s_szLine = NULL; - } - if( s_szOutLine ) - { - hb_xfree( s_szOutLine ); - s_szOutLine = NULL; - } -#endif - if( s_TextOutFunc ) - { - hb_xfree( s_TextOutFunc ); - s_TextOutFunc = NULL; - } - if( s_TextEndFunc ) - { - hb_xfree( s_TextEndFunc ); - s_TextEndFunc = NULL; - } - if( s_TextStartFunc ) - { - hb_xfree( s_TextStartFunc ); - s_TextStartFunc = NULL; - } -} - -int hb_pp_Internal_( FILE * handl_o, char * sOut ) -{ - PFILE pFile; - char * ptr, * ptrOut, * tmpPtr; - int lContinue; - int rdlen; - ULONG lens; - int lLine = 0; - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_Internal_(%p, %s)", handl_o, sOut ) ); - -#if defined( HB_PP_DEBUG_MEMORY ) - if( ! s_szLine ) - s_szLine = ( char * ) hb_xgrab( HB_PP_STR_SIZE ); - if( ! s_szOutLine ) - s_szOutLine = ( char * ) hb_xgrab( HB_PP_STR_SIZE ); -#endif - - hb_pp_NestedLiteralString = HB_FALSE; - hb_pp_LiteralEscSeq = HB_FALSE; - for(;; ) - { - pFile = hb_comp_files.pLast; - lens = 0; - lContinue = 0; - ptrOut = sOut; - while( ( rdlen = hb_pp_RdStr( pFile->handle, s_szLine + lens, HB_PP_STR_SIZE - - lens, lContinue, ( char * ) pFile->pBuffer, &( pFile->lenBuffer ), - &( pFile->iBuffer ) ) ) >= 0 ) - { - lens += rdlen; - hb_comp_iLine++; - - if( lens >= HB_PP_STR_SIZE - 2 ) - { - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_BUFFER_OVERFLOW, NULL, NULL ); - } - - if( hb_pp_StreamBlock ) - { - if( hb_pp_StreamBlock == HB_PP_STREAM_DUMP_C ) - break; - else if( hb_pp_StreamBlock == HB_PP_STREAM_CLIPPER ) - { - /* Clipper compatible TEXT/ENDTEXT handling */ - ptr = s_szLine; - HB_SKIPTABSPACES( ptr ); - if( hb_stricmp( ptr, "ENDTEXT" ) == 0 || - hb_stricmp( ptr, "#pragma __endtext" ) == 0 ) - { - pp_TextBlockFinish(); - break; - } - - if( s_TextOutFunc ) - { - memmove( s_szLine + 1, s_szLine, lens++ ); - s_szLine[ 0 ] = '['; - s_szLine[ lens++ ] = ']'; - s_szLine[ lens ] = '\0'; - lens = hb_snprintf( s_szOutLine, HB_PP_STR_SIZE, s_TextOutFunc, s_szLine ); - memcpy( s_szLine, s_szOutLine, lens + 1 ); - hb_pp_NestedLiteralString = HB_TRUE; - break; - } - else - { - s_szLine[ 0 ] = '\0'; /* discard text */ - } - } - else if( hb_pp_StreamBlock == HB_PP_STREAM_PRG ) - { - ptr = s_szLine + lens - rdlen; - HB_SKIPTABSPACES( ptr ); - if( hb_stricmp( ptr, "ENDTEXT" ) == 0 || - hb_stricmp( ptr, "#pragma __endtext" ) == 0 ) - { - lens -= rdlen; - s_szLine[ lens ] = '\0'; - pp_StreamBlockFinish(); - break; - } - else - { - lContinue = 1; - continue; - } - } - else if( hb_pp_StreamBlock == HB_PP_STREAM_C ) - { - ptr = s_szLine + lens - rdlen; - HB_SKIPTABSPACES( ptr ); - if( hb_stricmp( ptr, "ENDTEXT" ) == 0 || - hb_stricmp( ptr, "#pragma __endtext" ) == 0 ) - { - lens -= rdlen; - s_szLine[ lens ] = '\0'; - pp_StreamBlockFinish(); - hb_pp_LiteralEscSeq = HB_TRUE; - break; - } - else - { - lContinue = 1; - continue; - } - } - } - - if( s_szLine[ lens - 1 ] == ';' ) - { - lContinue = pFile->lenBuffer ? 1 : 0; - lens--; - lens--; - while( s_szLine[ lens ] == ' ' || s_szLine[ lens ] == '\t' ) - lens--; - s_szLine[ ++lens ] = ' '; - s_szLine[ ++lens ] = '\0'; - } - else - { - lContinue = 0; - lens = 0; - } - - if( ! lContinue ) - { - pp_ParseBuffer( pFile, &lLine ); - break; - } - } - - if( rdlen < 0 ) - { - if( hb_comp_files.iFiles == 1 ) - return 0; /* we have reached the main EOF */ - else - { - hb_pp_CloseInclude(); - lLine = 1; - } - - /* Ron Pinkas added 2000-06-22 */ - s_szLine[ 0 ] = '\0'; - break; - /* Ron Pinkas end 2000-06-22 */ - } - - if( *s_szLine ) - break; - } - - if( lLine ) - { - if( hb_comp_files.iFiles == 1 ) - hb_pp_LastOutLine = hb_comp_iLine; - - hb_snprintf( ptrOut, HB_PP_STR_SIZE, "#line %d \"%s\"", ( hb_comp_files.pLast->iLine ), hb_comp_files.pLast->szFileName ); - - while( *ptrOut ) - ptrOut++; - - /* Ron Pinkas added 2000-06-14 */ - tmpPtr = s_szLine; - HB_SKIPTABSPACES( tmpPtr ); - - /* Last Opened file ended without CR - adding CR to the #line directive. */ - if( *tmpPtr != '\0' ) - { - *ptrOut++ = '\n'; - *ptrOut = '\0'; - } - /* Ron Pinkas end 2000-06-14 */ - } - else - { - /* Ron Pinkas added 2000-06-13 */ - /* Ignore empty lines in #included files. */ - /* Ron Pinkas removed 2001-01-20 */ - #if 0 - if( ( hb_pp_LastOutLine != hb_comp_iLine ) && hb_comp_files.iFiles == 1 && handl_o ) - /* Ron Pinkas end 2000-06-13 */ - for(; hb_pp_LastOutLine < hb_comp_iLine; hb_pp_LastOutLine++ ) - hb_pp_WrStr( handl_o, "\n" ); - #endif - /* END Ron Pinkas removed 2001-01-20 */ - } - - lens = hb_pp_strocpy( ptrOut, s_szLine ) + ( ptrOut - sOut ); - - *( sOut + lens++ ) = '\n'; - *( sOut + lens ) = '\0'; - - if( hb_comp_iLineINLINE && hb_pp_StreamBlock == 0 ) - { - hb_comp_iLine = hb_comp_iLinePRG + ( hb_comp_iLine - hb_comp_iLineINLINE ); - hb_comp_iLine++; - hb_comp_iLineINLINE = 0; - } - - if( handl_o ) - { - hb_pp_WrStr( handl_o, sOut ); - } - - #if 0 - printf( "%d : %s\n", hb_comp_iLine, sOut ); - #endif - - return lens; -} - -static void pp_ParseBuffer( PFILE pFile, int * plLine ) -{ - HB_BOOL bCont = HB_TRUE; - char * ptr; - - while( bCont && *s_szLine != '\0' ) - { - ptr = s_szLine; - HB_SKIPTABSPACES( ptr ); - - if( *ptr == '#' ) - { - HB_BOOL bIgnore = hb_pp_ParseDirective_( ptr ); - - if( pFile != hb_comp_files.pLast ) - { - pFile = ( PFILE ) ( ( PFILE ) hb_comp_files.pLast )->pPrev; - - if( *plLine ) - { - hb_snprintf( s_szLine, HB_PP_STR_SIZE, "#line %d \"%s\"\n", pFile->iLine, pFile->szFileName ); - *plLine = 0; - } - else - *s_szLine = '\0'; - - hb_snprintf( s_szLine + strlen( s_szLine ), HB_PP_STR_SIZE - strlen( s_szLine ), - "#line 1 \"%s\"", hb_comp_files.pLast->szFileName ); - bCont = HB_FALSE; - } - else if( bIgnore ) - *s_szLine = '\0'; - else - { - hb_pp_ParseExpression( ptr, s_szOutLine, HB_TRUE ); - } - } - else - { - if( *ptr == '\0' ) - { - if( hb_comp_files.iFiles == 1 ) - *s_szLine = '\0'; - else - bCont = HB_FALSE; - } - else - { - if( hb_pp_nCondCompile == 0 || hb_pp_aCondCompile[ hb_pp_nCondCompile - 1 ] ) - { - hb_pp_ParseExpression( ptr, s_szOutLine, HB_TRUE ); - HB_SKIPTABSPACES( ptr ); - - bCont = ( *ptr == '#' ); - } - else - *s_szLine = '\0'; - } - } - } -} - -static char * pp_TextCommand( char * ptr, int * pLen ) -{ - int i; - char * cCommand = NULL; - - i = 0; - while( ptr[ i ] && ptr[ i ] != '|' ) - { - i++; - } - if( i > 0 ) - { - cCommand = ( char * ) hb_xgrab( i + 1 ); - i = 0; - while( ptr[ i ] && ptr[ i ] != '|' ) - { - cCommand[ i ] = ptr[ i ]; - i++; - } - cCommand[ i ] = '\0'; - *pLen -= i + 1; - if( *pLen ) - memcpy( ptr, ptr + i + 1, *pLen ); - else - ptr[ 0 ] = '\0'; - } - else if( i == 0 && *ptr == '|' ) - { - ( *pLen )--; - if( *pLen ) - memcpy( ptr, ptr + 1, *pLen ); - else - *ptr = '\0'; - } - - return cCommand; -} - -static void pp_TextBlockFinish( void ) -{ - hb_pp_StreamBlock = 0; - if( s_TextEndFunc ) - { - hb_strncpy( s_szLine, s_TextEndFunc, sizeof( s_szLine ) - 1 ); - hb_xfree( s_TextEndFunc ); - s_TextEndFunc = NULL; - } - else - { - s_szLine[ 0 ] = '\0'; - } - if( s_TextOutFunc ) - { - hb_xfree( s_TextOutFunc ); - s_TextOutFunc = NULL; - } - if( s_TextStartFunc ) - { - hb_xfree( s_TextStartFunc ); - s_TextStartFunc = NULL; - } - hb_pp_NestedLiteralString = HB_FALSE; -} - -HB_BOOL hb_pp_StreamBlockBegin( char * ptr, int iStreamType ) -{ - HB_BOOL bIgnore = HB_TRUE; - int len; - - switch( iStreamType ) - { - case HB_PP_STREAM_CLIPPER: - /* internal handling of TEXT/ENDTEXT command - * #pragma __text|functionOut|functionEnd|functionStart - */ - len = strlen( ptr ) - 6; - memcpy( ptr, ptr + 7, len ); - s_TextOutFunc = pp_TextCommand( ptr, &len ); - s_TextEndFunc = pp_TextCommand( ptr, &len ); - s_TextStartFunc = pp_TextCommand( ptr, &len ); - if( s_TextStartFunc ) - { - memcpy( ptr, s_TextStartFunc, strlen( s_TextStartFunc ) + 1 ); - bIgnore = HB_FALSE; - } - hb_pp_StreamBlock = iStreamType; - break; - - case HB_PP_STREAM_PRG: - /* internal handling of TEXT/ENDTEXT command - * #pragma __stream|functionOut|functionEnd|functionStart - * (lines are joined with CR/LF or LF) - */ - len = strlen( ptr ) - 8; - memcpy( ptr, ptr + 9, len ); - s_TextOutFunc = pp_TextCommand( ptr, &len ); - s_TextEndFunc = pp_TextCommand( ptr, &len ); - s_TextStartFunc = pp_TextCommand( ptr, &len ); - *ptr = '\0'; - hb_pp_StreamBlock = iStreamType; - break; - - case HB_PP_STREAM_C: - /* internal handling of TEXT/ENDTEXT command - * #pragma __cstream|functionOut|functionEnd|functionStart - * (lines are joined and C esc sequences are converted) - */ - len = strlen( ptr ) - 9; - memcpy( ptr, ptr + 10, len ); - s_TextOutFunc = pp_TextCommand( ptr, &len ); - s_TextEndFunc = pp_TextCommand( ptr, &len ); - s_TextStartFunc = pp_TextCommand( ptr, &len ); - *ptr = '\0'; - hb_pp_StreamBlock = iStreamType; - break; - - default: - break; - } - return bIgnore; -} - -static void pp_StreamBlockFinish( void ) -{ - hb_pp_StreamBlock = 0; - hb_snprintf( s_szOutLine, HB_PP_STR_SIZE, s_TextOutFunc, s_szLine ); - s_szLine[ 0 ] = '\0'; - if( s_TextStartFunc ) - { - hb_strncat( s_szLine, s_TextStartFunc, sizeof( s_szLine ) - 1 ); - hb_xfree( s_TextStartFunc ); - s_TextStartFunc = NULL; - } - hb_strncat( s_szLine, "[", sizeof( s_szLine ) - 1 ); - hb_strncat( s_szLine, s_szOutLine, sizeof( s_szLine ) - 1 ); - hb_strncat( s_szLine, "]", sizeof( s_szLine ) - 1 ); - if( s_TextEndFunc ) - { - hb_strncat( s_szLine, s_TextEndFunc, sizeof( s_szLine ) - 1 ); - hb_xfree( s_TextEndFunc ); - s_TextEndFunc = NULL; - } - if( s_TextOutFunc ) - { - hb_xfree( s_TextOutFunc ); - s_TextOutFunc = NULL; - } - hb_pp_NestedLiteralString = HB_TRUE; -} - -void hb_pp_BlockEnd() -{ - if( hb_pp_StreamBlock == HB_PP_STREAM_CLIPPER ) - pp_TextBlockFinish(); - else - pp_StreamBlockFinish(); -} - - -int hb_pp_ReadRules( void ) -{ - PFILE pFile; - char * ptr; - int lContinue; - int lens, rdlen; - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_ReadRules()" ) ); -#if defined( HB_PP_DEBUG_MEMORY ) - if( ! s_szLine ) - s_szLine = ( char * ) hb_xgrab( HB_PP_STR_SIZE ); - if( ! s_szOutLine ) - s_szOutLine = ( char * ) hb_xgrab( HB_PP_STR_SIZE ); -#endif - for(;; ) - { - pFile = hb_comp_files.pLast; - lens = lContinue = 0; - while( ( rdlen = hb_pp_RdStr( pFile->handle, s_szLine + lens, HB_PP_STR_SIZE - - lens, lContinue, ( char * ) pFile->pBuffer, &( pFile->lenBuffer ), - &( pFile->iBuffer ) ) ) >= 0 ) - { - lens += rdlen; - hb_comp_iLine++; - - if( s_szLine[ lens - 1 ] == ';' ) - { - lContinue = 1; - lens--; - lens--; - while( s_szLine[ lens ] == ' ' || s_szLine[ lens ] == '\t' ) - lens--; - s_szLine[ ++lens ] = ' '; - s_szLine[ ++lens ] = '\0'; - } - else - { - lContinue = 0; - lens = 0; - } - - if( ! lContinue ) - { - if( *s_szLine != '\0' ) - { - ptr = s_szLine; - HB_SKIPTABSPACES( ptr ); - - if( *ptr == '#' ) - { - hb_pp_ParseDirective_( ptr ); - } - - *s_szLine = '\0'; - } - - break; - } - } - - if( rdlen < 0 ) - { - if( hb_comp_files.iFiles == 1 ) - { - break; /* we have reached the main EOF */ - } - else - { - hb_pp_CloseInclude(); - hb_pp_LastOutLine = hb_comp_iLine; - } - - *s_szLine = '\0'; - } - } - - return 0; -} diff --git a/harbour/examples/pp/hbppcore.c b/harbour/examples/pp/hbppcore.c deleted file mode 100644 index 454b6de777..0000000000 --- a/harbour/examples/pp/hbppcore.c +++ /dev/null @@ -1,4810 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Preprocessor core module - * - * Copyright 1999 Alexander S.Kresin - * www - http://harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -/* - * The following parts are Copyright of the individual authors. - * www - http://harbour-project.org - * - * Copyright 1999-2001 Viktor Szakats (harbour.01 syenar.hu) - * __DATE__, __TIME__, __HB_MAIN__ support - * - * Copyright 2000 Ron Pinkas - * - * hb_pp_SetRules_() and related code for supportting - * replaceable rules with -w switch - * - * See COPYING for licensing terms. - * - */ - -/* - * Avoid tracing in preprocessor/compiler. - */ -#if ! defined( HB_TRACE_UTILS ) -#if defined( HB_TRACE_LEVEL ) -#undef HB_TRACE_LEVEL -#endif -#endif - -#include - -#include "hbppdef.h" -#include "hbcomp.h" -#include "hbdate.h" - -#if ! defined( __MINGW32CE__ ) && ! ( defined( _MSC_VER ) && defined( HB_OS_WIN_CE ) ) -# include -#endif - -int hb_pp_ParseDefine_( char * ); /* Process #define directive */ - -static COMMANDS * AddCommand( char * ); /* Add new #command to an array */ -static COMMANDS * AddTranslate( char * ); /* Add new #translate to an array */ -static DEFINES * DefSearch( char *, int, HB_BOOL * ); -static COMMANDS * ComSearch( char *, COMMANDS * ); -static COMMANDS * TraSearch( char *, COMMANDS * ); - -static int ParseUndef( char * ); /* Process #undef directive */ -static int ParseIfdef( char *, int ); /* Process #ifdef directive */ -static void ParseCommand( char *, HB_BOOL, HB_BOOL ); /* Process #command or #translate directive */ -static void ConvertPatterns( char *, int, char *, int ); /* Converting result pattern in #command and #translate */ -static int WorkDefine( char **, char *, DEFINES * ); /* Replace fragment of code with a #defined result text */ -static int WorkPseudoF( char **, char *, DEFINES * ); /* Replace pseudofunction with a #defined result text */ -static int WorkCommand( char *, char *, COMMANDS * ); -static int WorkTranslate( char *, char *, COMMANDS *, int * ); -static int CommandStuff( char *, char *, char *, int *, HB_BOOL, HB_BOOL ); -static int RemoveSlash( char * ); -static int WorkMarkers( char **, char **, char *, int *, HB_BOOL, HB_BOOL ); -static int getExpReal( char *, char **, HB_BOOL, int, HB_BOOL, HB_BOOL ); -static HB_BOOL isExpres( char *, HB_BOOL ); -static HB_BOOL TestOptional( char *, char * ); -static HB_BOOL CheckOptional( char *, char *, char *, int *, HB_BOOL, HB_BOOL ); -static void SkipOptional( char ** ); - -static void SearnRep( char *, char *, int, char *, int * ); -static int ReplacePattern( char, char *, int, char *, int ); -static void pp_rQuotes( char *, char * ); -static int md_strAt( char *, int, char *, HB_BOOL, HB_BOOL, HB_BOOL, int ); - -#define MD_STR_AT_IGNORECASE 0 /* search ignoring case */ -#define MD_STR_AT_USESUBCASE 1 /* use case specified in search string (old) */ -static char * PrevSquare( char *, char *, int * ); -static int IsInStr( char, char * ); -static int stroncpy( char *, char *, int ); -static int strincpy( char *, char * ); -static HB_BOOL truncmp( char **, char **, HB_BOOL ); -static HB_BOOL strincmp( char *, char **, HB_BOOL ); -static int strotrim( char *, HB_BOOL ); /* Ron Pinkas 2001-02-14 added 2nd parameter */ -static int NextWord( char **, char *, HB_BOOL ); -static int NextName( char **, char * ); -static int NextParm( char **, char * ); -static HB_BOOL OpenInclude( char *, HB_PATHNAMES *, PHB_FNAME, HB_BOOL bStandardOnly, char * ); -static HB_BOOL IsIdentifier( char * szProspect ); -static int IsMacroVar( char * szText, HB_BOOL isCommand ); -static void RemoveOptional( char * cpatt ); -static int ConvertOptional( char * cpatt, int len, HB_BOOL bLeft ); - -#define ISNAME( c ) ( isalnum( c ) || ( c ) == '_' || ( c ) > 0x7E ) -#define MAX_NAME 255 -#define MAX_EXP 2048 -#define PATTERN_SIZE 2048 - -#define STATE_INIT 0 -#define STATE_NORMAL 1 -#define STATE_COMMENT 2 -#define STATE_QUOTE1 3 -#define STATE_QUOTE2 4 -#define STATE_QUOTE3 5 -#define STATE_ID_END 6 -#define STATE_ID 7 -#define STATE_EXPRES 8 -#define STATE_EXPRES_ID 9 -#define STATE_BRACKET 10 - -#define IT_EXPR 1 -#define IT_ID 2 -#define IT_COMMA 3 -#define IT_ID_OR_EXPR 4 - -#define HB_PP_MAX_INCLUDES FOPEN_MAX - 5 - 1 - -#define HB_PP_MATCH_MARK '\1' -#define HB_PP_OPT_START '\2' -#define HB_PP_OPT_END '\3' - -/* Ron Pinkas added 2000-01-24 */ -#define IS_2CHAR_OPERATOR( p ) ( p[ 0 ] && p[ 1 ] && ( strncmp( p, ":=", 2 ) == 0 || \ - strncmp( p, "+=", 2 ) == 0 || \ - strncmp( p, "-=", 2 ) == 0 || \ - strncmp( p, "*=", 2 ) == 0 || \ - strncmp( p, "/=", 2 ) == 0 || \ - strncmp( p, "^=", 2 ) == 0 || \ - strncmp( p, "==", 2 ) == 0 || \ - strncmp( p, "<>", 2 ) == 0 || \ - strncmp( p, "<=", 2 ) == 0 || \ - strncmp( p, ">=", 2 ) == 0 || \ - strncmp( p, "++", 2 ) == 0 || \ - strncmp( p, "--", 2 ) == 0 || \ - strncmp( p, "->", 2 ) == 0 ) ) -/* END, Ron Pinkas added 2000-01-24 */ - - -static int s_kolAddDefs = 0; -static int s_kolAddComs = 0; -static int s_kolAddTras = 0; -static int s_ParseState; -static int s_maxCondCompile; -static int s_aIsRepeate[ 5 ]; -static int s_Repeate; -static HB_BOOL s_bReplacePat = HB_TRUE; -static int s_numBrackets; -static char s_groupchar; -static char s_prevchar; -/* additional buffers for expressions */ -static char * s_expreal = NULL; /* allocation inside WorkMarkers */ -static char * s_expcopy = NULL; /* allocation inside SearnExp */ - -/* global variables */ -int * hb_pp_aCondCompile = NULL; -int hb_pp_nCondCompile = 0; -HB_BOOL hb_pp_NestedLiteralString = HB_FALSE; -HB_BOOL hb_pp_LiteralEscSeq = HB_FALSE; -unsigned int hb_pp_MaxTranslateCycles = 1024; -int hb_pp_StreamBlock = 0; -char * hb_pp_STD_CH = NULL; - -/* Ron Pinkas added 2000-11-21 */ -static HB_BOOL s_bArray = HB_FALSE; - -/* Table with parse errors */ -const char * hb_pp_szErrors[] = { - "Can\'t open #include file: \'%s\'; %s", - "#else does not match #ifdef", - "#endif does not match #ifdef", - "Bad filename in #include", - "#define without parameters", - "Missing => in #translate/#command \'%s\' [%s]'", - "Error in pattern definition", - "Cycled #define", - "Invalid name follows #: \'%s\'", - "\'%s\'", - "Memory allocation error", - "Memory reallocation error", - "Freeing a NULL memory pointer", - "Value out of range in #pragma directive", - "Can\'t open command definitions file: \'%s\'", - "Invalid command definitions file name: \'%s\'", - "Too many nested #includes, can\'t open: \'%s\'", - "Input buffer overflow", - "Label missing in #define '%s'", - "Comma or right parenthesis missing in #define '%s'", - "Label duplicated in #define '%s(%s)'", -}; - -/* Table with warnings */ -const char * hb_pp_szWarnings[] = { - "1Redefinition or duplicate definition of #define %s", - "1No directives in command definitions file" -}; - -void hb_pp_SetRules_( HB_INCLUDE_FUNC_PTR pIncludeFunc, HB_BOOL bQuiet ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_SetRules_()" ) ); - - if( hb_pp_STD_CH ) - { - if( *hb_pp_STD_CH > ' ' ) - { - hb_comp_pFileName = hb_fsFNameSplit( hb_pp_STD_CH ); - - if( hb_comp_pFileName->szName ) - { - char szFileName[ HB_PATH_MAX ]; - - if( ! hb_comp_pFileName->szExtension ) - hb_comp_pFileName->szExtension = ".ch"; - - hb_fsFNameMerge( szFileName, hb_comp_pFileName ); - - if( ( *pIncludeFunc )( szFileName, hb_comp_pIncludePath ) ) - { - hb_pp_Init(); - - hb_pp_ReadRules(); - - if( s_kolAddComs || s_kolAddTras || s_kolAddDefs > 3 ) - { - if( ! bQuiet ) - printf( "Loaded: %i Commands, %i Translates, %i Defines from: %s\n", s_kolAddComs, s_kolAddTras, s_kolAddDefs - 3, szFileName ); - } - else - { - hb_compGenWarning( NULL, hb_pp_szWarnings, 'I', HB_PP_WARN_NO_DIRECTIVES, NULL /*szFileName */, NULL ); - } - - fclose( hb_comp_files.pLast->handle ); - hb_xfree( hb_comp_files.pLast->pBuffer ); - hb_xfree( hb_comp_files.pLast->szFileName ); - hb_xfree( hb_comp_files.pLast ); - hb_comp_files.pLast = NULL; - hb_comp_files.iFiles = 0; - - hb_xfree( hb_comp_pFileName ); - hb_comp_pFileName = NULL; - } - else - { - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_CANNOT_OPEN_RULES, szFileName, NULL ); - } - } - else - { - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_BAD_RULES_FILE_NAME, hb_pp_STD_CH, NULL ); - } - } - else - { - if( ! bQuiet ) - printf( "Standard command definitions excluded.\n" ); - - hb_pp_Init(); - } - hb_xfree( hb_pp_STD_CH ); - } - else - { - hb_pp_Table(); - hb_pp_Init(); - } -} - -void hb_pp_Free( void ) -{ - DEFINES * stdef; - COMMANDS * stcmd; - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_Free()" ) ); - - while( s_kolAddDefs ) - { - stdef = hb_pp_topDefine; - if( stdef->pars ) - hb_xfree( stdef->pars ); - if( stdef->value ) - hb_xfree( stdef->value ); - if( stdef->name ) - hb_xfree( stdef->name ); - hb_pp_topDefine = stdef->last; - hb_xfree( stdef ); - s_kolAddDefs--; - } - while( s_kolAddComs ) - { - stcmd = hb_pp_topCommand; - if( stcmd->mpatt ) - hb_xfree( stcmd->mpatt ); - if( stcmd->value ) - hb_xfree( stcmd->value ); - hb_xfree( stcmd->name ); - hb_pp_topCommand = stcmd->last; - hb_xfree( stcmd ); - s_kolAddComs--; - } - while( s_kolAddTras ) - { - stcmd = hb_pp_topTranslate; - if( stcmd->mpatt ) - hb_xfree( stcmd->mpatt ); - if( stcmd->value ) - hb_xfree( stcmd->value ); - hb_xfree( stcmd->name ); - hb_pp_topTranslate = stcmd->last; - hb_xfree( stcmd ); - s_kolAddTras--; - } - if( hb_pp_aCondCompile ) - { - hb_xfree( hb_pp_aCondCompile ); - hb_pp_aCondCompile = NULL; - } - hb_pp_InternalFree(); - - if( s_expreal ) - { - hb_xfree( ( void * ) s_expreal ); - s_expreal = NULL; - } - if( s_expcopy ) - { - hb_xfree( ( void * ) s_expcopy ); - s_expcopy = NULL; - } -} - -void hb_pp_Init( void ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_Init()" ) ); - - hb_pp_Free(); - - s_ParseState = 0; - s_maxCondCompile = 5; - s_bReplacePat = HB_TRUE; - s_prevchar = 'A'; - - if( ! hb_pp_aCondCompile ) - hb_pp_aCondCompile = ( int * ) hb_xgrab( sizeof( int ) * 5 ); - - hb_pp_nCondCompile = 0; - - { - char sOS[ 64 ]; - char sVer[ 64 ]; - char * pSrc, * pDst; - char * szPlatform = hb_verPlatform(); - int n; - - hb_strncpy( sOS, "__PLATFORM__", sizeof( sOS ) - 1 ); - - pSrc = szPlatform; - n = strlen( sOS ); - pDst = sOS; - - while( *pSrc && *pSrc != ' ' && n < ( int ) sizeof( sOS ) - 1 ) - { - if( *pSrc == '_' || ( *pSrc >= 'A' && *pSrc <= 'Z' ) || ( *pSrc >= 'a' && *pSrc <= 'z' ) || ( *pSrc >= '0' && *pSrc <= '9' ) ) - { - pDst[ n++ ] = *pSrc; - } - pSrc++; - } - pDst[ n ] = 0; - - n = 0; - pDst = sVer; - pDst[ n++ ] = '"'; - if( *pSrc == ' ' ) - { - while( *( ++pSrc ) && n < ( int ) sizeof( sVer ) - 2 ) - pDst[ n++ ] = *pSrc; - } - pDst[ n++ ] = '"'; - pDst[ n ] = 0; - - hb_pp_AddDefine_( sOS, sVer ); -#ifdef HB_OS_UNIX - hb_strncpy( &sOS[ 12 ], "UNIX", sizeof( sOS ) - 13 ); - hb_pp_AddDefine_( sOS, sVer ); -#endif - hb_xfree( szPlatform ); - } - - { - char szResult[ 6 ]; - USHORT usHarbour = ( 256 * HB_VER_MAJOR ) + HB_VER_MINOR; - - /* - This updates __HARBOUR__ on every change of HB_VER_MAJOR / HB_VER_MINOR - HIBYTE is the HB_VER_MAJOR value and the LOBYTE is the HB_VER_MINOR value. - - The check below is to ensure that __HARBOUR__ gets the - value of 1 by default - */ - hb_snprintf( szResult, sizeof( szResult ), "%05d", ( usHarbour ? usHarbour : 1 ) ); - hb_pp_AddDefine_( "__HARBOUR__", szResult ); - } - - { - int iYear, iMonth, iDay; - char szResult[ 11 ]; - - hb_dateToday( &iYear, &iMonth, &iDay ); - hb_dateStrPut( szResult + 1, iYear, iMonth, iDay ); - szResult[ 0 ] = '"'; - szResult[ 9 ] = '"'; - szResult[ 10 ] = '\0'; - hb_pp_AddDefine_( "__DATE__", szResult ); - - hb_dateTimeStr( szResult + 1 ); - szResult[ 0 ] = '"'; - szResult[ 9 ] = '"'; - szResult[ 10 ] = '\0'; - hb_pp_AddDefine_( "__TIME__", szResult ); - } - - { - char szResult[ 11 ]; - - hb_snprintf( szResult, sizeof( szResult ), "%d", ( int ) sizeof( void * ) ); -#if defined( HB_ARCH_16BIT ) - hb_pp_AddDefine_( "__ARCH16BIT__", szResult ); -#elif defined( HB_ARCH_32BIT ) - hb_pp_AddDefine_( "__ARCH32BIT__", szResult ); -#elif defined( HB_ARCH_64BIT ) - hb_pp_AddDefine_( "__ARCH64BIT__", szResult ); -#endif - -#if defined( HB_LITTLE_ENDIAN ) - hb_pp_AddDefine_( "__LITTLE_ENDIAN__", szResult ); -#elif defined( HB_BIG_ENDIAN ) - hb_pp_AddDefine_( "__BIG_ENDIAN__", szResult ); -#elif defined( HB_PDP_ENDIAN ) - hb_pp_AddDefine_( "__PDP_ENDIAN__", szResult ); -#endif - } - -#ifdef HB_START_PROCEDURE - hb_pp_AddDefine_( "__HB_MAIN__", HB_START_PROCEDURE ); -#endif -} - -/* Table with parse warnings */ -/* NOTE: The first character stores the warning's level that triggers this - * warning. The warning's level is set by -w command line option. - */ - -int hb_pp_ParseDirective_( char * sLine ) -{ - char sDirective[ MAX_NAME ]; - char szInclude[ HB_PATH_MAX ]; - int i; - int bIgnore = 1; - char * sParse; - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_ParseDirective_(%s)", sLine ) ); - - strotrim( sLine, HB_TRUE ); - hb_pp_strocpy( sLine, sLine + 1 ); - sParse = sLine; - - i = NextName( &sLine, sDirective ); - hb_strupr( sDirective ); - - HB_SKIPTABSPACES( sLine ); - - if( i == 4 && memcmp( sDirective, "ELSE", 4 ) == 0 ) /* --- #else --- */ - { - if( hb_pp_nCondCompile == 0 ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_DIRECTIVE_ELSE, NULL, NULL ); - else if( hb_pp_nCondCompile == 1 || hb_pp_aCondCompile[ hb_pp_nCondCompile - 2 ] ) - hb_pp_aCondCompile[ hb_pp_nCondCompile - 1 ] = 1 - hb_pp_aCondCompile[ hb_pp_nCondCompile - 1 ]; - } - else if( i >= 4 && i <= 5 && memcmp( sDirective, "ENDIF", i ) == 0 ) /* --- #endif --- */ - { - if( hb_pp_nCondCompile == 0 ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_DIRECTIVE_ENDIF, NULL, NULL ); - else - hb_pp_nCondCompile--; - } - else if( i >= 4 && i <= 5 && memcmp( sDirective, "IFDEF", i ) == 0 ) - ParseIfdef( sLine, HB_TRUE ); /* --- #ifdef --- */ - - else if( i >= 4 && i <= 6 && memcmp( sDirective, "IFNDEF", i ) == 0 ) - ParseIfdef( sLine, HB_FALSE ); /* --- #ifndef --- */ - - else if( hb_pp_nCondCompile == 0 || hb_pp_aCondCompile[ hb_pp_nCondCompile - 1 ] ) - { - if( i >= 4 && i <= 7 && memcmp( sDirective, "INCLUDE", i ) == 0 ) /* --- #include --- */ - { - char cDelimChar; - - if( *sLine != '\"' && *sLine != '\'' && *sLine != '<' ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_WRONG_NAME, NULL, NULL ); - - cDelimChar = *sLine; - if( cDelimChar == '<' ) - cDelimChar = '>'; - else if( cDelimChar == '`' ) - cDelimChar = '\''; - - sLine++; - i = 0; - while( *( sLine + i ) != '\0' && *( sLine + i ) != cDelimChar ) - i++; - if( *( sLine + i ) != cDelimChar ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_WRONG_NAME, NULL, NULL ); - *( sLine + i ) = '\0'; - - if( ! OpenInclude( sLine, hb_comp_pIncludePath, hb_comp_pFileName, ( cDelimChar == '>' ), szInclude ) ) - { - if( hb_fsMaxFilesError() ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_TOO_MANY_INCLUDES, sLine, NULL ); - else - { -#if defined( __CYGWIN__ ) || defined( __IBMCPP__ ) || defined( __LCC__ ) || defined( HB_OS_WIN_CE ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_CANNOT_OPEN, sLine, "" ); -#else - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_CANNOT_OPEN, sLine, strerror( errno ) ); -#endif - } - } - } - else if( i >= 4 && i <= 6 && memcmp( sDirective, "DEFINE", i ) == 0 ) - hb_pp_ParseDefine_( sLine ); /* --- #define --- */ - - else if( i >= 4 && i <= 5 && memcmp( sDirective, "UNDEF", i ) == 0 ) - ParseUndef( sLine ); /* --- #undef --- */ - - else if( ( i >= 4 && i <= 7 && memcmp( sDirective, "COMMAND", i ) == 0 ) || ( i >= 4 && i <= 8 && memcmp( sDirective, "XCOMMAND", i ) == 0 ) ) - /* --- #command --- */ - ParseCommand( sLine, ( i == 7 ) ? HB_FALSE : HB_TRUE, HB_TRUE ); - - else - if( ( i >= 4 && i <= 9 && memcmp( sDirective, "TRANSLATE", i ) == 0 ) - || ( i >= 4 && i <= 10 && memcmp( sDirective, "XTRANSLATE", i ) == 0 ) ) - /* --- #translate --- */ - ParseCommand( sLine, ( i == 9 ) ? HB_FALSE : HB_TRUE, HB_FALSE ); - - else if( i >= 4 && i <= 6 && memcmp( sDirective, "STDOUT", i ) == 0 ) - printf( "%s\n", sLine ); /* --- #stdout --- */ - - else if( i >= 4 && i <= 5 && memcmp( sDirective, "ERROR", i ) == 0 ) - /* --- #error --- */ - hb_compGenError( NULL, hb_pp_szErrors, 'E', HB_PP_ERR_EXPLICIT, sLine, NULL ); - - else if( i == 4 && memcmp( sDirective, "LINE", 4 ) == 0 ) - return -1; - - else if( i == 6 && memcmp( sDirective, "PRAGMA", 6 ) == 0 ) - { - hb_pp_strocpy( sParse, sParse + 6 ); - bIgnore = hb_pp_ParsePragma( sParse ); /* --- #pragma --- */ - } - else - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_WRONG_DIRECTIVE, sDirective, NULL ); - } - return bIgnore; -} - -int hb_pp_ParseDefine_( char * sLine ) -{ - char defname[ MAX_NAME ], pars[ MAX_NAME + 1 ]; - int i, npars = -1; - DEFINES * lastdef; - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_ParseDefine_(%s)", sLine ) ); - - HB_SKIPTABSPACES( sLine ); - if( ISNAME( ( BYTE ) *sLine ) ) - { - char * cParams = NULL; - - NextName( &sLine, defname ); - if( *sLine == '(' ) /* If pseudofunction was found */ - { - int iParLen = 0; - int iLen; - - sLine++; - HB_SKIPTABSPACES( sLine ); - - npars = 0; - while( *sLine && *sLine != ')' ) - { - if( ISNAME( ( BYTE ) *sLine ) ) - { - NextName( &sLine, pars ); - iLen = strlen( pars ); - if( cParams == NULL ) - { - /* 'xy0' -> '~xy0' */ - cParams = ( char * ) hb_xgrab( iLen + 2 ); - } - else - { - /* '~xy0' -> '~xy,~ab0' */ - char * cPos; - - cPos = strstr( cParams, pars ); - if( cPos && ( cPos[ iLen ] == ',' || cPos[ iLen ] == '\0' ) ) - { - cPos--; - if( *cPos == '\001' ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_LABEL_DUPL_IN_DEFINE, defname, pars ); - } - cParams = ( char * ) hb_xrealloc( cParams, iParLen + iLen + 3 ); - cParams[ iParLen++ ] = ','; - cParams[ iParLen ] = '\0'; - } - cParams[ iParLen ] = '\001'; - memcpy( cParams + iParLen + 1, pars, iLen + 1 ); - iParLen += iLen + 1; - npars++; - HB_SKIPTABSPACES( sLine ); - } - else - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_LABEL_MISSING_IN_DEFINE, defname, NULL ); - - if( *sLine == ',' ) - { - sLine++; - HB_SKIPTABSPACES( sLine ); - if( *sLine == ')' ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_LABEL_MISSING_IN_DEFINE, defname, NULL ); - } - } - HB_SKIPTABSPACES( sLine ); - if( *sLine == '\0' ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_PARE_MISSING_IN_DEFINE, defname, NULL ); - - sLine++; - } - - HB_SKIPTABSPACES( sLine ); - - if( cParams ) - { - char * tmp = cParams; - char * cPos; - int iPar, iLen, iPos, iOldPos; - - iLen = strlen( sLine ); - for( i = 0; i < npars; i++ ) - { - /*1z,1y */ - cPos = strchr( tmp, ',' ); - if( cPos ) - iPar = cPos - tmp; - else - iPar = strlen( tmp ); - memcpy( pars, tmp, iPar ); - pars[ iPar ] = '\0'; - iOldPos = 0; - while( ( iPos = md_strAt( pars + 1, iPar - 1, sLine + iOldPos, HB_TRUE, HB_FALSE, HB_FALSE, MD_STR_AT_IGNORECASE ) ) != 0 ) - { - if( sLine[ iOldPos + iPos ] != '\001' ) - { - hb_pp_Stuff( pars, sLine + iOldPos + iPos - 1, iPar, iPar - 1, iLen - iPos - iOldPos ); - iLen++; - } - iOldPos += iPos + iPar; - } - if( cPos ) - tmp = cPos + 1; - } - } - lastdef = hb_pp_AddDefine_( defname, ( *sLine == '\0' ) ? NULL : sLine ); - - if( lastdef ) - { - lastdef->npars = npars; - lastdef->pars = cParams; - } - else if( cParams ) - hb_xfree( cParams ); - } - else - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_DEFINE_ABSENT, NULL, NULL ); - - return 0; -} - -DEFINES * hb_pp_AddDefine_( char * defname, char * value ) -{ - HB_BOOL isNew; - DEFINES * stdef; - int len = strlen( defname ); - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_AddDefine_(%s, %s)", defname, value ) ); - - stdef = DefSearch( defname, len, &isNew ); - - if( stdef != NULL ) - { - hb_compGenWarning( NULL, hb_pp_szWarnings, 'I', HB_PP_WARN_DEFINE_REDEF, defname, NULL ); - - if( isNew ) - { - if( stdef->pars ) - hb_xfree( stdef->pars ); - if( stdef->value ) - hb_xfree( stdef->value ); - } - else - return NULL; - } - else - { - stdef = ( DEFINES * ) hb_xgrab( sizeof( DEFINES ) ); - stdef->last = hb_pp_topDefine; - hb_pp_topDefine = stdef; - stdef->name = hb_strdup( defname ); - stdef->namelen = len; - stdef->npars = -1; - - s_kolAddDefs++; - } - - stdef->value = ( value == NULL ) ? NULL : hb_strdup( value ); - stdef->pars = NULL; - - return stdef; -} - -static int ParseUndef( char * sLine ) -{ - char defname[ MAX_NAME ]; - DEFINES * stdef; - HB_BOOL isNew; - int len; - - HB_TRACE( HB_TR_DEBUG, ( "ParseUndef(%s)", sLine ) ); - - NextWord( &sLine, defname, HB_FALSE ); - - len = strlen( defname ); - if( ( stdef = DefSearch( defname, len, &isNew ) ) != NULL ) - { - if( isNew ) - { - if( stdef->pars ) - hb_xfree( stdef->pars ); - if( stdef->value ) - hb_xfree( stdef->value ); - hb_xfree( stdef->name ); - } - stdef->pars = NULL; - stdef->value = NULL; - stdef->name = NULL; - stdef->namelen = 0; - } - - return 0; -} - -static int ParseIfdef( char * sLine, int usl ) -{ - char defname[ MAX_NAME ]; - DEFINES * stdef; - int len = 0; - - HB_TRACE( HB_TR_DEBUG, ( "ParseIfdef(%s, %d)", sLine, usl ) ); - - if( hb_pp_nCondCompile == 0 || hb_pp_aCondCompile[ hb_pp_nCondCompile - 1 ] ) - { - len = NextWord( &sLine, defname, HB_FALSE ); - if( *defname == '\0' ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_DEFINE_ABSENT, NULL, NULL ); - } - if( hb_pp_nCondCompile == s_maxCondCompile ) - { - s_maxCondCompile += 5; - hb_pp_aCondCompile = ( int * ) hb_xrealloc( hb_pp_aCondCompile, sizeof( int ) * s_maxCondCompile ); - } - if( hb_pp_nCondCompile == 0 || hb_pp_aCondCompile[ hb_pp_nCondCompile - 1 ] ) - { - if( ( ( stdef = DefSearch( defname, len, NULL ) ) != NULL && usl ) || ( stdef == NULL && ! usl ) ) - hb_pp_aCondCompile[ hb_pp_nCondCompile ] = 1; - else - hb_pp_aCondCompile[ hb_pp_nCondCompile ] = 0; - } - else - hb_pp_aCondCompile[ hb_pp_nCondCompile ] = 0; - - hb_pp_nCondCompile++; - - return 0; -} - -static DEFINES * DefSearch( char * defname, int len, HB_BOOL * isNew ) -{ - int kol = 0, j; - DEFINES * stdef = hb_pp_topDefine; - - HB_TRACE( HB_TR_DEBUG, ( "DefSearch(%s)", defname ) ); - - while( stdef != NULL ) - { - kol++; - if( stdef->name != NULL && stdef->namelen == len ) - { - for( j = 0; *( stdef->name + j ) == *( defname + j ) && *( stdef->name + j ) != '\0'; j++ ) - ; - if( *( stdef->name + j ) == *( defname + j ) ) - { - if( isNew ) - *isNew = ( s_kolAddDefs >= kol ); - return stdef; - } - } - stdef = stdef->last; - } - return NULL; -} - -static COMMANDS * ComSearch( char * cmdname, COMMANDS * stcmdStart ) -{ - COMMANDS * stcmd = ( stcmdStart ) ? stcmdStart : hb_pp_topCommand; - - HB_TRACE( HB_TR_DEBUG, ( "ComSearch(%s, %p)", cmdname, stcmdStart ) ); - - while( stcmd != NULL ) - { - int j; - - for( j = 0; ( *( stcmd->name + j ) == HB_TOUPPER( *( cmdname + j ) ) ) && - ( *( stcmd->name + j ) != '\0' ) && ( ( stcmd->com_or_xcom ) ? 1 : ( j < 4 || ISNAME( ( BYTE ) *( cmdname + j + 1 ) ) ) ); j++ ) - ; - if( ( *( stcmd->name + j ) == HB_TOUPPER( *( cmdname + j ) ) ) - || ( ! stcmd->com_or_xcom && j >= 4 && *( stcmd->name + j ) != '\0' && *( cmdname + j ) == '\0' ) ) - break; - - stcmd = stcmd->last; - } - - return stcmd; -} - -static COMMANDS * TraSearch( char * cmdname, COMMANDS * sttraStart ) -{ - int j; - COMMANDS * sttra = ( sttraStart ) ? sttraStart : hb_pp_topTranslate; - - HB_TRACE( HB_TR_DEBUG, ( "TraSearch(%s, %p)", cmdname, sttraStart ) ); - - while( sttra != NULL ) - { - for( j = 0; *( sttra->name + j ) == HB_TOUPPER( *( cmdname + j ) ) && - *( sttra->name + j ) != '\0' && ( ( sttra->com_or_xcom ) ? 1 : ( j < 4 || ISNAME( ( BYTE ) *( cmdname + j + 1 ) ) ) ); j++ ) - ; - if( *( sttra->name + j ) == HB_TOUPPER( *( cmdname + j ) ) - || ( ! sttra->com_or_xcom && j >= 4 && *( sttra->name + j ) != '\0' && *( cmdname + j ) == '\0' ) ) - break; - sttra = sttra->last; - } - return sttra; -} - -static void ParseCommand( char * sLine, HB_BOOL com_or_xcom, HB_BOOL com_or_tra ) -{ -#if ! defined( HB_PP_DEBUG_MEMORY ) - static char mpatt[ PATTERN_SIZE ]; -#else - char * mpatt = ( char * ) hb_xgrab( PATTERN_SIZE ); -#endif - char * rpatt; - - char cmdname[ MAX_NAME ]; - COMMANDS * stcmd; - int mlen, rlen; - int ipos; - - /* Ron Pinkas added 2000-12-03 */ - HB_BOOL bOk = HB_FALSE; - - HB_TRACE( HB_TR_DEBUG, ( "ParseCommand(%s, %d, %d)", sLine, com_or_xcom, com_or_tra ) ); - - HB_SKIPTABSPACES( sLine ); - ipos = 0; - - /* JFL 2000-09-19 */ - /* This was the original line as Alexander wrote it */ - /* while( *sLine != '\0' && *sLine != ' ' && *sLine != '\t' && *sLine != '<' && *sLine != '=' && ( *sLine != '(' || ipos == 0 ) ) */ - /* Now the line #xtranslate = name(.. => will be allowed */ - - /* I changed it to the following to allow < and = to be the first char within a translate or xtranslate */ - while( *sLine != '\0' && *sLine != ' ' && *sLine != '\t' - && ( *sLine != '<' || ipos == 0 ) && ( *sLine != '=' || ipos == 0 ) && ( *sLine != '(' || ipos == 0 ) ) - { - /* Ron Pinkas added 2000-01-24 */ - if( ! ISNAME( ( BYTE ) *sLine ) ) - { - if( *sLine == '[' && ipos ) - break; - - if( IS_2CHAR_OPERATOR( sLine ) ) - { - *( cmdname + ipos++ ) = *sLine++; - *( cmdname + ipos++ ) = *sLine++; - break; - } - else - { - *( cmdname + ipos++ ) = *sLine++; - break; - } - } - /* END, Ron Pinkas added 2000-01-24 */ - - *( cmdname + ipos++ ) = *sLine++; - } - *( cmdname + ipos ) = '\0'; - - if( ! ipos ) - { -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( mpatt ); -#endif - return; - } - - hb_strupr( cmdname ); - HB_SKIPTABSPACES( sLine ); - - /* Ron Pinkas added 2000-12-03 */ - ipos = 0; - while( *sLine ) - { - mpatt[ ipos++ ] = *sLine; - - if( *sLine == '=' ) - { - int i = ipos; - - sLine++; - mpatt[ i++ ] = *sLine; - - while( *sLine && ( *sLine == ' ' || *sLine == '\t' ) ) - { - sLine++; - mpatt[ i++ ] = *sLine; - } - - if( *sLine == '>' ) - { - ipos = ipos - 2; - while( mpatt[ ipos ] == ' ' || mpatt[ ipos ] == '\t' ) - { - ipos--; - } - - mpatt[ ipos + 1 ] = '\0'; - sLine++; - bOk = HB_TRUE; - break; - } - - ipos = i; - } - - sLine++; - } - /* End - Ron Pinkas added 2000-12-03 */ - - /* Ron Pinkas modified 2000-12-03 - if( (ipos = hb_strAt( "=>", 2, sLine, strlen(sLine) )) > 0 ) */ - if( bOk ) - { - /* Ron Pinkas removed 2000-12-03 - stroncpy( mpatt, sLine, ipos-1 ); */ - - mlen = strotrim( mpatt, HB_TRUE ); - - /* Ron Pinkas removed 2000-12-03 - sLine += ipos + 1; */ - - HB_SKIPTABSPACES( sLine ); - /* hb_pp_strocpy( rpatt, sLine ); */ - rpatt = sLine; - rlen = strotrim( rpatt, HB_TRUE ); - - ConvertPatterns( mpatt, mlen, rpatt, rlen ); - RemoveSlash( mpatt ); - rlen = RemoveSlash( rpatt ); - - if( com_or_tra ) - stcmd = AddCommand( cmdname ); - else - stcmd = AddTranslate( cmdname ); - - stcmd->com_or_xcom = com_or_xcom; - stcmd->mpatt = hb_strdup( mpatt ); - stcmd->value = ( rlen > 0 ) ? hb_strdup( rpatt ) : NULL; - } - else - { - sLine -= ( ipos + 1 ); - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_COMMAND_DEFINITION, cmdname, sLine ); - } -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( mpatt ); -#endif -} - -/* Remove escape characters and check '[' optional markers - */ -static int ConvertOptional( char * cpatt, int len, HB_BOOL bLeft ) -{ - int i = 0; - - while( cpatt[ i ] != '\0' ) - { - if( cpatt[ i ] == '"' || cpatt[ i ] == '\'' ) - { - char c = cpatt[ i ]; - - i++; - while( cpatt[ i ] && cpatt[ i ] != c ) - { - i++; - } - i++; - continue; /* skip "strings" */ - } - - if( cpatt[ i ] == '[' ) - { - if( i && cpatt[ i - 1 ] == '\\' ) - { - hb_pp_Stuff( "", cpatt + i - 1, 0, 1, len - i + 1 ); - len--; - continue; - } - else - { - int j = i + 1; - int iOpenBrackets = 1; - HB_BOOL bOption = HB_FALSE; - - while( cpatt[ j ] && iOpenBrackets ) - { - if( cpatt[ j ] == '[' && cpatt[ j - 1 ] != '\\' ) - iOpenBrackets++; - else if( cpatt[ j ] == ']' && cpatt[ j - 1 ] != '\\' ) - { - if( --iOpenBrackets == 0 && ( bOption || bLeft ) ) - { - cpatt[ i ] = HB_PP_OPT_START; - cpatt[ j ] = HB_PP_OPT_END; - } - } - else if( cpatt[ j ] == '<' ) - { - j++; - while( cpatt[ j ] == ' ' || cpatt[ j ] == '\t' ) - j++; - if( strchr( "*(!-{.\"", cpatt[ j ] ) || ISNAME( ( BYTE ) cpatt[ j ] ) ) - { - bOption = HB_TRUE; - continue; - } - } - else if( cpatt[ j ] == '"' || cpatt[ j ] == '\'' ) - { - char c = cpatt[ j ]; - - j++; - while( cpatt[ j ] && cpatt[ j ] != c ) - { - j++; - } - } - j++; - } - - if( iOpenBrackets ) - { - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_PATTERN_DEFINITION, cpatt + i, NULL ); - } - } - } - else if( cpatt[ i ] == ']' ) - { - if( i && cpatt[ i - 1 ] == '\\' ) - { - hb_pp_Stuff( "", cpatt + i - 1, 0, 1, len - i + 1 ); - len--; - continue; - } - } - i++; - } - - return len; -} - -static void RemoveOptional( char * cpatt ) -{ - int i = 0; - int len = strlen( cpatt ); - int iOpenBra = 0; - - while( cpatt[ i ] != '\0' ) - { - if( cpatt[ i ] == '"' || cpatt[ i ] == '\'' ) - { - char c = cpatt[ i++ ]; - - while( cpatt[ i ] && cpatt[ i ] != c ) - { - i++; - } - if( cpatt[ i ] ) - i++; - continue; /* skip "strings" */ - } - if( cpatt[ i ] == '[' ) - { - i++; - iOpenBra++; - while( cpatt[ i ] && iOpenBra ) - { - if( cpatt[ i ] == '[' ) - iOpenBra++; - else if( cpatt[ i ] == ']' ) - iOpenBra--; - i++; - } - continue; /* skip [strings] */ - } - - if( cpatt[ i ] == HB_PP_OPT_START || cpatt[ i ] == HB_PP_OPT_END ) - { - hb_pp_Stuff( "", cpatt + i, 0, 1, len - i + 1 ); - len--; - } - else - i++; - } -} - - -/* ConvertPatterns() - * Converts result pattern in #command and #translate to inner format - */ - -static void ConvertPatterns( char * mpatt, int mlen, char * rpatt, int rlen ) -{ - int i = 0, ipos, ifou; - int explen, rmlen; - char exppatt[ MAX_NAME ], expreal[ 5 ] = " 0"; - char lastchar = '@', exptype; - char * ptr, * ptrtmp; - - HB_TRACE( HB_TR_DEBUG, ( "ConvertPatterns(%s, %d, %s, %d)", mpatt, mlen, rpatt, rlen ) ); - - expreal[ 0 ] = HB_PP_MATCH_MARK; - mlen = ConvertOptional( mpatt, mlen, HB_TRUE ); /* left pattern */ - rlen = ConvertOptional( rpatt, rlen, HB_FALSE ); /* right pattern */ - - while( *( mpatt + i ) != '\0' ) - { - if( mpatt[ i ] == '"' || mpatt[ i ] == '\'' ) - { - char c = mpatt[ i ]; - - i++; - while( mpatt[ i ] && mpatt[ i ] != c ) - { - i++; - } - i++; - continue; /* skip "strings" */ - } - - if( *( mpatt + i ) == '<' ) - { - if( i && mpatt[ i - 1 ] == '\\' ) - { - i++; - continue; - } - - /* Drag match marker, determine it type */ - explen = 0; - ipos = i; - i++; - exptype = '0'; - while( *( mpatt + i ) == ' ' || *( mpatt + i ) == '\t' ) - i++; - if( *( mpatt + i ) == '*' ) /* Wild match marker */ - { - exptype = '3'; - i++; - } - else if( *( mpatt + i ) == '(' ) /* Extended expression match marker */ - { - exptype = '4'; - i++; - } - else if( *( mpatt + i ) == '!' ) /* Minimal expression match marker */ - { - exptype = '5'; - i++; - } - ptr = mpatt + i; - while( *ptr != '>' ) - { - if( *ptr == '\0' || *ptr == '<' || *ptr == '[' || *ptr == ']' ) - { - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_PATTERN_DEFINITION, NULL, NULL ); - return; - } - ptr++; - } - - while( *( mpatt + i ) != '>' ) - { - if( *( mpatt + i ) == ',' ) /* List match marker */ - { - exptype = '1'; - while( *( mpatt + i ) != '>' ) - i++; - break; - } - else if( *( mpatt + i ) == ':' ) /* Restricted match marker */ - { - exptype = '2'; - *( mpatt + i-- ) = ' '; - break; - } - if( *( mpatt + i ) != ' ' && *( mpatt + i ) != '\t' ) - *( exppatt + explen++ ) = *( mpatt + i ); - i++; - } - - if( exptype == '3' ) - { - if( *( exppatt + explen - 1 ) == '*' ) - explen--; - else - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_PATTERN_DEFINITION, NULL, NULL ); - } - else if( exptype == '4' ) - { - if( *( exppatt + explen - 1 ) == ')' ) - explen--; - else - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_PATTERN_DEFINITION, NULL, NULL ); - } - else if( exptype == '5' ) - { - if( *( exppatt + explen - 1 ) == '!' ) - explen--; - else - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_PATTERN_DEFINITION, NULL, NULL ); - } - - rmlen = i - ipos + 1; - /* Convert match marker into inner format */ - lastchar = ( lastchar != 'Z' ) ? ( ( char ) ( ( unsigned int ) lastchar + 1 ) ) : 'a'; - expreal[ 1 ] = lastchar; - expreal[ 2 ] = exptype; - hb_pp_Stuff( expreal, mpatt + ipos, 4, rmlen, mlen - ipos ); - mlen += 4 - rmlen; - i += 4 - rmlen; - - /* Look for appropriate result markers */ - ptr = rpatt; - while( ( ifou = hb_strAt( exppatt, explen, ptr, rlen - ( ptr - rpatt ) ) ) > 0 ) - { - /* Convert result marker into inner format */ - ifou--; - ptr += ifou; - ptrtmp = ptr + 1; - rmlen = explen; - exptype = '0'; /* regular result marker */ - do - { - ptr--; - rmlen++; - ifou--; - if( *ptr == '<' ) - continue; - else if( *ptr == '\"' ) - exptype = '2'; /* normal stringify result marker */ - else if( *ptr == '(' ) - exptype = '3'; /* Smart stringify result marker */ - else if( *ptr == '{' ) - exptype = '4'; /* Blockify result marker */ - else if( *ptr == '.' ) - exptype = '5'; /* Logify result marker */ - else if( *ptr == '-' ) - exptype = '6'; /* ommit (remove) result marker */ - else if( *ptr == ' ' || *ptr == '\t' ) - continue; - else - ifou = -1; - } - while( ifou >= 0 && *ptr != '<' && *( ptr - 1 ) != '\\' ); - - if( ifou >= 0 && *ptr == '<' ) - { - ptr += rmlen++; - while( *ptr != '\0' && *ptr != '>' && *( ptr - 1 ) != '\\' ) - { - if( *ptr != ' ' && *ptr != '\t' && *ptr != '\"' && *ptr != ')' && *ptr != '}' && *ptr != '.' && *ptr != '-' ) - { - ifou = -1; - break; - } - rmlen++; - ptr++; - } - if( ifou >= 0 && *ptr == '>' ) - { - ptr -= rmlen; - ptr++; - if( exptype == '0' && *( ptr - 1 ) == '#' && *( ptr - 2 ) != '\\' ) - { - exptype = '1'; /* dumb stringify result marker */ - ptr--; - rmlen++; - } - expreal[ 2 ] = exptype; - hb_pp_Stuff( expreal, ptr, 4, rmlen, rlen + ( rpatt - ptr ) ); - rlen += 4 - rmlen; - } - else - ptr = ptrtmp; - } - else - ptr = ptrtmp; - } - } - i++; - } -} - -static COMMANDS * AddCommand( char * cmdname ) -{ - COMMANDS * stcmd; - - HB_TRACE( HB_TR_DEBUG, ( "AddCommand(%s)", cmdname ) ); - - stcmd = ( COMMANDS * ) hb_xgrab( sizeof( COMMANDS ) ); - stcmd->last = hb_pp_topCommand; - hb_pp_topCommand = stcmd; - stcmd->name = hb_strdup( cmdname ); - stcmd->namelen = strlen( cmdname ); - s_kolAddComs++; - return stcmd; -} - -static COMMANDS * AddTranslate( char * traname ) -{ - COMMANDS * sttra; - - HB_TRACE( HB_TR_DEBUG, ( "AddTranslate(%s)", traname ) ); - - sttra = ( COMMANDS * ) hb_xgrab( sizeof( COMMANDS ) ); - sttra->last = hb_pp_topTranslate; - hb_pp_topTranslate = sttra; - sttra->name = hb_strdup( traname ); - sttra->namelen = strlen( traname ); - s_kolAddTras++; - return sttra; -} - -int hb_pp_ParseExpression( char * sLine, char * sOutLine, HB_BOOL bSplitLines ) -{ -#if ! defined( HB_PP_DEBUG_MEMORY ) - static char rpatt[ PATTERN_SIZE ]; -#else - char * rpatt = ( char * ) hb_xgrab( PATTERN_SIZE ); -#endif - char sToken[ MAX_NAME ]; - char * ptri, * ptro, * ptrb; - int lenToken, i, ipos, isdvig, lens; - int ifou; - int rezDef, rezTra, rezCom; - unsigned int kolpass = 0; - DEFINES * stdef; - COMMANDS * stcmd; - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_ParseExpression(%s, %s)", sLine, sOutLine ) ); - - do - { - strotrim( sLine, HB_FALSE ); - - rezDef = 0; - rezTra = 0; - rezCom = 0; - isdvig = 0; - - do - { - ptro = sOutLine; - ptri = sLine + isdvig; - if( bSplitLines ) - ipos = md_strAt( ";", 1, ptri, HB_TRUE, HB_FALSE, HB_FALSE, MD_STR_AT_IGNORECASE ); - else - ipos = 0; - - if( ipos > 0 ) - { - *( ptri + ipos - 1 ) = '\0'; - } - - HB_SKIPTABSPACES( ptri ); - - if( *ptri == '#' ) - { - int bIgnore; - - hb_strncpy( rpatt, ptri, PATTERN_SIZE - 1 ); - bIgnore = hb_pp_ParseDirective_( rpatt ); - - if( ipos > 0 ) - { - ipos--; - *( sLine + isdvig + ipos - 1 ) = ';'; - *( sLine + isdvig + ipos ) = ' '; - } - - lens = strlen( sLine + isdvig ); - if( bIgnore ) - hb_pp_Stuff( " ", sLine + isdvig, 0, ( ipos ) ? ipos : lens, lens ); - else - hb_pp_Stuff( rpatt, sLine + isdvig, strlen( rpatt ), ( ipos ) ? ipos : lens, lens ); - - if( ipos > 0 ) - { - ipos = 1; - } - } - else /* Look for macros from #define */ - { - while( ( lenToken = NextName( &ptri, sToken ) ) > 0 ) - { -#if 0 - printf( "Token: >%s< Line: >%s<\n", sToken, sLine ); -#endif - - if( ( stdef = DefSearch( sToken, lenToken, NULL ) ) != NULL ) - { - ptrb = ptri - lenToken; - - if( ( i = WorkDefine( &ptri, ptro, stdef ) ) >= 0 ) - { - rezDef++; - lens = strlen( ptrb ); - - if( ipos > 0 ) - { - *( ptrb + lens ) = ';'; - lens += strlen( ptrb + lens + 1 ); - } - - hb_pp_Stuff( ptro, ptrb, i, ptri - ptrb, lens + 1 ); - if( ipos > 0 ) - { - ipos += i - ( ptri - ptrb ); - *( sLine + isdvig + ipos - 1 ) = '\0'; - } - ptri += i - ( ptri - ptrb ); - } - } - } - - if( rezDef == 0 ) - { - /* Look for definitions from #translate */ - stcmd = hb_pp_topTranslate; - while( stcmd != NULL ) - { - ptri = sLine + isdvig; - lenToken = stcmd->namelen; - - while( ( ifou = md_strAt( stcmd->name, lenToken, ptri, HB_TRUE, HB_FALSE, HB_FALSE, MD_STR_AT_USESUBCASE ) ) > 0 ) - { - ptri += ifou - 1; - - if( ( i = WorkTranslate( ptri + lenToken, ptro, stcmd, &lens ) ) >= 0 ) - { - lens += lenToken; - while( lens > 0 && ( *( ptri + lens - 1 ) == ' ' || *( ptri + lens - 1 ) == '\t' ) ) - { - lens--; - } - - if( ipos > 0 ) - { - *( sLine + isdvig + ipos - 1 ) = ';'; - } - - hb_pp_Stuff( ptro, ptri, i, lens, strlen( ptri ) ); - rezTra = 1; - - if( ipos > 0 ) - { - ipos += i - lens; - *( sLine + isdvig + ipos - 1 ) = '\0'; - } - - ptri += i; - } - else - { - ptri += lenToken; - } - } - - stcmd = stcmd->last; - } - } /* rezDef == 0 */ - - /* Look for definitions from #command */ - /* JFL ! Was 3 but insufficient in most cases */ - /* I know this is a new hardcoded limit ... any better idea's welcome */ - if( rezDef == 0 && rezTra == 0 && kolpass < 20 ) - { - ptri = sLine + isdvig; - HB_SKIPTABSPACES( ptri ); - - if( ISNAME( ( BYTE ) *ptri ) ) - { - NextName( &ptri, sToken ); - } - else - { - /* Ron Pinkas commented 2000-01-24 - i = 0; - while( *ptri != ' ' && *ptri != '\t' && *ptri != '\0' && *ptri != '\"' && *ptri != '\'' && *ptri != '(' && !ISNAME( ( BYTE ) *ptri ) ) - { - *(sToken+i) = *ptri++; - i++; - } - *(sToken+i) = '\0'; - */ - - /* Ron Pinkas added 2000-01-24 */ - if( IS_2CHAR_OPERATOR( ptri ) ) - { - sToken[ 0 ] = *ptri++; - sToken[ 1 ] = *ptri++; - sToken[ 2 ] = '\0'; - } - else - { - sToken[ 0 ] = *ptri++; - sToken[ 1 ] = '\0'; - } - /* END, Ron Pinkas added 2000-01-24 */ - } - - HB_SKIPTABSPACES( ptri ); - - if( ( *ptri == '\0' - || ( *ptri != '=' - && ( ! IsInStr( *ptri, ":/+*-%^" ) - || *( ptri + 1 ) != '=' ) && ( *ptri != '-' - || *( ptri + 1 ) != '>' ) ) ) && ( stcmd = ComSearch( sToken, NULL ) ) != NULL ) - { - ptro = sOutLine; - - i = WorkCommand( ptri, ptro, stcmd ); - ptri = sLine + isdvig; - - if( ipos > 0 ) - { - *( ptri + ipos - 1 ) = ';'; - } - - if( i >= 0 ) - { - if( isdvig + ipos > 0 ) - { - lens = strlen( sLine + isdvig ); - hb_pp_Stuff( ptro, sLine + isdvig, i, ( ipos ) ? ipos - 1 : lens, lens ); - - if( ipos > 0 ) - { - ipos = i + 1; - } - } - else - { - memcpy( sLine, sOutLine, i + 1 ); - } - } - - rezCom = 1; - } - else if( ipos > 0 ) - { - *( sLine + isdvig + ipos - 1 ) = ';'; - } - } - else if( ipos > 0 ) - { - *( sLine + isdvig + ipos - 1 ) = ';'; - } - } - - isdvig += ipos; - } - while( ipos != 0 ); - - kolpass++; - - if( kolpass > hb_pp_MaxTranslateCycles && ( rezDef || rezTra || rezCom ) ) - { - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_RECURSE, NULL, NULL ); - break; - } - } - while( rezDef || rezTra || rezCom ); - - RemoveOptional( sLine ); - if( *sOutLine ) - { - RemoveOptional( sOutLine ); - } - -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( rpatt ); -#endif - return 0; -} - -static int WorkDefine( char ** ptri, char * ptro, DEFINES * stdef ) -{ - int npars, lens; - char * ptr; - - HB_TRACE( HB_TR_DEBUG, ( "WorkDefine(%p, %s, %p)", ptri, ptro, stdef ) ); - - if( stdef->npars < 0 ) - { - lens = hb_pp_strocpy( ptro, stdef->value ); - } - else - { - HB_SKIPTABSPACES( *ptri ); - - if( **ptri == '(' ) - { - npars = 0; - ptr = *ptri; - - do - { - ptr++; - - if( NextParm( &ptr, NULL ) > 0 ) - { - npars++; - } - } - while( *ptr != ')' && *ptr != '\0' ); - - if( *ptr == ')' && stdef->npars == npars ) - { - /* Ron Pinkas added 2000-11-21 */ - char * pTmp = ptr + 1; - - while( *pTmp && ( *pTmp == ' ' || *pTmp == '\t' ) ) - { - pTmp++; - } - if( *pTmp == '[' ) - { - s_bArray = HB_TRUE; - } - /* END - Ron Pinkas added 2000-11-21 */ - - lens = WorkPseudoF( ptri, ptro, stdef ); - } - else - { - return -1; - } - } - else - { - return -1; - } - } - - return lens; -} - -static int WorkPseudoF( char ** ptri, char * ptro, DEFINES * stdef ) -{ - char parfict[ MAX_NAME ], * ptrreal; - char * ptrb; - int ipos, ifou, ibeg; - int lenfict, lenreal, lenres; - - HB_TRACE( HB_TR_DEBUG, ( "WorkPseudoF(%p, %s, %p)", ptri, ptro, stdef ) ); - - lenres = hb_pp_strocpy( ptro, stdef->value ); /* Copying value of macro to destination string */ - - if( stdef->pars ) - { - ipos = 0; - ibeg = 0; - - for(;; ) /* Parsing through parameters */ - { /* in macro definition */ - if( *( stdef->pars + ipos ) == ',' || *( stdef->pars + ipos ) == '\0' ) - { - *( parfict + ipos - ibeg ) = '\0'; - lenfict = ipos - ibeg; - - if( **ptri != ')' ) - { - ( *ptri )++; /* Get next real parameter */ - HB_SKIPTABSPACES( *ptri ); - ptrreal = *ptri; - lenreal = NextParm( ptri, NULL ); - - ptrb = ptro; - while( ( ifou = hb_strAt( parfict, lenfict, ptrb, lenres - ( ptrb - ptro ) ) ) > 0 ) - { - ptrb = ptrb + ifou - 1; - if( ! ISNAME( ( BYTE ) *( ptrb - 1 ) ) && ! ISNAME( ( BYTE ) *( ptrb + lenfict ) ) ) - { - hb_pp_Stuff( ptrreal, ptrb, lenreal, lenfict, lenres + ( ptro - ptrb ) ); - lenres += lenreal - lenfict; - ptrb += lenreal; - } - else - { - ptrb++; - } - } - - ibeg = ipos + 1; - } - } - else - { - *( parfict + ipos - ibeg ) = *( stdef->pars + ipos ); - } - - if( *( stdef->pars + ipos ) == '\0' ) - { - break; - } - - ipos++; - } - } - else - { - while( **ptri != ')' ) - { - ( *ptri )++; - } - } - - ( *ptri )++; - - return lenres; -} - -static int WorkCommand( char * ptri, char * ptro, COMMANDS * stcmd ) -{ - int rez; - int lenres; - char * ptrmp; - char * sToken = stcmd->name; - - HB_TRACE( HB_TR_DEBUG, ( "WorkCommand(%s, %s, %p)", ptri, ptro, stcmd ) ); - - do - { - lenres = hb_pp_strocpy( ptro, stcmd->value ); /* Copying result pattern */ - ptrmp = stcmd->mpatt; /* Pointer to a match pattern */ - s_Repeate = 0; - s_groupchar = '@'; - rez = CommandStuff( ptrmp, ptri, ptro, &lenres, HB_TRUE, stcmd->com_or_xcom ); - - stcmd = stcmd->last; - if( rez < 0 && stcmd != NULL ) - stcmd = ComSearch( sToken, stcmd ); - } - while( rez < 0 && stcmd != NULL ); - - *( ptro + lenres ) = '\0'; - if( rez >= 0 ) - { - return lenres; - } - return -1; -} - -static int WorkTranslate( char * ptri, char * ptro, COMMANDS * sttra, int * lens ) -{ - int rez; - int lenres; - char * ptrmp; - char * sToken = sttra->name; - - HB_TRACE( HB_TR_DEBUG, ( "WorkTranslate(%s, %s, %p, %p)", ptri, ptro, sttra, lens ) ); - - do - { - lenres = hb_pp_strocpy( ptro, sttra->value ); - ptrmp = sttra->mpatt; - s_Repeate = 0; - s_groupchar = '@'; - rez = CommandStuff( ptrmp, ptri, ptro, &lenres, HB_FALSE, sttra->com_or_xcom ); - - sttra = sttra->last; - - if( rez < 0 && sttra != NULL ) - { - sttra = TraSearch( sToken, sttra ); - } - } - while( rez < 0 && sttra != NULL ); - - *( ptro + lenres ) = '\0'; - - if( rez >= 0 ) - { - *lens = rez; - return lenres; - } - - return -1; -} - -#define MAX_OPTIONALS 64 - -static int CommandStuff( char * ptrmp, char * inputLine, char * ptro, int * lenres, HB_BOOL com_or_tra, HB_BOOL com_or_xcom ) -{ - HB_BOOL endTranslation = HB_FALSE; - int ipos; - char * lastopti[ MAX_OPTIONALS ], * strtopti = NULL, * strtptri = NULL; - char * ptri = inputLine, * ptr, tmpname[ MAX_NAME ]; - int isWordInside = 0; - char szMatch[ 2 ]; - char * cSkipped[ MAX_OPTIONALS ]; - int iSkipped = 0; - - /* - printf( "MP: >%s<\nIn: >%s<\n", ptrmp, ptri ); - */ - - HB_TRACE( HB_TR_DEBUG, ( "CommandStuff(%s, %s, %s, %p, %d, %d)", ptrmp, inputLine, ptro, lenres, com_or_tra, com_or_xcom ) ); - - s_numBrackets = 0; - HB_SKIPTABSPACES( ptri ); - if( ptrmp == NULL ) - { - if( *ptri != '\0' ) - return -1; - } - else - { - while( *ptri != '\0' && ! endTranslation ) - { - HB_SKIPTABSPACES( ptrmp ); - if( *ptrmp == HB_PP_OPT_START && ! s_numBrackets && ! strtopti ) - { - /* Store start position of outermost optional in pattern */ - strtopti = ptrmp; - } - if( ! s_numBrackets && strtopti && strtptri != ptri && - ( ISNAME( ( BYTE ) *ptri ) || *ptri == '&' ) ) - { - /* Input stream starts with a word or macro -store the position - * which matches the outermost optional in pattern - */ - strtptri = ptri; - ptrmp = strtopti; - ptr = ptri; - ipos = NextName( &ptr, tmpname ); /* get starting keyword */ - ipos = md_strAt( tmpname, ipos, strtopti, HB_TRUE, HB_TRUE, HB_TRUE, MD_STR_AT_USESUBCASE ); - if( ipos && TestOptional( strtopti, strtopti + ipos - 2 ) ) - { - /* the keyword from input is found in the pattern */ - ptr = PrevSquare( strtopti + ipos - 2, strtopti, NULL ); - if( ptr ) - ptrmp = ptr; - if( ptr != strtopti ) - { - cSkipped[ iSkipped++ ] = strtopti; - } - } - } - - switch( *ptrmp ) - { - case HB_PP_OPT_START: - if( ! s_numBrackets ) - isWordInside = 0; - s_numBrackets++; - s_aIsRepeate[ s_Repeate ] = 0; - lastopti[ s_Repeate++ ] = ptrmp; - ptrmp++; - if( ! CheckOptional( ptrmp, ptri, ptro, lenres, com_or_tra, com_or_xcom ) ) - { - SkipOptional( &ptrmp ); - } - break; - - case HB_PP_OPT_END: - if( s_Repeate ) - { - s_Repeate--; - if( s_aIsRepeate[ s_Repeate ] ) - { - if( ISNAME( ( BYTE ) *ptri ) ) - { - ptr = ptri; - ipos = NextName( &ptr, tmpname ); - ipos = md_strAt( tmpname, ipos, ptrmp, HB_TRUE, HB_TRUE, HB_TRUE, MD_STR_AT_USESUBCASE ); - if( ipos && TestOptional( ptrmp + 1, ptrmp + ipos - 2 ) ) - { - ptr = PrevSquare( ptrmp + ipos - 2, ptrmp + 1, NULL ); - if( ! ptr || CheckOptional( ptrmp + 1, ptri, ptro, lenres, com_or_tra, com_or_xcom ) ) - { - ptrmp = lastopti[ s_Repeate ]; - ptrmp++; - s_Repeate++; - SkipOptional( &ptrmp ); - s_numBrackets++; - ptrmp++; - strtptri = ptri; - } - else - ptrmp = lastopti[ s_Repeate ]; - } - else - { - ptrmp = lastopti[ s_Repeate ]; - } - } - else - { - ptrmp = lastopti[ s_Repeate ]; - } - } - else - { - if( ! isWordInside ) - strtopti = NULL; - ptrmp++; - } - s_numBrackets--; - } - else - { - if( ! isWordInside ) - strtopti = NULL; - s_numBrackets--; - ptrmp++; - } - break; - - case ',': - if( s_numBrackets == 1 ) - isWordInside = 1; - if( ! s_numBrackets ) - strtopti = NULL; - if( *ptri == ',' ) - { - ptrmp++; - ptri++; - } - else - { - if( s_numBrackets ) - { - SkipOptional( &ptrmp ); - } - else - return -1; - } - break; - - case HB_PP_MATCH_MARK: /* Match marker */ - if( ! s_numBrackets ) - strtopti = NULL; - if( s_numBrackets == 1 && *( ptrmp + 2 ) == '2' ) - isWordInside = 1; /* restricted match marker */ - if( ! WorkMarkers( &ptrmp, &ptri, ptro, lenres, com_or_tra, com_or_xcom ) ) - { - if( s_numBrackets ) - { - SkipOptional( &ptrmp ); - } - else - return -1; - } - break; - - case '\0': - if( iSkipped ) - { - ptrmp = cSkipped[ --iSkipped ]; - break; - } - if( com_or_tra ) - return -1; - else - endTranslation = HB_TRUE; - break; - - default: /* Key word */ - if( s_numBrackets == 1 ) - isWordInside = 1; - if( ! s_numBrackets ) - strtopti = NULL; - ptr = ptri; - if( *ptri == ',' || truncmp( &ptri, &ptrmp, ! com_or_xcom ) ) - { - ptri = ptr; - if( s_numBrackets ) - { - SkipOptional( &ptrmp ); - } - else - return -1; - } - } - HB_SKIPTABSPACES( ptri ); - } - ; - } - - if( *ptrmp != '\0' ) - { - if( s_Repeate ) - { - s_Repeate = 0; - ptrmp = lastopti[ 0 ]; - } - s_numBrackets = 0; - do - { - HB_SKIPTABSPACES( ptrmp ); - if( *ptrmp != '\0' ) - switch( *ptrmp ) - { - case HB_PP_OPT_START: - ptrmp++; - SkipOptional( &ptrmp ); - ptrmp++; - break; - case HB_PP_OPT_END: - ptrmp++; - break; - default: - return -1; - } - } - while( *ptrmp != '\0' ); - } - - szMatch[ 0 ] = HB_PP_MATCH_MARK; - szMatch[ 1 ] = '\0'; - SearnRep( szMatch, "", 0, ptro, lenres ); - *( ptro + *lenres ) = '\0'; - - if( com_or_tra ) - return 1; - else - return ptri - inputLine; -} - -static int RemoveSlash( char * cpatt ) -{ - int i = 0; - int lenres = strlen( cpatt ); - - while( cpatt[ i ] != '\0' ) - { - if( cpatt[ i ] == '"' || cpatt[ i ] == '\'' ) - { - char c = cpatt[ i ]; - - i++; - while( cpatt[ i ] && cpatt[ i ] != c ) - { - i++; - } - i++; - continue; /* skip "strings" */ - } - if( cpatt[ i ] == '[' ) - { - i++; - while( cpatt[ i ] && cpatt[ i ] != ']' ) - { - i++; - } - i++; - continue; /* skip [strings] */ - } - - if( cpatt[ i ] == '\\' ) - { - hb_pp_Stuff( "", cpatt + i, 0, 1, lenres - i + 1 ); - lenres--; - i++; - } - else - i++; - } - return lenres; -} - -static int WorkMarkers( char ** ptrmp, char ** ptri, char * ptro, int * lenres, HB_BOOL com_or_tra, HB_BOOL com_or_xcom ) -{ -#if ! defined( HB_PP_DEBUG_MEMORY ) - char exppatt[ MAX_NAME ]; -#else - char * exppatt = ( char * ) hb_xgrab( MAX_NAME ); -#endif - int lenreal = 0, maxlenreal, lenpatt; - int rezrestr, ipos, nBra; - char * ptr, * ptrtemp; - - HB_TRACE( HB_TR_DEBUG, ( "WorkMarkers(%p, %p, %s, %p)", ptrmp, ptri, ptro, lenres ) ); - - - maxlenreal = HB_PP_STR_SIZE; - if( s_expreal == NULL ) - s_expreal = ( char * ) hb_xgrab( maxlenreal + 1 ); - - /* Copying a match pattern to 'exppatt' */ - lenpatt = stroncpy( exppatt, *ptrmp, 4 ); - *ptrmp += 4; - - HB_SKIPTABSPACES( *ptrmp ); - - /* JFL removed 12/11/2001 to allow param like (,,3) as allowed by clipper */ - /* - if( **ptri == ',' ) - { - if( s_numBrackets ) - { - return 0; - } - } */ - - ptrtemp = *ptrmp; - - if( *( exppatt + 2 ) != '2' && *ptrtemp == HB_PP_OPT_END ) - { - ptrtemp++; - HB_SKIPTABSPACES( ptrtemp ); - - while( *ptrtemp == HB_PP_OPT_START ) - { - nBra = 0; - ptrtemp++; - - while( ( *ptrtemp != HB_PP_OPT_END || nBra ) && *ptrtemp != '\0' ) - { - if( *ptrtemp == HB_PP_OPT_START ) - { - nBra++; - } - else if( *ptrtemp == HB_PP_OPT_END ) - { - nBra--; - } - ptrtemp++; - } - ptrtemp++; - - HB_SKIPTABSPACES( ptrtemp ); - } - } - - if( *( exppatt + 2 ) != '2' && *ptrtemp != HB_PP_MATCH_MARK - && *ptrtemp != ',' && *ptrtemp != HB_PP_OPT_START && *ptrtemp != HB_PP_OPT_END && *ptrtemp != '\0' ) - { - lenreal = strincpy( s_expreal, ptrtemp ); - - if( ( ipos = md_strAt( s_expreal, lenreal, *ptri, HB_TRUE, HB_TRUE, HB_FALSE, MD_STR_AT_USESUBCASE ) ) > 0 ) - { - if( ptrtemp > *ptrmp ) - { - if( ipos == 1 ) - { - if( s_numBrackets ) - { -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( exppatt ); -#endif - return 0; - } - } - else - { - maxlenreal = ipos; - lenreal = 0; - } - } - else - { - /* - printf( "\nFound: '%s' Len: %i In: '%s' At: %i \n", s_expreal, lenreal, *ptri, ipos ); - */ - - lenreal = stroncpy( s_expreal, *ptri, ipos - 1 ); - - if( ipos > 1 ) - { - if( *( exppatt + 2 ) == '5' ) /* ---- Minimal match marker */ - { - if( IsIdentifier( s_expreal ) ) - { - *ptri += lenreal; - } - } - else if( isExpres( s_expreal, *( exppatt + 2 ) == '1' ) ) - { - *ptri += lenreal; - } - } - else - { - if( s_numBrackets ) - { -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( exppatt ); -#endif - return 0; - } - else - { - lenreal = 0; - } - } - } - } - else - { - if( s_numBrackets ) - { -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( exppatt ); -#endif - return 0; - } - else - { - lenreal = 0; - } - } - } - - if( *( exppatt + 2 ) == '4' ) /* ---- extended match marker */ - { - if( ! lenreal ) - lenreal = getExpReal( s_expreal, ptri, HB_FALSE, maxlenreal, HB_FALSE, HB_FALSE ); - { - SearnRep( exppatt, s_expreal, lenreal, ptro, lenres ); - } - } - else if( *( exppatt + 2 ) == '3' ) /* ---- wild match marker */ - { - lenreal = hb_pp_strocpy( s_expreal, *ptri ); - *ptri += lenreal; - SearnRep( exppatt, s_expreal, lenreal, ptro, lenres ); - } - else if( *( exppatt + 2 ) == '2' ) /* ---- restricted match marker */ - { - while( **ptrmp != '>' ) - { - *( exppatt + lenpatt++ ) = *( ( *ptrmp )++ ); - } - *( exppatt + lenpatt ) = '\0'; - ( *ptrmp )++; - - ptr = exppatt + 4; - rezrestr = 0; - while( *ptr != '\0' ) - { - if( *ptr == '&' ) - { - /* rglab: Thu Sep 2 21:30:07 2004 - * Special Clipper undocumented restricted match marker: - * - * Clipper accepts the macro variable only here. - * eg. - * SET FILTER TO &var. - * SET FILTER TO &var.foo - * SET FILTER TO &(var) - * - * Notice that any expression that starts from the macro - * variable is not valid for this marker - * eg. - * SET FILTER TO &var+1 - * the above command is preprocessed by a general rule - * that is using smart match marker <(x)> - */ - if( **ptri == '&' ) - { - char * ptrmacro = *ptri; /* save current position */ - - *ptri += 1; - HB_SKIPTABSPACES( *ptri ); - if( **ptri == '(' ) /* macro expression &( expr ) */ - { - lenreal = getExpReal( s_expreal + 2, ptri, HB_TRUE, maxlenreal, HB_FALSE, HB_TRUE ); - if( ! ( **ptri == '\0' || **ptri == ' ' ) && com_or_tra ) - break; - s_expreal[ 0 ] = '&'; - s_expreal[ 1 ] = '('; - lenreal += 3; - s_expreal[ lenreal - 1 ] = ')'; - SearnRep( exppatt, s_expreal, lenreal, ptro, lenres ); - rezrestr = 1; - } - else - { - lenreal = IsMacroVar( *ptri, com_or_tra ); - if( lenreal > 0 ) - { - if( ! com_or_tra ) - { - /* translate */ - hb_strncpy( s_expreal + 1, *ptri, HB_PP_STR_SIZE - 1 ); - s_expreal[ 0 ] = '&'; - s_expreal[ lenreal + 1 ] = '\0'; - *ptri += lenreal; - SearnRep( exppatt, s_expreal, lenreal + 1, ptro, lenres ); - rezrestr = 1; - break; - } - else - { - char * ptmp = *ptri + lenreal; - HB_SKIPTABSPACES( ptmp ); - if( ! IsInStr( *ptmp, ":/+*-%^=<>[{.," ) || - ( *ptmp && ptmp[ 0 ] == '+' && ptmp[ 1 ] == '+' ) || - ( *ptmp && ptmp[ 0 ] == '-' && ptmp[ 1 ] == '-' ) ) - { - /* NOTE: - * Clipper usually bounds to left the '++' and '--' - * operators which means that the following code: - * #command XCALL => ( ) - * XCALL &a ++b - * is preprocessed into: - * &a( ++b ) - * However if used with restricted macro match marker: - * #command MCALL => ( ) - * then - * MCALL &a ++b - * is preprocessed into: - * &a ++( b ) - */ - hb_strncpy( s_expreal + 1, *ptri, HB_PP_STR_SIZE - 1 ); - s_expreal[ 0 ] = '&'; - s_expreal[ lenreal + 1 ] = '\0'; - *ptri += lenreal; - SearnRep( exppatt, s_expreal, lenreal + 1, ptro, lenres ); - rezrestr = 1; - break; - } - else - { -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( exppatt ); -#endif - *ptri = ptrmacro; /* restore '&' char */ - return 0; - } - } - } - else - { -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( exppatt ); -#endif - *ptri -= 1; /* restore '&' char */ - return 0; - } - } - break; - } - else - { - ptr++; - } - } - else - { - HB_SKIPTABSPACES( ptr ); - /* Comparing real parameter and restriction value */ - ptrtemp = ptr; - if( ! strincmp( *ptri, &ptr, ! com_or_xcom ) ) - { - lenreal = stroncpy( s_expreal, *ptri, ( ptr - ptrtemp ) ); - *ptri += lenreal; - SearnRep( exppatt, s_expreal, lenreal, ptro, lenres ); - rezrestr = 1; - break; - } - else - { - while( *ptr != ',' && *ptr != '\0' ) - { - ptr++; - } - if( *ptr == ',' ) - { - ptr++; - } - } - } - } - if( rezrestr == 0 ) - { - /* If restricted match marker doesn't correspond to real parameter */ -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( exppatt ); -#endif - return 0; - } - } - else if( *( exppatt + 2 ) == '1' ) /* ---- list match marker */ - { - if( ! lenreal ) - { - lenreal = getExpReal( s_expreal, ptri, HB_TRUE, maxlenreal, HB_FALSE, HB_FALSE ); - } - - if( lenreal ) - { - SearnRep( exppatt, s_expreal, lenreal, ptro, lenres ); - } - else - { -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( exppatt ); -#endif - return 0; - } - } - else /* ---- regular match marker */ - { - /* Copying a real expression to 's_expreal' */ - if( ! lenreal ) - { - lenreal = getExpReal( s_expreal, ptri, HB_FALSE, maxlenreal, HB_FALSE, HB_FALSE ); - } - - /* - printf("Len: %i Pat: %s Exp: %s\n", lenreal, exppatt, s_expreal ); - */ - - if( lenreal ) - { - SearnRep( exppatt, s_expreal, lenreal, ptro, lenres ); - } - else - { -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( exppatt ); -#endif - return 0; - } - } - -#if defined( HB_PP_DEBUG_MEMORY ) - hb_xfree( exppatt ); -#endif - return 1; -} - -static int getExpReal( char * expreal, char ** ptri, HB_BOOL prlist, int maxrez, HB_BOOL bStrict, HB_BOOL bInBrackets ) -{ - int lens = 0; - char * sZnaki = "+-=><*/$.:#%!^"; - int State; - int StBr1 = 0, StBr2 = 0, StBr3 = 0; - HB_BOOL rez = HB_FALSE; - HB_BOOL bMacro = HB_FALSE; - HB_BOOL bBrackets = HB_FALSE; - char * cStart = expreal; - char cLastSep = '\0'; - char cLastChar = '\0'; - - HB_TRACE( HB_TR_DEBUG, ( "getExpReal(%s, %p, %d, %d, %d, %d)", expreal, ptri, prlist, maxrez, bStrict, bInBrackets ) ); - - HB_SKIPTABSPACES( *ptri ); - - if( **ptri == '(' && bInBrackets ) - { - /* scan expression including start and end brackets */ - bBrackets = HB_TRUE; - ( *ptri )++; - prlist = HB_TRUE; - } - State = ( **ptri == '\'' || **ptri == '\"' || **ptri == '[' ) ? STATE_EXPRES : STATE_ID; - - while( **ptri != '\0' && ! rez && lens < maxrez ) - { - if( State == STATE_EXPRES || ( cLastChar && strchr( "({[.|,$!#=<>^%*/+-", cLastChar ) ) ) - { - /* Ron Pinkas added if on State 2001-05-02 to avoid - multiple strings concatination. - */ - if( **ptri == '"' ) - { - if( expreal != NULL ) - { - *expreal++ = **ptri; - } - - ( *ptri )++; - lens++; - - while( **ptri != '\0' && lens < maxrez ) - { - if( expreal != NULL ) - { - *expreal++ = **ptri; - } - - if( **ptri == '"' ) - { - break; - } - - ( *ptri )++; - lens++; - } - - ( *ptri )++; - lens++; - - cLastChar = '"'; - State = ( StBr1 == 0 && StBr2 == 0 && StBr3 == 0 ) ? STATE_ID_END : STATE_BRACKET; - continue; - } - else if( **ptri == '\'' ) - { - char * pString; - - if( expreal != NULL ) - { - *expreal++ = **ptri; - } - - ( *ptri )++; - lens++; - - pString = expreal; - - while( **ptri != '\0' && lens < maxrez ) - { - if( expreal != NULL ) - { - *expreal++ = **ptri; - } - - if( **ptri == '\'' ) - { - break; - } - - ( *ptri )++; - lens++; - } - - if( expreal != NULL ) - { - *( expreal - 1 ) = '\0'; - if( strchr( pString, '"' ) == NULL ) - { - *( pString - 1 ) = '"'; - *( expreal - 1 ) = '"'; - } - else - { - *( expreal - 1 ) = '\''; - } - } - - ( *ptri )++; - lens++; - - cLastChar = '\''; - State = ( StBr1 == 0 && StBr2 == 0 && StBr3 == 0 ) ? STATE_ID_END : STATE_BRACKET; - continue; - } - else if( **ptri == '[' ) - { - /* ( see below 5-2-2001 - && ( State == STATE_EXPRES || ( strchr( ")]}.", cLastChar ) == NULL - && ! ISNAME( ( BYTE ) cLastChar ) ) ) - */ - char * pString; - - if( expreal != NULL ) - { - *expreal++ = **ptri; - } - - ( *ptri )++; - lens++; - - pString = expreal; - - while( **ptri != '\0' && lens < maxrez ) - { - if( expreal != NULL ) - { - *expreal++ = **ptri; - } - - if( **ptri == ']' ) - { - break; - } - - ( *ptri )++; - lens++; - } - - if( expreal != NULL ) - { - *( expreal - 1 ) = '\0'; - if( strchr( pString, '"' ) == NULL ) - { - *( pString - 1 ) = '"'; - *( expreal - 1 ) = '"'; - } - else if( strchr( pString, '\'' ) == NULL ) - { - *( pString - 1 ) = '\''; - *( expreal - 1 ) = '\''; - } - else - { - *( expreal - 1 ) = ']'; - } - } - - ( *ptri )++; - lens++; - - cLastChar = ']'; - State = ( StBr1 == 0 && StBr2 == 0 && StBr3 == 0 ) ? STATE_ID_END : STATE_BRACKET; - continue; - } - /* Added by Ron Pinkas 2001-05-02 - ( removed lots of related scattered logic below! - */ - } - else if( strchr( "'\"", **ptri ) ) - { - /* New String, can't belong to extracted expression. */ - break; - } - else if( **ptri == '[' && ( strchr( ")]}.", cLastChar ) == NULL && ! ISNAME( ( BYTE ) cLastChar ) ) ) /* New String, can't belong to extracted expression. */ - { - break; - } - /* End - END - Added by Ron Pinkas 2000-11-05 */ - -#if 0 - printf( "State: %i Char:%c\n", State, **ptri ); -#endif - - switch( State ) - { - case STATE_BRACKET: - if( **ptri == '(' ) - { - StBr1++; - } - else if( **ptri == '[' ) - { - StBr2++; - } - else if( **ptri == '{' ) - { - StBr3++; - } - else if( **ptri == ')' ) - { - StBr1--; - if( StBr1 == 0 && StBr2 == 0 && StBr3 == 0 ) - { - State = STATE_ID_END; - } - } - else if( **ptri == ']' ) - { - StBr2--; - if( StBr1 == 0 && StBr2 == 0 && StBr3 == 0 ) - { - State = STATE_ID_END; - } - } - else if( **ptri == '}' ) - { - StBr3--; - if( StBr1 == 0 && StBr2 == 0 && StBr3 == 0 ) - { - State = STATE_ID_END; - } - } - - break; - - case STATE_ID: - case STATE_ID_END: - if( ( ( ISNAME( ( BYTE ) **ptri ) || **ptri == '\\' || **ptri == '&' ) && State == STATE_ID_END ) || **ptri == ',' ) - { - if( **ptri == ',' ) - { - if( ! prlist ) - { - rez = HB_TRUE; - } - else - { - State = STATE_EXPRES; - } - cLastSep = ','; - } - else - { - rez = HB_TRUE; - } - } - else if( ( **ptri == '+' && *( *ptri + 1 ) == '+' ) || ( **ptri == '-' && *( *ptri + 1 ) == '-' ) ) - { - cLastChar = **ptri; - - if( expreal ) - { - *expreal++ = **ptri; - } - ( *ptri )++; - lens++; - - if( expreal ) - { - *expreal++ = **ptri; - } - ( *ptri )++; - lens++; - - if( State == STATE_ID ) - { - /* Prefix ONLY when lens == 0 (2) oterwise MUST be a postfix. */ - if( lens == 2 ) - { - while( **ptri == ' ' && lens < maxrez ) - { - if( expreal ) - { - *expreal++ = **ptri; - } - ( *ptri )++; - lens++; - } - } - else - { - State = ( StBr1 == 0 && StBr2 == 0 && StBr3 == 0 ) ? STATE_ID_END : STATE_BRACKET; - } - } - continue; - } - else if( IsInStr( **ptri, sZnaki ) ) - { - cLastSep = ','; - /* Ron Pinkas added 2000-06-02 */ - if( **ptri == '.' && bMacro ) - { - /* Macro terminator '.' */ - if( *( *ptri + 1 ) == ' ' ) - { - State = STATE_ID_END; - } - - bMacro = HB_FALSE; - - /* Ron Pinkas added 2000-05-03 */ - /* Macro terminator is NOT a coninutation char unlike '.' of logical operators, so we don't want it recorded as cLastChar! */ - if( expreal != NULL ) - { - *expreal++ = **ptri; - } - ( *ptri )++; - lens++; - 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; - } - else if( **ptri == '(' ) - { - State = STATE_BRACKET; - StBr1 = 1; - } - else if( **ptri == '[' ) - { - StBr2++; - State = STATE_BRACKET; - } - else if( **ptri == '{' ) - { - State = STATE_BRACKET; - StBr3 = 1; - } - else if( **ptri == ')' && StBr1 == 0 ) - { - if( bBrackets ) - { - ( *ptri )++; - } - rez = HB_TRUE; - } - else if( **ptri == ']' && StBr2 == 0 ) - { - rez = HB_TRUE; - } - else if( **ptri == '}' && StBr3 == 0 ) - { - rez = HB_TRUE; - } - else if( **ptri == '&' ) - { - bMacro = HB_TRUE; - } - else if( **ptri == ' ' ) - { - State = STATE_ID_END; - bMacro = HB_FALSE; - } - - break; - - case STATE_EXPRES: - case STATE_EXPRES_ID: - if( **ptri == '[' ) - { - StBr2++; - State = STATE_BRACKET; - } - else if( ISNAME( ( BYTE ) **ptri ) ) - { - if( prlist && cLastSep == ' ' ) - { - State = STATE_ID_END; - rez = HB_TRUE; - } - else - State = STATE_EXPRES_ID; - cLastSep = **ptri; - } - else if( **ptri == ' ' ) - { - if( ! prlist ) - { - if( State == STATE_EXPRES_ID ) - { - State = STATE_ID_END; - } - else if( lens > 2 && ( ( *( *ptri - 2 ) == '+' && *( *ptri - 1 ) == '+' ) || ( *( *ptri - 2 ) == '-' && *( *ptri - 1 ) == '-' ) ) ) - { - State = STATE_ID_END; - } - } - if( cLastSep != ',' ) - cLastSep = ' '; - } - /* Ron Pinkas added 2000-06-14 */ - else if( **ptri == ')' && StBr1 == 0 ) - { - rez = HB_TRUE; - } - /* Ron Pinkas end 2000-06-14 */ - else if( **ptri == '(' ) - { - StBr1++; - State = STATE_BRACKET; - } - else if( **ptri == '{' ) - { - StBr3++; - State = STATE_BRACKET; - } - else if( **ptri == '}' && StBr3 == 0 ) - { - rez = HB_TRUE; - } - else if( **ptri == ',' ) - { - if( ! prlist ) - { - rez = HB_TRUE; - State = STATE_EXPRES; - } - cLastSep = ','; - } - else if( **ptri == '.' && *( *ptri - 2 ) == '.' && - ( *( *ptri - 1 ) == 'T' || *( *ptri - 1 ) == 'F' || *( *ptri - 1 ) == 't' || *( *ptri - 1 ) == 'f' ) ) - { - State = STATE_ID_END; - } - else if( **ptri == '&' ) - { - State = STATE_ID; - continue; - } - else - { - State = STATE_EXPRES; - cLastSep = ','; - } - - break; - } - - if( ! rez ) - { - /* Ron Pinkas added 2000-06-17 */ - if( **ptri != ' ' && **ptri != '\t' ) - { - cLastChar = **ptri; - } - /* Ron Pinkas end 2000-06-17 */ - - if( expreal != NULL ) - *expreal++ = **ptri; - - ( *ptri )++; - lens++; - } - } - if( ! rez && lens >= maxrez ) - { - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_BUFFER_OVERFLOW, NULL, NULL ); - } - - if( expreal != NULL && expreal > cStart ) - { - while( *( expreal - 1 ) == ' ' && expreal > cStart ) - { - expreal--; - lens--; - } - - *expreal = '\0'; - } - - /* Ron Pinkas added 2000-06-21 */ - if( bStrict ) - { - if( State == STATE_QUOTE1 || State == STATE_QUOTE2 || State == STATE_QUOTE3 || State == STATE_BRACKET || StBr1 || StBr2 || StBr3 ) - { - /* Alexander should we include this??? - expreal = NULL; - */ - lens = 0; - } - } - /* Ron Pinkas end 2000-06-21 */ - - return lens; -} - -static HB_BOOL isExpres( char * stroka, HB_BOOL prlist ) -{ - int l1, l2; - - HB_TRACE( HB_TR_DEBUG, ( "isExpres(%s)", stroka ) ); - -#if 0 - printf( "Exp: >%s<\n", stroka ); -#endif - - l1 = strlen( stroka ); - l2 = getExpReal( NULL, &stroka, prlist, HB_PP_STR_SIZE, HB_TRUE, HB_FALSE ); - -#if 0 - printf( "Len1: %i Len2: %i RealExp: >%s< Last: %c\n", l1, l2, stroka - l2, ( stroka - l2 )[ l1 - 1 ] ); -#endif - - /* Ron Pinkas modified 2000-06-17 Expression can't be valid if last charcter is one of these: ":/+*-%^=(<>" - return ( l1 <= l2 ); - */ - - return l1 <= l2 /*&& ! IsInStr( ( stroka - l2 )[l1-1], ":/+*-%^=(<>[{" ) */; -} - -static HB_BOOL TestOptional( char * ptr1, char * ptr2 ) -{ - int nbr = 0; - HB_BOOL flagname = HB_FALSE; - int statevar = 0; - - HB_TRACE( HB_TR_DEBUG, ( "TestOptional(%s, %s)", ptr1, ptr2 ) ); - - while( ptr1 <= ptr2 ) - { - if( *ptr1 == HB_PP_OPT_START ) - { - nbr++; - } - else if( *ptr1 == HB_PP_OPT_END ) - { - if( nbr ) - { - nbr--; - flagname = HB_FALSE; - } - else - return 0; - } - else if( *ptr1 == HB_PP_MATCH_MARK && *( ptr1 + 2 ) == '2' && nbr ) - statevar = 1; - else if( *ptr1 == '>' && statevar ) - statevar = 0; - else if( *ptr1 != ' ' && *ptr1 != '\t' && ! statevar ) - { - if( nbr ) - flagname = HB_TRUE; - else - return 0; - } - ptr1++; - } - /* if( !flagname ) - while( *ptr1 != ']' ) - { - if( *ptr1 == '[' || *ptr1 == '\0' ) return 0; - ptr1++; - } */ - return ! flagname; -} - -static HB_BOOL CheckOptional( char * ptrmp, char * ptri, char * ptro, int * lenres, HB_BOOL com_or_tra, HB_BOOL com_or_xcom ) -{ - int save_numBr = s_numBrackets, save_Repeate = s_Repeate; - HB_BOOL endTranslation = HB_FALSE; - HB_BOOL bResult = HB_TRUE; - char * lastInputptr[ 5 ]; - char * lastopti[ 3 ], * ptr; - - HB_SYMBOL_UNUSED( com_or_tra ); - - HB_TRACE( HB_TR_DEBUG, ( "CheckOptional(%s, %s, %s, %p, %d, %d)", ptrmp, ptri, ptro, lenres, com_or_tra, com_or_xcom ) ); - - s_bReplacePat = HB_FALSE; - lastInputptr[ s_Repeate ] = ptri; - while( *ptri != '\0' && ! endTranslation && bResult ) - { - HB_SKIPTABSPACES( ptrmp ); - switch( *ptrmp ) - { - case HB_PP_OPT_START: - s_numBrackets++; - s_aIsRepeate[ s_Repeate ] = 0; - lastInputptr[ s_Repeate ] = ptri; - lastopti[ s_Repeate++ ] = ptrmp; - ptrmp++; - break; - - case HB_PP_OPT_END: - if( s_numBrackets == save_numBr ) - endTranslation = HB_TRUE; - else - { - if( s_Repeate ) - { - s_Repeate--; - ptrmp = lastopti[ s_Repeate ]; - } - else - ptrmp++; - s_numBrackets--; - } - break; - - case ',': - if( *ptri == ',' ) - { - ptrmp++; - ptri++; - } - else - { - if( s_numBrackets - save_numBr > 0 ) - { - SkipOptional( &ptrmp ); - ptri = lastInputptr[ s_Repeate ]; - } - else - bResult = HB_FALSE; - } - break; - - case HB_PP_MATCH_MARK: /* Match marker */ - if( ! WorkMarkers( &ptrmp, &ptri, ptro, lenres, com_or_tra, com_or_xcom ) ) - { - if( s_numBrackets - save_numBr > 0 ) - { - SkipOptional( &ptrmp ); - ptri = lastInputptr[ s_Repeate ]; - } - else - bResult = HB_FALSE; - } - break; - - case '\0': - bResult = HB_FALSE; - - default: /* Key word */ - ptr = ptri; - if( *ptri == ',' || truncmp( &ptri, &ptrmp, ! com_or_xcom ) ) - { - ptri = ptr; - if( s_numBrackets - save_numBr > 0 ) - { - SkipOptional( &ptrmp ); - ptri = lastInputptr[ s_Repeate ]; - } - else - bResult = HB_FALSE; - } - } - HB_SKIPTABSPACES( ptri ); - } - ; - - if( *ptri == '\0' ) - { - for(;; ) - { - HB_SKIPTABSPACES( ptrmp ); - if( *ptrmp == HB_PP_OPT_START ) - { - ptrmp++; - SkipOptional( &ptrmp ); - } - else if( *ptrmp == HB_PP_OPT_END ) - break; - else - { - bResult = 0; - break; - } - } - } - s_Repeate = save_Repeate; - s_numBrackets = save_numBr; - s_bReplacePat = HB_TRUE; - return bResult; -} - -static void SkipOptional( char ** ptri ) -{ - int nbr = 0; - - HB_TRACE( HB_TR_DEBUG, ( "SkipOptional(%p)", ptri ) ); - - while( **ptri != HB_PP_OPT_END || nbr ) - { - switch( **ptri ) - { - case HB_PP_OPT_START: - nbr++; - break; - case HB_PP_OPT_END: - nbr--; - break; - case HB_PP_MATCH_MARK: - ( *ptri ) += 3; - if( *( *ptri - 1 ) == '2' ) - while( **ptri != '>' ) - ( *ptri )++; - break; - } - ( *ptri )++; - } - if( **ptri == HB_PP_OPT_END && s_numBrackets > 0 ) - { - if( s_Repeate ) - s_Repeate--; - s_numBrackets--; - ( *ptri )++; - } -} - -static void SearnRep( char * exppatt, char * expreal, int lenreal, char * ptro, int * lenres ) -{ - int ifou, isdvig = 0; - HB_BOOL rezs, bFound = HB_FALSE; - int kolmarkers; - int lennew, i; - char lastchar = '0'; - char * ptr, * ptr2, * ptrOut = ptro; - - HB_TRACE( HB_TR_DEBUG, ( "SearnRep(%s, %s, %d, %s, %p)", exppatt, expreal, lenreal, ptro, lenres ) ); - - if( s_expcopy == NULL ) - s_expcopy = ( char * ) hb_xgrab( HB_PP_STR_SIZE ); - - if( *( exppatt + 1 ) == '\0' ) - *( ptro + *lenres ) = '\0'; - - while( ( ifou = md_strAt( exppatt, ( *( exppatt + 1 ) ) ? 2 : 1, ptrOut, HB_FALSE, HB_FALSE, HB_TRUE, MD_STR_AT_USESUBCASE ) ) > 0 ) - { - bFound = HB_TRUE; - rezs = HB_FALSE; - ptr = ptrOut + ifou - 1; - kolmarkers = 0; - ptr = PrevSquare( ptr, ptro, &kolmarkers ); - if( ptr ) - { - if( s_Repeate ) - s_aIsRepeate[ s_Repeate - 1 ]++; - if( ! s_bReplacePat ) - return; - - ptr2 = ptrOut + ifou + 3; - while( *ptr2 != HB_PP_OPT_END || *( ptr2 - 1 ) == '\\' ) - { - if( *ptr2 == HB_PP_MATCH_MARK ) - kolmarkers++; - ptr2++; - } - - if( s_Repeate && lenreal && kolmarkers && lastchar != '0' && *( ptrOut + ifou + 2 ) == '0' ) - { - isdvig += ifou; - rezs = HB_TRUE; - } - else if( s_Repeate ) - { - if( lenreal == 0 ) - { - if( s_numBrackets >= 2 ) - { - isdvig += ifou; - continue; - } - else - { - hb_pp_Stuff( "", ptr, 0, ptr2 - ptr + 1, *lenres - ( ptr - ptro ) ); - *lenres -= ptr2 - ptr + 1; - isdvig = ptr - ptro; - rezs = HB_TRUE; - } - } - else - { - lennew = ptr2 - ptr - 1; - - if( lennew < HB_PP_STR_SIZE - 2 ) - { - memcpy( s_expcopy, ptr + 1, lennew ); - } - else - { - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_BUFFER_OVERFLOW, NULL, NULL ); - return; - } - *( s_expcopy + lennew++ ) = ' '; - *( s_expcopy + lennew ) = '\0'; - while( ( i = hb_strAt( exppatt, 2, s_expcopy, lennew ) ) > 0 ) - lennew += ReplacePattern( exppatt[ 2 ], expreal, lenreal, s_expcopy + i - 1, lennew ); - if( kolmarkers ) - { - s_groupchar = ( char ) ( ( unsigned int ) s_groupchar + 1 ); - for( i = 0; i < lennew; i++ ) - if( *( s_expcopy + i ) == HB_PP_MATCH_MARK ) - { - *( s_expcopy + i + 3 ) = s_groupchar; - i += 4; - } - } - hb_pp_Stuff( s_expcopy, ptr, lennew, 0, *lenres - ( ptr - ptro ) ); - *lenres += lennew; - isdvig = ptr - ptro + ( ptr2 - ptr - 1 ) + lennew; - rezs = HB_TRUE; - } - } - else if( exppatt[ 0 ] == '\001' && exppatt[ 1 ] == '\000' ) - { - /* final pass to remove optional markers */ - hb_pp_Stuff( "", ptr, 0, ptr2 - ptr + 1, *lenres - ( ptr - ptro ) ); - *lenres -= ptr2 - ptr + 1; - isdvig = ptr - ptro; - rezs = HB_TRUE; - } - } - - if( ! rezs && s_bReplacePat ) - { - if( *( ptrOut + ifou + 2 ) != '0' && *( exppatt + 1 ) ) - { - isdvig = ptrOut - ptro + ifou; - do - { - if( lastchar == '0' ) - lastchar = *( ptrOut + ifou + 2 ); - if( lastchar != *( ptrOut + ifou + 2 ) ) - { - ifou += 3; - ptrOut = ptrOut + ifou; - continue; - } - - *lenres += ReplacePattern( exppatt[ 2 ], expreal, lenreal, ptrOut + ifou - 1, *lenres - ifou + 1 ); - ptrOut = ptrOut + ifou; - } - while( ( ifou = md_strAt( exppatt, ( *( exppatt + 1 ) ) ? 2 : 1, ptrOut, HB_FALSE, HB_FALSE, HB_TRUE, MD_STR_AT_USESUBCASE ) ) > 0 ); - if( ! s_Repeate ) - { - lastchar++; - ptrOut = ptro + isdvig; - isdvig = 0; - continue; - } - return; - } - else if( lastchar == '0' ) - { - *lenres += ReplacePattern( ( exppatt[ 1 ] ? exppatt[ 2 ] : exppatt[ 1 ] ), expreal, lenreal, ptrOut + ifou - 1, *lenres - isdvig - ifou + 1 ); - isdvig += ifou - 1; - } - else - { - ptrOut += ifou + 1; - continue; - } - } - else if( ! s_bReplacePat ) - isdvig += ifou; - ptrOut = ptro + isdvig; - } - if( ! bFound && s_Repeate ) - s_aIsRepeate[ s_Repeate - 1 ]++; -} - -static HB_BOOL ScanMacro( char * expreal, int lenitem, int * pNewLen ) -{ - int i; - - HB_TRACE( HB_TR_DEBUG, ( "ScanMacro(%s, %d, %p)", expreal, lenitem, pNewLen ) ); - - expreal++; /* skip '&' character */ - i = 0; - - while( expreal[ i ] == ' ' || expreal[ i ] == '\t' ) - { - i++; - } - if( expreal[ i ] == '(' ) - { - *pNewLen = lenitem - 1; - return HB_TRUE; - } - else if( HB_ISALPHA( ( BYTE ) expreal[ i ] ) || expreal[ i ] == '_' ) - { - i++; - while( ISNAME( ( BYTE ) expreal[ i ] ) ) - { - i++; - } - *pNewLen = i; - if( expreal[ i ] == '.' ) - { - i++; - } - while( expreal[ i ] == ' ' || expreal[ i ] == '\t' ) - { - i++; - } - if( expreal[ i ] == '\0' || expreal[ i ] == ',' || expreal[ i ] == ')' ) /* || expreal[i] == ' ' )*/ - { - return HB_TRUE; - } - } - *pNewLen = lenitem; - return HB_FALSE; -} - -static int pp_Stringify( HB_BOOL bSmart, char ** ptro, int * lenres, char * expr, int lenitem ) -{ - int rmlen = 0; - int lenTrim = lenitem; - int iAdd = 0; - char sQuotes[ 3 ] = "\"\""; - HB_BOOL bComma = expr[ lenitem ] == ','; - - while( *expr == ' ' && lenTrim ) - { - expr++; - lenTrim--; - } - while( lenTrim && expr[ lenTrim - 1 ] == ' ' ) - { - lenTrim--; - } - - if( ! lenTrim ) - { - /* empty string - do nothing unless the comma is required */ - } - else if( *expr == '&' ) - { - /* macro operator */ - HB_BOOL bSmartMacro; - int lennew; - - lennew = lenTrim; - bSmartMacro = ScanMacro( expr, lenTrim, &lennew ); - if( bSmartMacro ) - { - /* remove macro operator '&' */ - lenTrim = lennew; - hb_pp_Stuff( expr + 1, *ptro, lenTrim, 0, *lenres ); - } - else - { - /* enclose expression in string markers */ - iAdd = 2; - pp_rQuotes( expr, sQuotes ); - hb_pp_Stuff( sQuotes, *ptro, iAdd, 0, *lenres ); - hb_pp_Stuff( expr, *ptro + 1, lenTrim, 0, *lenres + iAdd ); - } - } - else if( bSmart && ( *expr == '(' - || ( *expr == '\"' && *( expr + lenTrim - 1 ) == '\"' ) - || ( *expr == '[' && *( expr + lenTrim - 1 ) == ']' ) || ( *expr == '\'' && *( expr + lenTrim - 1 ) == '\'' ) ) ) - { - /* items enclosed in () "" '' [] leave unchanged */ - hb_pp_Stuff( expr, *ptro, lenTrim, 0, *lenres ); - } - else - { - /* enclose expression in string markers */ - iAdd = 2; - pp_rQuotes( expr, sQuotes ); - hb_pp_Stuff( sQuotes, *ptro, iAdd, 0, *lenres ); - hb_pp_Stuff( expr, *ptro + 1, lenTrim, 0, *lenres + iAdd ); - } - ( *ptro ) += lenTrim + iAdd; - ( *lenres ) += lenTrim + iAdd; - - if( bComma ) - { - hb_pp_Stuff( ",", *ptro, 1, 0, *lenres ); - ( *lenres )++; - ( *ptro )++; - rmlen++; - } - rmlen += lenTrim + iAdd; - - return rmlen; -} - -static int ReplacePattern( char patttype, char * expreal, int lenreal, char * ptro, int lenres ) -{ - int rmlen = lenreal, ifou, lenitem; - char sQuotes[ 4 ] = "\"\","; - - HB_TRACE( HB_TR_DEBUG, ( "ReplacePattern(%c, %s, %d, %s, %p)", patttype, expreal, lenreal, ptro, lenres ) ); - - switch( *( ptro + 2 ) ) - { - case '0': /* Regular result marker */ - hb_pp_Stuff( expreal, ptro, lenreal, 4, lenres ); - break; - - case '1': /* Dumb stringify result marker */ - pp_rQuotes( expreal, sQuotes ); - hb_pp_Stuff( sQuotes, ptro, 2, 4, lenres ); - if( lenreal ) - hb_pp_Stuff( expreal, ptro + 1, lenreal, 0, lenres ); - rmlen = lenreal + 2; - if( *sQuotes == '[' ) - hb_pp_NestedLiteralString = HB_TRUE; - break; - - case '2': /* Normal stringify result marker */ - hb_pp_Stuff( "", ptro, 0, 4, lenres ); /* remove match marker */ - lenres -= 4; - if( patttype == '1' ) /* list match marker */ - { - rmlen = 0; - do - { - ifou = md_strAt( ",", 1, expreal, HB_FALSE, HB_TRUE, HB_FALSE, MD_STR_AT_IGNORECASE ); - if( *expreal != '\0' ) - { - rmlen += pp_Stringify( HB_FALSE, &ptro, &lenres, expreal, ( ( ifou ) ? ifou - 1 : lenreal ) ); - } - expreal += ifou; - lenreal -= ifou; - } - while( ifou > 0 ); - } - else - { - rmlen = pp_Stringify( HB_FALSE, &ptro, &lenres, expreal, lenreal ); - } - break; - - case '3': /* Smart stringify result marker */ - hb_pp_Stuff( "", ptro, 0, 4, lenres ); /* remove match marker */ - lenres -= 4; - if( patttype == '1' ) /* list match marker */ - { - rmlen = 0; - do - { - ifou = md_strAt( ",", 1, expreal, HB_FALSE, HB_TRUE, HB_FALSE, MD_STR_AT_IGNORECASE ); - if( *expreal != '\0' ) - { - rmlen += pp_Stringify( HB_TRUE, &ptro, &lenres, expreal, ( ( ifou ) ? ifou - 1 : lenreal ) ); - } - expreal += ifou; - lenreal -= ifou; - } - while( ifou > 0 ); - } - else - { - rmlen = pp_Stringify( HB_TRUE, &ptro, &lenres, expreal, lenreal ); - } - break; - - case '4': /* Blockify result marker */ - if( ! lenreal ) - hb_pp_Stuff( expreal, ptro, lenreal, 4, lenres ); - else if( patttype == '1' ) /* list match marker */ - { - hb_pp_Stuff( "", ptro, 0, 4, lenres ); - lenres -= 4; - rmlen = 0; - do - { - ifou = md_strAt( ",", 1, expreal, HB_FALSE, HB_TRUE, HB_FALSE, MD_STR_AT_IGNORECASE ); - lenitem = ( ifou ) ? ifou - 1 : lenreal; - if( *expreal != '\0' ) - { - int i; - - i = ( ifou ) ? 6 : 5; - hb_pp_Stuff( "{|| },", ptro, i, 0, lenres ); - hb_pp_Stuff( expreal, ptro + 4, lenitem, 0, lenres + i ); - ptro += i + lenitem; - rmlen += i + lenitem; - } - expreal += ifou; - lenreal -= ifou; - } - while( ifou > 0 ); - } - else if( lenreal && *expreal == '{' ) - { - hb_pp_Stuff( expreal, ptro, lenreal, 4, lenres ); - } - else - { - hb_pp_Stuff( "{|| }", ptro, 5, 4, lenres ); - hb_pp_Stuff( expreal, ptro + 4, lenreal, 0, lenres ); - rmlen = lenreal + 5; - } - break; - - case '5': /* Logify result marker */ - rmlen = 3; - if( ! lenreal ) - { - hb_pp_Stuff( ".F.", ptro, 3, 4, lenres ); - } - else - hb_pp_Stuff( ".T.", ptro, 3, 4, lenres ); - break; - - case '6': /* Ommit result marker */ - rmlen = 1; - hb_pp_Stuff( " ", ptro, 1, 4, lenres ); - break; - } - return rmlen - 4; -} - -static void pp_rQuotes( char * expreal, char * sQuotes ) -{ - HB_BOOL lQuote1 = HB_FALSE; - HB_BOOL lQuote2 = HB_FALSE; - - HB_TRACE( HB_TR_DEBUG, ( "pp_rQuotes(%s, %s)", expreal, sQuotes ) ); - - /* - printf( "String: >%s< Delim: %s\n", expreal, sQuotes ); - */ - - while( *expreal != '\0' ) - { - if( *expreal == '\"' ) - lQuote2 = HB_TRUE; - else if( *expreal == '\'' ) - lQuote1 = HB_TRUE; - expreal++; - } - if( lQuote2 ) - { - if( lQuote1 ) - { - *sQuotes = '['; - *( sQuotes + 1 ) = ']'; - } - else - { - *sQuotes = '\''; - *( sQuotes + 1 ) = '\''; - } - } - else - { - *sQuotes = '\"'; - *( sQuotes + 1 ) = '\"'; - } -} - -int hb_pp_RdStr( FILE * handl_i, char * buffer, int maxlen, HB_BOOL lContinue, char * sBuffer, int * lenBuffer, int * iBuffer ) -{ - int readed = 0; - int State = 0; - char cha, cLast = '\0', symbLast = '\0'; - HB_BOOL lDropSpaces = lContinue; - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_RdStr(%p, %s, %d, %d, %s, %p, %p)", handl_i, buffer, maxlen, lDropSpaces, sBuffer, lenBuffer, iBuffer ) ); - - if( *lenBuffer == 0 ) - { - return -1; - } - - for(;; ) - { - if( *iBuffer == *lenBuffer ) - { - if( ( *lenBuffer = fread( sBuffer, 1, HB_PP_BUFF_SIZE, handl_i ) ) < 1 ) - { - sBuffer[ 0 ] = '\n'; - } - *iBuffer = 0; - } - - cha = sBuffer[ *iBuffer ]; - ( *iBuffer )++; - - if( cha == '\r' ) - { - cha = ' '; - } - - if( cha == '\n' ) - { - if( ( hb_pp_StreamBlock != HB_PP_STREAM_DUMP_C ) && s_ParseState == STATE_COMMENT && symbLast == ';' ) - { - buffer[ readed++ ] = ';'; - } - break; - } - else - { - if( hb_pp_StreamBlock == HB_PP_STREAM_DUMP_C ) - { - buffer[ readed++ ] = cha; - continue; - } - } - - if( maxlen > 0 ) - { - switch( s_ParseState ) - { - case STATE_COMMENT: - if( cha == '/' && cLast == '*' ) - { - s_ParseState = STATE_NORMAL; - cha = ' '; - } - - cLast = cha; - - if( cha != ' ' && cha != '\t' ) - { - symbLast = cha; - } - break; - - case STATE_QUOTE1: - if( cha == '\'' ) - s_ParseState = STATE_NORMAL; - break; - - case STATE_QUOTE2: - if( cha == '\"' ) - s_ParseState = STATE_NORMAL; - break; - - case STATE_QUOTE3: - if( cha == ']' ) - s_ParseState = STATE_NORMAL; - break; - - default: - switch( cha ) - { - case '[': - /* Ron Pinkas modified 2000-06-17 - if( ISNAME(( BYTE ) s_prevchar) || s_prevchar == ']' ) - */ - if( ISNAME( ( BYTE ) s_prevchar ) || strchr( ")]}.", s_prevchar ) ) - { - s_ParseState = STATE_BRACKET; - } - else - { - s_ParseState = STATE_QUOTE3; - } - break; - - case ']': - s_ParseState = STATE_NORMAL; - break; - - case '\"': - if( s_ParseState != STATE_BRACKET ) - { - s_ParseState = STATE_QUOTE2; - } - break; - - case '\'': - if( s_ParseState != STATE_BRACKET ) - { - s_ParseState = STATE_QUOTE1; - } - break; - - case '&': - if( readed > 0 && buffer[ readed - 1 ] == '&' ) - { - maxlen = 0; - readed--; - } - break; - - case '/': - if( readed > 0 && buffer[ readed - 1 ] == '/' && ! hb_pp_StreamBlock ) - { - maxlen = 0; - readed--; - } - break; - - case '*': - if( readed > 0 && buffer[ readed - 1 ] == '/' && ! hb_pp_StreamBlock ) - { - s_ParseState = STATE_COMMENT; - readed--; - } - else if( ! State && ! lContinue ) - { - maxlen = readed = 0; - } - break; - } - - if( cha != ' ' && cha != ';' ) - { - s_prevchar = cha; - } - } - - if( cha != ' ' && cha != '\t' ) - { - State = 1; - } - - if( lDropSpaces && State ) - { - lDropSpaces = 0; - } - - if( readed < maxlen && ( ! lDropSpaces || readed == 0 ) && s_ParseState != STATE_COMMENT ) - { - buffer[ readed++ ] = cha; - } - } - } - - while( --readed >= 0 && ( buffer[ readed ] == ' ' || buffer[ readed ] == '\t' ) ) - ; - - if( buffer[ readed ] != ';' && s_ParseState != STATE_COMMENT ) - { - s_ParseState = STATE_NORMAL; - } - - if( maxlen ) - { - if( readed < maxlen ) - readed++; - } - else - readed++; - buffer[ readed ] = '\0'; - -#if 0 - printf( "%s\n", buffer ); -#endif - - return readed; -} - -int hb_pp_WrStr( FILE * handl_o, char * buffer ) -{ - int lens = strlen( buffer ); - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_WrStr(%p, %s)", handl_o, buffer ) ); - - /* Ron Pinkas added 2001-01-20 */ - if( hb_comp_files.iFiles == 1 ) - { - for(; hb_pp_LastOutLine < hb_comp_iLine - 1; hb_pp_LastOutLine++ ) - { - fwrite( "\n", 1, 1, handl_o ); - } - hb_pp_LastOutLine = hb_comp_iLine; - } - /* END Ron Pinkas added 2001-01-20 */ - - fwrite( buffer, lens, 1, handl_o ); - - if( *( buffer + lens - 1 ) != '\n' ) - { - fwrite( "\n", 1, 1, handl_o ); - } - - return 0; -} - -static int md_strAt( char * szSub, int lSubLen, char * szText, HB_BOOL checkword, HB_BOOL checkPrth, HB_BOOL bRule, int iCaseOption ) -{ - int State = STATE_NORMAL; - long lPos = 0, lSubPos = 0; - int kolPrth = 0, kolSquare = 0, kolFig = 0; - int lCase; - int iNestedQuote3 = 0; - char cLastChar = '\0'; - - HB_TRACE( HB_TR_DEBUG, ( "md_strAt(%s, %d, %s, %d, %d, %d)", szSub, lSubLen, szText, checkword, checkPrth, iCaseOption ) ); - - if( iCaseOption == MD_STR_AT_IGNORECASE ) - { - lCase = 0; - } - else - { - lCase = ( *szSub == HB_PP_MATCH_MARK ) ? 0 : 1; - } - - while( *( szText + lPos ) != '\0' && lSubPos < lSubLen ) - { - if( State == STATE_QUOTE1 ) - { - if( *( szText + lPos ) == '\'' ) - { - State = STATE_NORMAL; - } - lPos++; - } - else if( State == STATE_QUOTE2 ) - { - if( *( szText + lPos ) == '\"' ) - { - State = STATE_NORMAL; - } - lPos++; - } - else if( State == STATE_QUOTE3 ) - { - if( *( szText + lPos ) == ']' ) - { - if( --iNestedQuote3 == 0 ) - State = STATE_NORMAL; - } - else if( *( szText + lPos ) == '[' ) - iNestedQuote3++; - lPos++; - } - else - { - if( State == STATE_BRACKET ) - { - if( *( szText + lPos ) == ']' && ( lPos == 0 || *( szText + lPos - 1 ) != '\\' ) ) - { - kolSquare--; - if( kolSquare == 0 ) - { - State = STATE_NORMAL; - } - - cLastChar = ']'; - lPos++; - continue; - } - else if( *( szText + lPos ) == '[' && ( lPos == 0 || *( szText + lPos - 1 ) != '\\' ) ) - { - kolSquare++; - cLastChar = '['; - lPos++; - continue; - } - else if( *( szText + lPos ) == ',' ) - { - cLastChar = ','; - lPos++; - continue; - } - } - else - { - if( ( *( szText + lPos ) == '\'' || *( szText + lPos ) == '`' ) && ( lPos == 0 || *( szText + lPos - 1 ) != '\\' ) ) - { - State = STATE_QUOTE1; - lPos++; - continue; - } - else if( *( szText + lPos ) == '\"' && ( lPos == 0 || *( szText + lPos - 1 ) != '\\' ) ) - { - State = STATE_QUOTE2; - lPos++; - continue; - } - else if( bRule == HB_FALSE && *( szText + lPos ) == '[' && strchr( ")]}.", cLastChar ) == NULL && ! ISNAME( ( BYTE ) cLastChar ) ) - { - State = STATE_QUOTE3; - iNestedQuote3++; - lPos++; - continue; - } - else if( *( szText + lPos ) == '[' && ( lPos == 0 || *( szText + lPos - 1 ) != '\\' ) ) - { - State = STATE_BRACKET; - kolSquare++; - cLastChar = '['; - lPos++; - continue; - } - else if( *( szText + lPos ) == '(' ) - { - kolPrth++; - } - else if( *( szText + lPos ) == ')' ) - { - kolPrth--; - } - else if( *( szText + lPos ) == '{' ) - { - kolFig++; - } - else if( *( szText + lPos ) == '}' ) - { - kolFig--; - } - else if( szText[ lPos ] == '.' && szSub[ 0 ] != '.' ) - { - if( HB_TOUPPER( szText[ lPos + 1 ] ) == 'T' && szText[ lPos + 2 ] == '.' ) - { - lPos += 3; - } - else if( HB_TOUPPER( szText[ lPos + 1 ] ) == 'F' && szText[ lPos + 2 ] == '.' ) - { - lPos += 3; - } - else if( HB_TOUPPER( szText[ lPos + 1 ] ) == 'O' && HB_TOUPPER( szText[ lPos + 2 ] ) == 'R' && szText[ lPos + 4 ] == '.' ) - { - lPos += 4; - } - else if( HB_TOUPPER( szText[ lPos + 1 ] ) == 'A' - && HB_TOUPPER( szText[ lPos + 2 ] ) == 'N' && HB_TOUPPER( szText[ lPos + 3 ] ) == 'D' && szText[ lPos + 4 ] == '.' ) - { - lPos += 5; - } - else if( HB_TOUPPER( szText[ lPos + 1 ] ) == 'N' - && HB_TOUPPER( szText[ lPos + 2 ] ) == 'O' && HB_TOUPPER( szText[ lPos + 3 ] ) == 'T' && szText[ lPos + 4 ] == '.' ) - { - lPos += 5; - } - else - { - lPos++; - } - - lSubPos = 0; - continue; - } - } - - if( ! lSubPos && checkPrth && - ( ( ( kolPrth > 1 ) - || ( kolPrth == 1 && *( szText + lPos ) != '(' ) - || ( kolPrth == 0 && *( szText + lPos ) == ')' ) ) - || ( ( kolFig > 1 ) || ( kolFig == 1 && *( szText + lPos ) != '{' ) || ( kolFig == 0 && *( szText + lPos ) == '}' ) ) ) ) - { - cLastChar = *( szText + lPos ); - lPos++; - continue; - } - - if( lSubPos && checkPrth && ( kolPrth > 0 || kolFig > 0 ) ) - { - cLastChar = *( szText + lPos ); - lPos++; - lSubPos = 0; - continue; - } - - if( ( lCase - && HB_TOUPPER( *( szText + lPos ) ) == HB_TOUPPER( *( szSub + lSubPos ) ) ) || ( ! lCase && *( szText + lPos ) == *( szSub + lSubPos ) ) ) - { - lSubPos++; - cLastChar = *( szText + lPos ); - lPos++; - - if( lSubPos >= lSubLen && checkword && - ( ( ISNAME( ( BYTE ) *szSub ) && lPos > lSubPos - && ISNAME( ( BYTE ) *( szText + lPos - lSubPos - 1 ) ) ) - || ( ISNAME( ( BYTE ) *( szSub + lSubLen - 1 ) ) && ISNAME( ( BYTE ) *( szText + lPos ) ) ) ) ) - { - lSubPos = 0; - } - } - else if( lSubPos ) - { - lSubPos = 0; - } - else - { - cLastChar = *( szText + lPos ); - lPos++; - } - } - } - -#if 0 - if( bRule == 0 && szSub[ 0 ] != ';' ) - { - printf( "Rule: %i Find: >%s< In: >%s<\n", bRule, szSub, szText ); - printf( "Pos: %i Len: %i At: >%s<\n", lPos, lSubLen, ( szText + lPos - lSubLen ) ); - } -#endif - - return lSubPos < lSubLen ? 0 : lPos - lSubLen + 1; -} - -static char * PrevSquare( char * ptr, char * bound, int * kolmark ) -{ - HB_TRACE( HB_TR_DEBUG, ( "PrevSquare(%s, %s, %d)", ptr, bound, kolmark == NULL ? 0 : *kolmark ) ); - while( ptr > bound ) - { - if( kolmark && *ptr == HB_PP_MATCH_MARK ) - { - ( *kolmark )++; - } - else if( *ptr == HB_PP_OPT_START || *ptr == HB_PP_OPT_END ) - { - break; - } - ptr--; - } - return ( *ptr == HB_PP_OPT_START ) ? ptr : NULL; -} - -static int IsInStr( char symb, char * s ) -{ - HB_TRACE( HB_TR_DEBUG, ( "IsInStr(%c, %s)", symb, s ) ); - - while( *s != '\0' ) - if( *s++ == symb ) - return 1; - return 0; -} - -/* ptri = string for inserting - ptro = output string - len1 = length of ptri string - len2 = length of ptro string that will be replaced - lenres = length of ptro string - */ -void hb_pp_Stuff( char * ptri, char * ptro, int len1, int len2, int lenres ) -{ - char * ptr1, * ptr2; - int i; - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_Stuff(%s, %s, %d, %d, %d)", ptri, ptro, len1, len2, lenres ) ); - - if( len1 > len2 ) - { - ptr1 = ptro + lenres + 1; - ptr2 = ptro + lenres + len1 - len2; - /* This is a static buffer - current inserting can erase the null char - than we need set it again. - */ - ptr2[ 1 ] = '\0'; - for( i = 0; i <= lenres; ptr2--, i++ ) - { - ptr1--; - *ptr2 = *ptr1; - } - } - else - { - ptr1 = ptro + len2; - ptr2 = ptro + len1; - for(; ptr1 <= ptro + lenres; ptr1++, ptr2++ ) - *ptr2 = *ptr1; - } - ptr2 = ptro; - for( i = 0; i < len1; i++ ) - *ptr2++ = *( ptri + i ); -} - -int hb_pp_strocpy( char * ptro, char * ptri ) -{ - int lens = 0; - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_strocpy(%s, %s)", ptro, ptri ) ); - - if( ptri != NULL ) - while( *ptri != '\0' ) - { - *ptro++ = *ptri++; - lens++; - } - *ptro = '\0'; - return lens; -} - -static int stroncpy( char * ptro, char * ptri, int lens ) -{ - int i = 0; - - HB_TRACE( HB_TR_DEBUG, ( "stroncpy(%s, %s, %d)", ptro, ptri, lens ) ); - - for(; i < lens; i++ ) - *( ptro + i ) = *ptri++; - i--; - while( i > 0 && *( ptro + i ) == ' ' ) - i--; - i++; - *( ptro + i ) = '\0'; - return i; -} - -static HB_BOOL truncmp( char ** ptro, char ** ptri, HB_BOOL lTrunc ) -{ - char * ptrb = *ptro, co, ci; - - HB_TRACE( HB_TR_DEBUG, ( "truncmp(%p, %p, %d)", ptro, ptri, lTrunc ) ); - - - for(; - **ptri != ' ' && **ptri != '\t' && **ptri != ',' - && **ptri != HB_PP_OPT_START && **ptri != HB_PP_OPT_END - && **ptri != HB_PP_MATCH_MARK && **ptri != '\0' && HB_TOUPPER( **ptri ) == HB_TOUPPER( **ptro ); ( *ptro )++, ( *ptri )++ ) - ; - co = *( *ptro - 1 ); - ci = **ptri; - - if( ( ( ci == ' ' || ci == ',' || ci == HB_PP_OPT_START || - ci == HB_PP_OPT_END || ci == HB_PP_MATCH_MARK || ci == '\0' ) && - ( ( ! ISNAME( ( BYTE ) **ptro ) && ISNAME( ( BYTE ) co ) ) || - ( ! ISNAME( ( BYTE ) co ) ) ) ) ) - return HB_FALSE; - else if( lTrunc && *ptro - ptrb >= 4 && ISNAME( ( BYTE ) ci ) && ! ISNAME( ( BYTE ) **ptro ) && ISNAME( ( BYTE ) co ) ) - { - while( ISNAME( ( BYTE ) **ptri ) ) - ( *ptri )++; - return HB_FALSE; - } - return HB_TRUE; -} - -static HB_BOOL strincmp( char * ptro, char ** ptri, HB_BOOL lTrunc ) -{ - char * ptrb = ptro, co, ci; - - HB_TRACE( HB_TR_DEBUG, ( "strincmp(%s, %p)", ptro, ptri ) ); - - for(; - **ptri != ',' && **ptri != HB_PP_OPT_START && **ptri != HB_PP_OPT_END - && **ptri != HB_PP_MATCH_MARK && **ptri != '\0' && HB_TOUPPER( **ptri ) == HB_TOUPPER( *ptro ); ptro++, ( *ptri )++ ) - ; - co = *( ptro - 1 ); - ci = **ptri; - if( ( ( ci == ' ' || ci == ',' || ci == HB_PP_OPT_START || - ci == HB_PP_OPT_END || ci == HB_PP_MATCH_MARK || ci == '\0' ) && - ( ( ! ISNAME( ( BYTE ) *ptro ) && ISNAME( ( BYTE ) co ) ) || ( ! ISNAME( ( BYTE ) co ) ) ) ) ) - return HB_FALSE; - else if( lTrunc && ptro - ptrb >= 4 && ISNAME( ( BYTE ) ci ) && ! ISNAME( ( BYTE ) *ptro ) && ISNAME( ( BYTE ) co ) ) - { - /* while( ISNAME(( BYTE ) **ptri) ) (*ptri)++; */ - return HB_FALSE; - } - return HB_TRUE; -} - -static int strincpy( char * ptro, char * ptri ) -{ - int lens = 0; - - HB_TRACE( HB_TR_DEBUG, ( "strincpy(%s, %s)", ptro, ptri ) ); - - for(; - *ptri != ' ' && *ptri != ',' && *ptri != HB_PP_OPT_START - && *ptri != HB_PP_OPT_END && *ptri != HB_PP_MATCH_MARK && *ptri != '\0'; ptro++, ptri++, lens++ ) - *ptro = *ptri; - return lens; -} - -static int strotrim( char * stroka, HB_BOOL bRule ) -{ - char * ptr = stroka, lastc = '0', curc; - int lens = 0, State = STATE_NORMAL; - - HB_TRACE( HB_TR_DEBUG, ( "strotrim(%s)", stroka ) ); - - while( ( curc = *stroka ) != '\0' ) - { - if( State == STATE_QUOTE1 ) - { - if( curc == '\'' ) - { - State = STATE_NORMAL; - } - } - else if( State == STATE_QUOTE2 ) - { - if( curc == '\"' ) - { - State = STATE_NORMAL; - } - } - else if( State == STATE_QUOTE3 ) - { - if( curc == ']' ) - { - State = STATE_NORMAL; - } - } - else - { - if( curc == '\'' ) - { - State = STATE_QUOTE1; - } - else if( curc == '\"' ) - { - State = STATE_QUOTE2; - } - /* Ron Pinkas added 2000-11-05 */ - /* Ron Pinkas 2001-02-14 added bRule logic (removed array logic). */ - else if( curc == '[' && bRule == HB_FALSE ) /* && ( strchr( ")]}.", cLastChar ) == NULL && ! ISNAME( ( BYTE ) cLastChar ) ) ) */ - { - State = STATE_QUOTE3; - } - /* END - Ron Pinkas added 2000-11-05 */ - else if( curc == '\t' ) - { - curc = ' '; - } - } - - if( State != STATE_NORMAL || curc != ' ' || - ( curc == ' ' && ! bRule ) || - ( curc == ' ' && lastc != ' ' && lastc != ',' && lastc != '(' && *( stroka + 1 ) != ',' && *( stroka + 1 ) != ' ' && *( stroka + 1 ) ) ) - { - *ptr++ = curc; - lastc = curc; - lens++; - } - - stroka++; - } - - *ptr = '\0'; - - return lens; -} - -static int NextWord( char ** sSource, char * sDest, HB_BOOL lLower ) -{ - int i = 0; - - HB_TRACE( HB_TR_DEBUG, ( "NextWord(%p, %s, %d)", sSource, sDest, lLower ) ); - - HB_SKIPTABSPACES( ( *sSource ) ); - - while( **sSource != '\0' && **sSource != ' ' && **sSource != '\t' && **sSource != '(' ) - { - *sDest++ = ( lLower ) ? HB_TOLOWER( **sSource ) : **sSource; - ( *sSource )++; - i++; - } - - *sDest = '\0'; - - return i; -} - -static int NextName( char ** sSource, char * sDest ) -{ - /* Ron Pinkas added 2000-11-08 */ - char cLastChar = '\0', * pString = NULL, * pTmp; - - /* END - Ron Pinkas added 2000-11-08 */ - - int lenName = 0, State = STATE_NORMAL; - - HB_TRACE( HB_TR_DEBUG, ( "NextName(%p, %s)", sSource, sDest ) ); - -#if 0 - printf( "In: >%s<\n", *sSource ); -#endif - - while( **sSource != '\0' && ( ! ISNAME( ( BYTE ) **sSource ) || State != STATE_NORMAL ) ) - { - if( State == STATE_QUOTE1 ) - { - if( **sSource == '\'' ) - { - State = STATE_NORMAL; - - /* Ron Pinkas added 2000-11-08 */ - **sSource = '\0'; - if( strchr( pString, '"' ) == NULL ) - { - *pString = '"'; - **sSource = '"'; - } - else - { - **sSource = '\''; - } - /* END - Ron Pinkas added 2000-11-08 */ - } - } - else if( State == STATE_QUOTE2 ) - { - if( **sSource == '\"' ) - { - State = STATE_NORMAL; - } - } - else if( State == STATE_QUOTE3 ) - { - if( **sSource == ']' ) - { - State = STATE_NORMAL; - - /* Ron Pinkas added 2000-11-08 */ - **sSource = '\0'; - if( strchr( pString, '"' ) == NULL ) - { - *pString = '"'; - **sSource = '"'; - } - else if( strchr( pString, '\'' ) == NULL ) - { - *pString = '\''; - **sSource = '\''; - } - else - { - **sSource = ']'; - } - /* END - Ron Pinkas added 2000-11-08 */ - } - } - else if( ( *sSource )[ 0 ] == HB_PP_OPT_START || ( *sSource )[ 0 ] == HB_PP_OPT_END ) - { - State = STATE_NORMAL; - } - /* Ron Pinkas added 2001-02-21 */ - else if( ( *sSource )[ 0 ] == '.' && HB_TOUPPER( ( *sSource )[ 1 ] ) == 'A' - && HB_TOUPPER( ( *sSource )[ 2 ] ) == 'N' && HB_TOUPPER( ( *sSource )[ 3 ] ) == 'D' && ( *sSource )[ 4 ] == '.' ) - { - ( *sSource ) += 5; - cLastChar = ' '; - continue; - } - else if( ( *sSource )[ 0 ] == '.' && HB_TOUPPER( ( *sSource )[ 1 ] ) == 'N' - && HB_TOUPPER( ( *sSource )[ 2 ] ) == 'O' && HB_TOUPPER( ( *sSource )[ 3 ] ) == 'T' && ( *sSource )[ 4 ] == '.' ) - { - ( *sSource ) += 5; - cLastChar = ' '; - continue; - } - else if( ( *sSource )[ 0 ] == '.' && HB_TOUPPER( ( *sSource )[ 1 ] ) == 'O' && HB_TOUPPER( ( *sSource )[ 2 ] ) == 'R' && ( *sSource )[ 3 ] == '.' ) - { - ( *sSource ) += 4; - cLastChar = ' '; - continue; - } - /* End - Ron Pinkas added 2001-02-21 */ - else if( ( *sSource )[ 0 ] == '.' && HB_TOUPPER( ( *sSource )[ 1 ] ) == 'T' && ( *sSource )[ 2 ] == '.' ) - { - ( *sSource ) += 3; - cLastChar = ' '; - continue; - } - else if( ( *sSource )[ 0 ] == '.' && HB_TOUPPER( ( *sSource )[ 1 ] ) == 'F' && ( *sSource )[ 2 ] == '.' ) - { - ( *sSource ) += 3; - cLastChar = ' '; - continue; - } - else if( **sSource == '\'' ) - { - /* Ron Pinkas added 2000-11-08 */ - pString = *sSource; - State = STATE_QUOTE1; - } - else if( **sSource == '\"' ) - { - /* Ron Pinkas added 2000-11-08 */ - pString = *sSource; - State = STATE_QUOTE2; - } - /* Ron Pinkas added 2000-11-08 */ - else if( **sSource == '[' && s_bArray == HB_FALSE && strchr( ")]}.\"\'", cLastChar ) == NULL && ! ISNAME( ( BYTE ) cLastChar ) ) - { - /* Ron Pinkas added 2000-11-08 */ - pString = *sSource; - State = STATE_QUOTE3; - } - /* END - Ron Pinkas added 2000-11-08 */ - - /* Ron Pinkas added 2000-11-08 */ - if( State == STATE_NORMAL && **sSource != ' ' && **sSource != '\t' ) - { - cLastChar = **sSource; - } - /* END - Ron Pinkas added 2000-11-08 */ - - ( *sSource )++; - } - - while( **sSource != '\0' && ISNAME( ( BYTE ) **sSource ) ) - { - *sDest++ = *( *sSource )++; - lenName++; - } - - *sDest = '\0'; - - /* Ron Pinkas added 2000-11-08 - Prepare for next run. */ - pTmp = *sSource; - while( *pTmp && ( *pTmp == ' ' || *pTmp == '\t' || *pTmp == HB_PP_OPT_END || *pTmp == HB_PP_OPT_START ) ) - { - pTmp++; - } - - s_bArray = ( *pTmp == '[' ); - /* END - Ron Pinkas added 2000-11-08 */ - -#if 0 - printf( "NextName: >%s<\n", sDest - lenName ); - printf( "Rest: >%s<\n", *sSource ); -#endif - - return lenName; -} - -static int NextParm( char ** sSource, char * sDest ) -{ - int lenName = 0, State = STATE_NORMAL, StBr = 0; - char cLastChar = '\0'; - - HB_TRACE( HB_TR_DEBUG, ( "NextParm(%p, %s)", sSource, sDest ) ); - - HB_SKIPTABSPACES( ( *sSource ) ); - - while( **sSource != '\0' ) - { - if( State == STATE_QUOTE1 ) - { - if( **sSource == '\'' ) - { - State = STATE_NORMAL; - } - } - else if( State == STATE_QUOTE2 ) - { - if( **sSource == '\"' ) - { - State = STATE_NORMAL; - } - } - else if( State == STATE_QUOTE3 ) - { - if( **sSource == ']' ) - { - State = STATE_NORMAL; - } - } - else if( **sSource == '\'' ) - { - State = STATE_QUOTE1; - } - else if( **sSource == '\"' ) - { - State = STATE_QUOTE2; - } - else if( **sSource == '[' && strchr( ")]}.", cLastChar ) == NULL && ! ISNAME( ( BYTE ) cLastChar ) ) - { - State = STATE_QUOTE3; - } - /* Ron Pinkas added 2000-11-26 */ - else if( **sSource == '[' ) - { - StBr++; - } - else if( **sSource == ']' ) - { - StBr--; - } - /* END - Ron Pinkas added 2000-11-26 */ - else if( **sSource == '{' ) - { - StBr++; - } - else if( **sSource == '}' ) - { - StBr--; - } - else if( **sSource == '(' ) - { - StBr++; - } - else if( **sSource == ')' || **sSource == ',' ) - { - if( StBr == 0 ) - { - break; - } - - if( **sSource == ')' ) - { - StBr--; - } - } - - if( sDest != NULL ) - { - *sDest++ = **sSource; - } - - if( State == STATE_NORMAL && **sSource != ' ' && **sSource != '\t' ) - { - cLastChar = **sSource; - } - - ( *sSource )++; - lenName++; - } - - if( sDest ) - { - *sDest = '\0'; - } - -#if 0 - if( sDest ) - printf( "NextParm: >%s<\n", sDest - lenName ); - else - printf( "NextParm Len: %i\n", lenName ); -#endif - - return lenName; -} - -static HB_BOOL IsIdentifier( char * szProspect ) -{ - if( HB_ISALPHA( ( BYTE ) szProspect[ 0 ] ) || szProspect[ 0 ] == '_' ) - { - int i = 1; - - while( ISNAME( ( BYTE ) szProspect[ i ] ) ) - { - i++; - } - while( szProspect[ i ] == ' ' ) - { - i++; - } - - return szProspect[ i ] == '\0'; - } - - return HB_FALSE; -} - - -static int IsMacroVar( char * szText, HB_BOOL isCommand ) -{ - int len = 0; - - if( HB_ISALPHA( ( BYTE ) szText[ 0 ] ) || szText[ 0 ] == '_' ) - { - int i = 1; - - while( ISNAME( ( BYTE ) szText[ i ] ) || HB_ISDIGIT( ( BYTE ) szText[ i ] ) || szText[ i ] == '&' || szText[ i ] == '.' ) - { - i++; - } -/* - while( ISNAME( ( BYTE ) szText[i] ) || szText[i] == '&' ) - { - i++; - } - if( szText[i] == '.' || szText[i] == '&' ) - { - i++; - while( ISNAME(( BYTE ) szText[i]) || HB_ISDIGIT( ( BYTE ) szText[i] ) || szText[i] == '&' || szText[i] == '.' ) - { - i++; - } - } - */ - len = i; - if( ! ( szText[ i ] == '\0' || szText[ i ] == ' ' || szText[ i ] == ')' ) && isCommand ) - { - return 0; - } - } - return len; -} - - -static HB_BOOL OpenInclude( char * szFileName, HB_PATHNAMES * pSearch, PHB_FNAME pMainFileName, HB_BOOL bStandardOnly, char * szInclude ) -{ - FILE * fptr; - PHB_FNAME pFileName; - PFILE pFile; - - HB_TRACE( HB_TR_DEBUG, ( "OpenInclude(%s, %p, %p, %d, %s)", szFileName, pSearch, pMainFileName, ( int ) bStandardOnly, szInclude ) ); - -#if ! defined( __MINGW32CE__ ) && ! ( defined( _MSC_VER ) && defined( HB_OS_WIN_CE ) ) - errno = 0; -#endif - if( bStandardOnly ) - { - fptr = 0; - szInclude[ 0 ] = '\0'; - } - else - { - pFileName = hb_fsFNameSplit( szFileName ); - - if( ( pFileName->szPath == NULL || *( pFileName->szPath ) == '\0' ) && pMainFileName ) - pFileName->szPath = pMainFileName->szPath; - - hb_fsFNameMerge( szInclude, pFileName ); - - fptr = fopen( szInclude, "r" ); - hb_xfree( pFileName ); - } - - if( ! fptr && pSearch && ! hb_fsMaxFilesError() ) - { - pFileName = hb_fsFNameSplit( szFileName ); - pFileName->szName = szFileName; - pFileName->szExtension = NULL; - while( pSearch && ! fptr ) - { - pFileName->szPath = pSearch->szPath; - hb_fsFNameMerge( szInclude, pFileName ); - fptr = fopen( szInclude, "r" ); - pSearch = pSearch->pNext; - } - hb_xfree( pFileName ); - } - - if( fptr ) - { - pFile = ( PFILE ) hb_xgrab( sizeof( _FILE ) ); - pFile->handle = fptr; - pFile->pBuffer = hb_xgrab( HB_PP_BUFF_SIZE ); - pFile->iBuffer = pFile->lenBuffer = 10; - pFile->yyBuffer = NULL; - pFile->szFileName = hb_strdup( szFileName ); - - if( hb_comp_files.pLast ) - hb_comp_files.pLast->iLine = hb_comp_iLine; - hb_comp_iLine = 1; - - pFile->iLine = 1; - pFile->pPrev = hb_comp_files.pLast; - hb_comp_files.pLast = pFile; - hb_comp_files.iFiles++; - return HB_TRUE; - } - - return HB_FALSE; -} - - -void hb_pp_CloseInclude( void ) -{ - PFILE pFile; - - /* we close the currently include file and continue */ - fclose( hb_comp_files.pLast->handle ); - hb_xfree( hb_comp_files.pLast->pBuffer ); - hb_xfree( hb_comp_files.pLast->szFileName ); - pFile = ( PFILE ) ( ( PFILE ) hb_comp_files.pLast )->pPrev; - hb_xfree( hb_comp_files.pLast ); - hb_comp_files.pLast = pFile; - if( hb_comp_files.pLast ) - hb_comp_iLine = hb_comp_files.pLast->iLine; - hb_comp_files.iFiles--; -} diff --git a/harbour/examples/pp/hbppdef.h b/harbour/examples/pp/hbppdef.h deleted file mode 100644 index eb9754fb44..0000000000 --- a/harbour/examples/pp/hbppdef.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Header file for the Preprocesor - * - * Copyright 1999 Alexander S.Kresin - * www - http://harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#ifndef HB_PP_H_ -#define HB_PP_H_ - -#include "hbapi.h" -#include "hbapifs.h" -#include "hberrors.h" - -HB_EXTERN_BEGIN - -typedef void * PHB_PP_STATE; -typedef void * PHB_PP_TOKEN; -typedef void * PHB_PP_OPEN_FUNC; - -struct _DEFINES; -typedef struct _DEFINES -{ - char * name; - int namelen; - char * pars; - int npars; - char * value; - struct _DEFINES * last; -} DEFINES; - -struct _COMMANDS; -typedef struct _COMMANDS -{ - int com_or_xcom; - char * name; - int namelen; - char * mpatt; - char * value; - struct _COMMANDS * last; -} COMMANDS; - -/* #include support */ -typedef struct -{ - FILE * handle; /* handle of the opened file */ - void * pBuffer; /* file buffer */ - char * yyBuffer; /* buffer used by yyac */ - int iBuffer; /* current position in file buffer */ - int lenBuffer; /* current length of data in file buffer */ - char * szFileName; /* name of the file */ - void * pPrev; /* pointer to the previous opened file */ - void * pNext; /* pointer to the next opened file */ - int iLine; /* currently processed line number */ -} _FILE, * PFILE; /* structure to hold an opened PRG or CH */ - -/* structure to control several opened PRGs and CHs */ -typedef struct -{ - PFILE pLast; /* pointer to the last opened file */ - int iFiles; /* number of files currently opened */ -} FILES; - - -#define HB_PP_STR_SIZE 12288 -#define HB_PP_BUFF_SIZE 4096 - -#define HB_SKIPTABSPACES( sptr ) while( *( sptr ) == ' ' || *( sptr ) == '\t' ) ( sptr )++ - -/* ppcore.c exported functions and variables */ - -#define HB_INCLUDE_FUNC_( hbFunc ) HB_BOOL hbFunc( char *, HB_PATHNAMES * ) -typedef HB_INCLUDE_FUNC_ ( HB_INCLUDE_FUNC ); -typedef HB_INCLUDE_FUNC * HB_INCLUDE_FUNC_PTR; - -extern void hb_pp_SetRules_( HB_INCLUDE_FUNC_PTR hb_compInclude, HB_BOOL hb_comp_bQuiet ); -extern int hb_pp_ReadRules( void ); -extern void hb_pp_Init( void ); -extern void hb_pp_Free( void ); -extern void hb_pp_CloseInclude( void ); -extern int hb_pp_ParseDirective_( char * ); /* Parsing preprocessor directives ( #... ) */ -extern int hb_pp_ParseExpression( char *, char *, HB_BOOL ); /* Parsing a line ( without preprocessor directive ) */ -extern int hb_pp_WrStr( FILE *, char * ); -extern int hb_pp_RdStr( FILE *, char *, int, HB_BOOL, char *, int *, int * ); -extern void hb_pp_Stuff( char *, char *, int, int, int ); -extern int hb_pp_strocpy( char *, char * ); -extern DEFINES * hb_pp_AddDefine_( char *, char * ); /* Add new #define to a linked list */ - -extern PHB_FNAME hb_comp_pFileName; -extern HB_BOOL hb_comp_bQuiet; -extern HB_BOOL hb_comp_bStartProc; -extern HB_BOOL hb_comp_bAutoMemvarAssume; -extern HB_BOOL hb_comp_bForceMemvars; -extern HB_BOOL hb_comp_bShortCuts; -extern HB_BOOL hb_comp_bDebugInfo; -extern HB_BOOL hb_comp_bLineNumbers; -extern int hb_comp_iExitLevel; -extern int hb_comp_iWarnings; -extern int hb_comp_iLine; -extern int hb_comp_iLineINLINE; -extern int hb_comp_iLinePRG; -extern int hb_pp_lInclude; -extern int * hb_pp_aCondCompile; -extern int hb_pp_nCondCompile; -extern const char * hb_pp_szErrors[]; -extern const char * hb_pp_szWarnings[]; -extern int hb_pp_nEmptyStrings; -extern int hb_pp_LastOutLine; -extern int hb_pp_StreamBlock; -extern HB_BOOL hb_pp_NestedLiteralString; -extern HB_BOOL hb_pp_LiteralEscSeq; -extern unsigned int hb_pp_MaxTranslateCycles; -extern HB_PATHNAMES * hb_comp_pIncludePath; -extern FILES hb_comp_files; -extern HB_BOOL hb_comp_bPPO; -extern FILE * hb_comp_yyppo; - -/* ppcomp.c exported functions */ -extern int hb_pp_Internal_( FILE *, char * ); -extern void hb_pp_InternalFree( void ); - -#define HB_PP_STREAM_DUMP_C 1 /* pragma BEGINDUMP */ -#define HB_PP_STREAM_CLIPPER 2 /* clipper compatible TEXT/ENDTEXT */ -#define HB_PP_STREAM_PRG 4 /* TEXT/ENDTEXT lines joined with LF */ -#define HB_PP_STREAM_C 8 /* TEXT/ENDTEXT lines joined and ESC seq processed */ - -extern HB_BOOL hb_pp_StreamBlockBegin( char *, int ); -extern void hb_pp_BlockEnd( void ); - -/* pptable.c exported functions and variables */ - -extern void hb_pp_Table( void ); - -extern DEFINES * hb_pp_topDefine; -extern COMMANDS * hb_pp_topCommand; -extern COMMANDS * hb_pp_topTranslate; - -/* pragma.c exported functions */ - -extern HB_BOOL hb_pp_ParsePragma( char * szline ); - -/* - * Errors generated by Harbour preprocessor - */ -#define HB_PP_ERR_CANNOT_OPEN 1 -#define HB_PP_ERR_DIRECTIVE_ELSE 2 -#define HB_PP_ERR_DIRECTIVE_ENDIF 3 -#define HB_PP_ERR_WRONG_NAME 4 -#define HB_PP_ERR_DEFINE_ABSENT 5 -#define HB_PP_ERR_COMMAND_DEFINITION 6 -#define HB_PP_ERR_PATTERN_DEFINITION 7 -#define HB_PP_ERR_RECURSE 8 -#define HB_PP_ERR_WRONG_DIRECTIVE 9 -#define HB_PP_ERR_EXPLICIT 10 -#define HB_PP_ERR_MEMALLOC 11 -#define HB_PP_ERR_MEMREALLOC 12 -#define HB_PP_ERR_MEMFREE 13 -#define HB_PP_ERR_PRAGMA_BAD_VALUE 14 -#define HB_PP_ERR_CANNOT_OPEN_RULES 15 -#define HB_PP_ERR_BAD_RULES_FILE_NAME 16 -#define HB_PP_ERR_TOO_MANY_INCLUDES 17 -#define HB_PP_ERR_BUFFER_OVERFLOW 18 -#define HB_PP_ERR_LABEL_MISSING_IN_DEFINE 19 -#define HB_PP_ERR_PARE_MISSING_IN_DEFINE 20 -#define HB_PP_ERR_LABEL_DUPL_IN_DEFINE 21 - -#define HB_PP_WARN_DEFINE_REDEF 1 -#define HB_PP_WARN_NO_DIRECTIVES 2 - -HB_EXTERN_END - -#endif /* HB_PP_H_ */ diff --git a/harbour/examples/pp/hbpptbl.c b/harbour/examples/pp/hbpptbl.c deleted file mode 100644 index c5cf68a82e..0000000000 --- a/harbour/examples/pp/hbpptbl.c +++ /dev/null @@ -1,450 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Preprocessor precompiled std.ch and some additions ( mainly generated ) - * - * Copyright 1999 Alexander S.Kresin - * www - http://harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -/* - * Avoid tracing in preprocessor/compiler. - */ -#if ! defined(HB_TRACE_UTILS) - #if defined(HB_TRACE_LEVEL) - #undef HB_TRACE_LEVEL - #endif -#endif - -#include - -#include "hbppdef.h" - -COMMANDS * hb_pp_topCommand = NULL; -COMMANDS * hb_pp_topTranslate = NULL; -DEFINES * hb_pp_topDefine = NULL; - -void hb_pp_Table( void ) -{ - static DEFINES sD___01 = {"_SET_ALTERNATE", 14,NULL,-1,"18", NULL }; - static DEFINES sD___02 = {"_SET_ALTFILE", 12,NULL,-1,"19", &sD___01 }; - static DEFINES sD___03 = {"_SET_BELL", 9,NULL,-1,"26", &sD___02 }; - static DEFINES sD___04 = {"_SET_CANCEL", 11,NULL,-1,"12", &sD___03 }; - static DEFINES sD___05 = {"_SET_COLOR", 10,NULL,-1,"15", &sD___04 }; - static DEFINES sD___06 = {"_SET_CONFIRM", 12,NULL,-1,"27", &sD___05 }; - static DEFINES sD___07 = {"_SET_CONSOLE", 12,NULL,-1,"17", &sD___06 }; - static DEFINES sD___08 = {"_SET_CURSOR", 11,NULL,-1,"16", &sD___07 }; - static DEFINES sD___09 = {"_SET_DATEFORMAT", 15,NULL,-1,"4", &sD___08 }; - static DEFINES sD___10 = {"_SET_DEBUG", 10,NULL,-1,"13", &sD___09 }; - static DEFINES sD___11 = {"_SET_DECIMALS", 13,NULL,-1,"3", &sD___10 }; - static DEFINES sD___12 = {"_SET_DEFAULT", 12,NULL,-1,"7", &sD___11 }; - static DEFINES sD___13 = {"_SET_DELETED", 12,NULL,-1,"11", &sD___12 }; - static DEFINES sD___14 = {"_SET_DELIMCHARS", 15,NULL,-1,"34", &sD___13 }; - static DEFINES sD___15 = {"_SET_DELIMITERS", 15,NULL,-1,"33", &sD___14 }; - static DEFINES sD___16 = {"_SET_DEVICE", 11,NULL,-1,"20", &sD___15 }; - static DEFINES sD___17 = {"_SET_EPOCH", 10,NULL,-1,"5", &sD___16 }; - static DEFINES sD___18 = {"_SET_ESCAPE", 11,NULL,-1,"28", &sD___17 }; - static DEFINES sD___19 = {"_SET_EVENTMASK", 14,NULL,-1,"39", &sD___18 }; - static DEFINES sD___20 = {"_SET_EXACT", 10,NULL,-1,"1", &sD___19 }; - static DEFINES sD___21 = {"_SET_EXCLUSIVE", 14,NULL,-1,"8", &sD___20 }; - static DEFINES sD___22 = {"_SET_EXIT", 9,NULL,-1,"30", &sD___21 }; - static DEFINES sD___23 = {"_SET_EXTRA", 10,NULL,-1,"21", &sD___22 }; - static DEFINES sD___24 = {"_SET_EXTRAFILE", 14,NULL,-1,"22", &sD___23 }; - static DEFINES sD___25 = {"_SET_FIXED", 10,NULL,-1,"2", &sD___24 }; - static DEFINES sD___26 = {"_SET_INSERT", 11,NULL,-1,"29", &sD___25 }; - static DEFINES sD___27 = {"_SET_INTENSITY", 14,NULL,-1,"31", &sD___26 }; - static DEFINES sD___28 = {"_SET_MARGIN", 11,NULL,-1,"25", &sD___27 }; - static DEFINES sD___29 = {"_SET_MCENTER", 12,NULL,-1,"37", &sD___28 }; - static DEFINES sD___30 = {"_SET_MESSAGE", 12,NULL,-1,"36", &sD___29 }; - static DEFINES sD___31 = {"_SET_PATH", 9,NULL,-1,"6", &sD___30 }; - static DEFINES sD___32 = {"_SET_PRINTER", 12,NULL,-1,"23", &sD___31 }; - static DEFINES sD___33 = {"_SET_PRINTFILE", 14,NULL,-1,"24", &sD___32 }; - static DEFINES sD___34 = {"_SET_SCOREBOARD", 15,NULL,-1,"32", &sD___33 }; - static DEFINES sD___35 = {"_SET_SCROLLBREAK", 16,NULL,-1,"38", &sD___34 }; - static DEFINES sD___36 = {"_SET_SOFTSEEK", 13,NULL,-1,"9", &sD___35 }; - static DEFINES sD___37 = {"_SET_TYPEAHEAD", 14,NULL,-1,"14", &sD___36 }; - static DEFINES sD___38 = {"_SET_UNIQUE", 11,NULL,-1,"10", &sD___37 }; - static DEFINES sD___39 = {"_SET_WRAP", 9,NULL,-1,"35", &sD___38 }; - static DEFINES sD___40 = {"_SET_COUNT", 10,NULL,-1,"47", &sD___39 }; - static DEFINES sD___41 = {"_SET_CH", 7,NULL,-1,NULL, &sD___40 }; - static DEFINES sD___42 = {"_DFSET", 6,"\001x,\001y",2,"Set( _SET_DATEFORMAT, if(__SetCentury(), \001x, \001y) )", &sD___41 }; - static DEFINES sD___43 = {"_SET_VIDEOMODE", 14,NULL,-1,"40", &sD___42 }; - static DEFINES sD___44 = {"_SET_MBLOCKSIZE", 15,NULL,-1,"41", &sD___43 }; - static DEFINES sD___45 = {"_SET_MFILEEXT", 13,NULL,-1,"42", &sD___44 }; - static DEFINES sD___46 = {"_SET_STRICTREAD", 15,NULL,-1,"43", &sD___45 }; - static DEFINES sD___47 = {"_SET_OPTIMIZE", 13,NULL,-1,"44", &sD___46 }; - static DEFINES sD___48 = {"_SET_AUTOPEN", 12,NULL,-1,"45", &sD___47 }; - static DEFINES sD___49 = {"_SET_AUTORDER", 13,NULL,-1,"46", &sD___48 }; - static DEFINES sD___50 = {"_SET_AUTOSHARE", 14,NULL,-1,"47", &sD___49 }; - static DEFINES sD___51 = {"_SET_LANGUAGE", 13,NULL,-1,"100", &sD___50 }; - static DEFINES sD___52 = {"_SET_IDLEREPEAT", 15,NULL,-1,"101", &sD___51 }; - static DEFINES sD___53 = {"_SET_FILECASE", 13,NULL,-1,"102", &sD___52 }; - static DEFINES sD___54 = {"_SET_DIRCASE", 12,NULL,-1,"103", &sD___53 }; - static DEFINES sD___55 = {"_SET_DIRSEPARATOR", 17,NULL,-1,"104", &sD___54 }; - static DEFINES sD___56 = {"_SET_EOF", 8,NULL,-1,"105", &sD___55 }; - static DEFINES sD___57 = {"_SET_HARDCOMMIT", 15,NULL,-1,"106", &sD___56 }; - static DEFINES sD___58 = {"_SET_FORCEOPT", 13,NULL,-1,"107", &sD___57 }; - static DEFINES sD___59 = {"_SET_DBFLOCKSCHEME", 18,NULL,-1,"108", &sD___58 }; - static DEFINES sD___60 = {"_SET_DEFEXTENSIONS", 18,NULL,-1,"109", &sD___59 }; - - static COMMANDS sC___1 = {0,"NOTE", 4,"\1A30",NULL,NULL }; - static COMMANDS sC___2 = {0,"DO",2,"WHILE \1A00","while \1A00",&sC___1 }; - static COMMANDS sC___3 = {0,"END",3,"\1A00","end",&sC___2 }; - static COMMANDS sC___4 = {0,"END",3,"SEQUENCE","end",&sC___3 }; - static COMMANDS sC___5 = {0,"ENDSEQUENCE",11,"","end",&sC___4 }; - static COMMANDS sC___6 = {0,"ENDDO",5,"\1A30","enddo",&sC___5 }; - static COMMANDS sC___7 = {0,"ENDIF",5,"\1A30","endif",&sC___6 }; - static COMMANDS sC___8 = {0,"ENDCASE",7,"\1A30","endcase",&sC___7 }; - static COMMANDS sC___9 = {0,"ENDFOR",6,"\2 \1A30 \3","next",&sC___8 }; - static COMMANDS sC___10 = {0,"NEXT",4,"\1A00 \2TO \1B00\3 \2STEP \1C00\3","next",&sC___9 }; - static COMMANDS sC___11 = {0,"DO",2,"\1A00.PRG \2WITH \1B10\3","do \1A00 \2 WITH \1B00\3",&sC___10 }; - static COMMANDS sC___12 = {0,"CALL",4,"\1A00() \2WITH \1B10\3","call \1A00 \2 WITH \1B00\3",&sC___11 }; - static COMMANDS sC___13 = {0,"STORE",5,"\1A00 TO \1B00 \2, \1C00 \3","\1B00 := \2 \1C00 := \3 \1A00",&sC___12 }; - static COMMANDS sC___14 = {0,"SET",3,"ECHO \1A30",NULL,&sC___13 }; - static COMMANDS sC___15 = {0,"SET",3,"HEADING \1A30",NULL,&sC___14 }; - static COMMANDS sC___16 = {0,"SET",3,"MENU \1A30",NULL,&sC___15 }; - static COMMANDS sC___17 = {0,"SET",3,"STATUS \1A30",NULL,&sC___16 }; - static COMMANDS sC___18 = {0,"SET",3,"STEP \1A30",NULL,&sC___17 }; - static COMMANDS sC___19 = {0,"SET",3,"SAFETY \1A30",NULL,&sC___18 }; - static COMMANDS sC___20 = {0,"SET",3,"TALK \1A30",NULL,&sC___19 }; - static COMMANDS sC___21 = {0,"SET",3,"PROCEDURE TO",NULL,&sC___20 }; - static COMMANDS sC___22 = {0,"SET",3,"PROCEDURE TO \1A00","_ProcReq_( \1A30 )",&sC___21 }; - static COMMANDS sC___23 = {0,"SET",3,"EXACT \1A20ON,OFF,&>","Set( _SET_EXACT, \1A30 )",&sC___22 }; - static COMMANDS sC___24 = {0,"SET",3,"EXACT (\1A00)","Set( _SET_EXACT, \1A00 )",&sC___23 }; - static COMMANDS sC___25 = {0,"SET",3,"FIXED \1A20ON,OFF,&>","Set( _SET_FIXED, \1A30 )",&sC___24 }; - static COMMANDS sC___26 = {0,"SET",3,"FIXED (\1A00)","Set( _SET_FIXED, \1A00 )",&sC___25 }; - static COMMANDS sC___27 = {0,"SET",3,"DECIMALS TO \1A00","Set( _SET_DECIMALS, \1A00 )",&sC___26 }; - static COMMANDS sC___28 = {0,"SET",3,"DECIMALS TO","Set( _SET_DECIMALS, 0 )",&sC___27 }; - static COMMANDS sC___29 = {0,"SET",3,"PATH TO \1A30","Set( _SET_PATH, \1A30 )",&sC___28 }; - static COMMANDS sC___30 = {0,"SET",3,"PATH TO","Set( _SET_PATH, "" )",&sC___29 }; - static COMMANDS sC___31 = {0,"SET",3,"DEFAULT TO \1A40","Set( _SET_DEFAULT, \1A30 )",&sC___30 }; - static COMMANDS sC___32 = {0,"SET",3,"DEFAULT TO","Set( _SET_DEFAULT, "" )",&sC___31 }; - static COMMANDS sC___33 = {0,"SET",3,"CENTURY \1A20ON,OFF,&>","__SetCentury( \1A30 )",&sC___32 }; - static COMMANDS sC___34 = {0,"SET",3,"CENTURY (\1A00)","__SetCentury( \1A00 )",&sC___33 }; - static COMMANDS sC___35 = {0,"SET",3,"EPOCH TO \1A00","Set( _SET_EPOCH, \1A00 )",&sC___34 }; - static COMMANDS sC___36 = {0,"SET",3,"DATE FORMAT \2TO\3 \1A00","Set( _SET_DATEFORMAT, \1A00 )",&sC___35 }; - static COMMANDS sC___37 = {0,"SET",3,"DATE \2TO\3 AMERICAN","_DFSET( 'mm/dd/yyyy', 'mm/dd/yy' )",&sC___36 }; - static COMMANDS sC___38 = {0,"SET",3,"DATE \2TO\3 ANSI","_DFSET( 'yyyy.mm.dd', 'yy.mm.dd' )",&sC___37 }; - static COMMANDS sC___39 = {0,"SET",3,"DATE \2TO\3 BRITISH","_DFSET( 'dd/mm/yyyy', 'dd/mm/yy' )",&sC___38 }; - static COMMANDS sC___40 = {0,"SET",3,"DATE \2TO\3 FRENCH","_DFSET( 'dd/mm/yyyy', 'dd/mm/yy' )",&sC___39 }; - static COMMANDS sC___41 = {0,"SET",3,"DATE \2TO\3 GERMAN","_DFSET( 'dd.mm.yyyy', 'dd.mm.yy' )",&sC___40 }; - static COMMANDS sC___42 = {0,"SET",3,"DATE \2TO\3 ITALIAN","_DFSET( 'dd-mm-yyyy', 'dd-mm-yy' )",&sC___41 }; - static COMMANDS sC___43 = {0,"SET",3,"DATE \2TO\3 JAPANESE","_DFSET( 'yyyy/mm/dd', 'yy/mm/dd' )",&sC___42 }; - static COMMANDS sC___44 = {0,"SET",3,"DATE \2TO\3 USA","_DFSET( 'mm-dd-yyyy', 'mm-dd-yy' )",&sC___43 }; - static COMMANDS sC___45 = {0,"SET",3,"ALTERNATE \1A20ON,OFF,&>","Set( _SET_ALTERNATE, \1A30 )",&sC___44 }; - static COMMANDS sC___46 = {0,"SET",3,"ALTERNATE (\1A00)","Set( _SET_ALTERNATE, \1A00 )",&sC___45 }; - static COMMANDS sC___47 = {0,"SET",3,"ALTERNATE TO","Set( _SET_ALTFILE, "" )",&sC___46 }; - static COMMANDS sC___48 = {0,"SET",3,"ALTERNATE TO \1A40 \2\1B20 ADDITIVE>\3","Set( _SET_ALTFILE, \1A30, \1B50 )",&sC___47 }; - static COMMANDS sC___49 = {0,"SET",3,"CONSOLE \1A20ON,OFF,&>","Set( _SET_CONSOLE, \1A30 )",&sC___48 }; - static COMMANDS sC___50 = {0,"SET",3,"CONSOLE (\1A00)","Set( _SET_CONSOLE, \1A00 )",&sC___49 }; - static COMMANDS sC___51 = {0,"SET",3,"MARGIN TO \1A00","Set( _SET_MARGIN, \1A00 )",&sC___50 }; - static COMMANDS sC___52 = {0,"SET",3,"MARGIN TO","Set( _SET_MARGIN, 0 )",&sC___51 }; - static COMMANDS sC___53 = {0,"SET",3,"PRINTER \1A20ON,OFF,&>","Set( _SET_PRINTER, \1A30 )",&sC___52 }; - static COMMANDS sC___54 = {0,"SET",3,"PRINTER (\1A00)","Set( _SET_PRINTER, \1A00 )",&sC___53 }; - static COMMANDS sC___55 = {0,"SET",3,"PRINTER TO","Set( _SET_PRINTFILE, '""' )",&sC___54 }; - static COMMANDS sC___56 = {0,"SET",3,"PRINTER TO \1A40 \2\1B20 ADDITIVE>\3","Set( _SET_PRINTFILE, \1A30, \1B50 )",&sC___55 }; - static COMMANDS sC___57 = {0,"SET",3,"DEVICE TO SCREEN","Set( _SET_DEVICE, 'SCREEN' )",&sC___56 }; - static COMMANDS sC___58 = {0,"SET",3,"DEVICE TO PRINTER","Set( _SET_DEVICE, 'PRINTER' )",&sC___57 }; - static COMMANDS sC___59 = {0,"SET",3,"COLOR TO \2\1A30\3","SetColor( \1A10 )",&sC___58 }; - static COMMANDS sC___60 = {0,"SET",3,"COLOR TO ( \1A00 )","SetColor( \1A00 )",&sC___59 }; - static COMMANDS sC___61 = {0,"SET",3,"COLOUR TO \2\1A30\3","SET COLOR TO \2\1A00\3",&sC___60 }; - static COMMANDS sC___62 = {0,"SET",3,"CURSOR \1A20ON,OFF,&>","SetCursor( if(Upper(\1A30) == 'ON', 1, 0) )",&sC___61 }; - static COMMANDS sC___63 = {0,"SET",3,"CURSOR (\1A00)","SetCursor( if(\1A00, 1, 0) )",&sC___62 }; - static COMMANDS sC___64 = {0,"?",1,"\2 \1A10\3","QOut( \1A00 )",&sC___63 }; - static COMMANDS sC___65 = {0,"?",1,"? \2 \1A10\3","QQOut( \1A00 )",&sC___64 }; - static COMMANDS sC___66 = {0,"EJECT",5,"","__Eject()",&sC___65 }; - static COMMANDS sC___67 = {0,"TEXT",4,"","#pragma __text|QOut(%s)|QQOut()",&sC___66 }; - static COMMANDS sC___68 = {0,"TEXT",4,"TO FILE \1A40","#pragma __text|QOut(%s)|__TextRestore()|__TextSave( \1A30 )",&sC___67 }; - static COMMANDS sC___69 = {0,"TEXT",4,"TO PRINTER","#pragma __text|QOut(%s)|__TextRestore()|__TextSave('PRINTER')",&sC___68 }; - static COMMANDS sC___70 = {0,"CLS",3,"","Scroll() ; SetPos(0,0)",&sC___69 }; - static COMMANDS sC___71 = {0,"CLEAR",5,"SCREEN","CLS",&sC___70 }; - static COMMANDS sC___72 = {0,"@",1,"\1A00, \1B00","Scroll( \1A00, \1B00, \1A00 ) ; SetPos( \1A00, \1B00 )",&sC___71 }; - static COMMANDS sC___73 = {0,"@",1,"\1A00, \1B00 CLEAR","Scroll( \1A00, \1B00 ) ; SetPos( \1A00, \1B00 )",&sC___72 }; - static COMMANDS sC___74 = {0,"@",1,"\1A00, \1B00 CLEAR TO \1C00, \1D00", - "Scroll( \1A00, \1B00, \1C00, \1D00 ) ; SetPos( \1A00, \1B00 )",&sC___73 }; - static COMMANDS sC___75 = {0,"@",1,"\1A00, \1B00, \1C00, \1D00 BOX \1E00 \2COLOR \1F00\3", - "DispBox( \1A00, \1B00, \1C00, \1D00, \1E00 \2, \1F00 \3 )",&sC___74 }; - static COMMANDS sC___76 = {0,"@",1,"\1A00, \1B00 TO \1C00, \1D00 \2DOUBLE\3 \2COLOR \1E00\3", - "DispBox( \1A00, \1B00, \1C00, \1D00, 2 \2, \1E00 \3 )",&sC___75 }; - static COMMANDS sC___77 = {0,"@",1,"\1A00, \1B00 TO \1C00, \1D00 \2COLOR \1E00\3", - "DispBox( \1A00, \1B00, \1C00, \1D00, 1 \2, \1E00 \3 )",&sC___76 }; - static COMMANDS sC___78 = {0,"@",1,"\1A00, \1B00 SAY \1C00 \2PICTURE \1D00\3 \2COLOR \1E00\3", - "DevPos( \1A00, \1B00 ) ; DevOutPict( \1C00, \1D00 \2, \1E00\3 )",&sC___77 }; - static COMMANDS sC___79 = {0,"@",1,"\1A00, \1B00 SAY \1C00 \2COLOR \1D00\3", - "DevPos( \1A00, \1B00 ) ; DevOut( \1C00 \2, \1D00\3 )",&sC___78 }; - static COMMANDS sC___80 = {0,"SET",3,"BELL \1A20ON,OFF,&>","Set( _SET_BELL, \1A30 )",&sC___79 }; - static COMMANDS sC___81 = {0,"SET",3,"BELL (\1A00)","Set( _SET_BELL, \1A00 )",&sC___80 }; - static COMMANDS sC___82 = {0,"SET",3,"CONFIRM \1A20ON,OFF,&>","Set( _SET_CONFIRM, \1A30 )",&sC___81 }; - static COMMANDS sC___83 = {0,"SET",3,"CONFIRM (\1A00)","Set( _SET_CONFIRM, \1A00 )",&sC___82 }; - static COMMANDS sC___84 = {0,"SET",3,"ESCAPE \1A20ON,OFF,&>","Set( _SET_ESCAPE, \1A30 )",&sC___83 }; - static COMMANDS sC___85 = {0,"SET",3,"ESCAPE (\1A00)","Set( _SET_ESCAPE, \1A00 )",&sC___84 }; - static COMMANDS sC___86 = {0,"SET",3,"INTENSITY \1A20ON,OFF,&>","Set( _SET_INTENSITY, \1A30 )",&sC___85 }; - static COMMANDS sC___87 = {0,"SET",3,"INTENSITY (\1A00)","Set( _SET_INTENSITY, \1A00 )",&sC___86 }; - static COMMANDS sC___88 = {0,"SET",3,"SCOREBOARD \1A20ON,OFF,&>","Set( _SET_SCOREBOARD, \1A30 )",&sC___87 }; - static COMMANDS sC___89 = {0,"SET",3,"SCOREBOARD (\1A00)","Set( _SET_SCOREBOARD, \1A00 )",&sC___88 }; - static COMMANDS sC___90 = {0,"SET",3,"DELIMITERS \1A20ON,OFF,&>","Set( _SET_DELIMITERS, \1A30 )",&sC___89 }; - static COMMANDS sC___91 = {0,"SET",3,"DELIMITERS (\1A00)","Set( _SET_DELIMITERS, \1A00 )",&sC___90 }; - static COMMANDS sC___92 = {0,"SET",3,"DELIMITERS TO \1A00","Set( _SET_DELIMCHARS, \1A00 )",&sC___91 }; - static COMMANDS sC___93 = {0,"SET",3,"DELIMITERS TO DEFAULT","Set( _SET_DELIMCHARS, '::' )",&sC___92 }; - static COMMANDS sC___94 = {0,"SET",3,"DELIMITERS TO","Set( _SET_DELIMCHARS, '::' )",&sC___93 }; - static COMMANDS sC___95 = {0,"SET",3,"FORMAT TO \1A00","_ProcReq_( \1A30 + '.fmt' ) ; __SetFormat( {|| \1A00()} )",&sC___94 }; - static COMMANDS sC___96 = {0,"SET",3,"FORMAT TO \1A00.\1B00", - "_ProcReq_( \1A30 + '.' + \1B30 ) ; __SetFormat( {|| \1A00()} )",&sC___95 }; - static COMMANDS sC___97 = {0,"SET",3,"FORMAT TO \1A20&>", - "if ( Empty(\1A30) ) ; SET FORMAT TO ; else ; __SetFormat( &('{||' + \1A30 + '()}') ) ; end",&sC___96 }; - static COMMANDS sC___98 = {0,"SET",3,"FORMAT TO","__SetFormat()",&sC___97 }; - static COMMANDS sC___99 = {0,"@",1,"\1A00, \1B00 GET \1C00 \2PICTURE \1D00\3 \2VALID \1E00\3 \2WHEN \1F00\3 \2SEND \1G00\3", - "SetPos( \1A00, \1B00 ) ; AAdd( GetList, _GET_( \1C00, \1C20, \1D00, \1E40, \1F40 ):display() ) \2; ATail(GetList):\1G00\3",&sC___98 }; - static COMMANDS sC___100 = {0,"@",1,"\1A00, \1B00 SAY \1C00 \2\1D10\3 GET \1E00 \2\1F10\3", - "@ \1A00, \1B00 SAY \1C00 \2\1D00\3 ; @ Row(), Col()+1 GET \1E00 \2\1F00\3",&sC___99 }; - static COMMANDS sC___101 = {0,"@",1,"\1A00, \1B00 GET \1C00 \2\1D10\3 RANGE \1E00, \1F00 \2\1G10\3", - "@ \1A00, \1B00 GET \1C00 \2\1D00\3 VALID {|_1| RangeCheck(_1,, \1E00, \1F00)} \2\1G00\3",&sC___100 }; - static COMMANDS sC___102 = {0,"@",1,"\1A00, \1B00 GET \1C00 \2\1D10\3 COLOR \1E00 \2\1F10\3", - "@ \1A00, \1B00 GET \1C00 \2\1D00\3 SEND colorDisp(\1E00) \2\1F00\3",&sC___101 }; - static COMMANDS sC___103 = {0,"READ",4,"SAVE","ReadModal(GetList)",&sC___102 }; - static COMMANDS sC___104 = {0,"READ",4,"","ReadModal(GetList) ; GetList := {}",&sC___103 }; - static COMMANDS sC___105 = {0,"CLEAR",5,"GETS","ReadKill(.T.) ; GetList := {}",&sC___104 }; - static COMMANDS sC___106 = {0,"@",1,"\2\1A10\3 COLOUR \2\1B10\3","@ \2\1A00\3 COLOR \2\1B00\3",&sC___105 }; - static COMMANDS sC___107 = {0,"SET",3,"WRAP \1A20ON,OFF,&>","Set( _SET_WRAP, \1A30 )",&sC___106 }; - static COMMANDS sC___108 = {0,"SET",3,"WRAP (\1A00)","Set( _SET_WRAP, \1A00 )",&sC___107 }; - static COMMANDS sC___109 = {0,"SET",3,"MESSAGE TO \1A00 \2\1B20 CENTER, CENTRE>\3", - "Set( _SET_MESSAGE, \1A00 ) ; Set( _SET_MCENTER, \1B50 )",&sC___108 }; - static COMMANDS sC___110 = {0,"SET",3,"MESSAGE TO","Set( _SET_MESSAGE, 0 ) ; Set( _SET_MCENTER, .F. )",&sC___109 }; - static COMMANDS sC___111 = {0,"@",1,"\1A00, \1B00 PROMPT \1C00 \2MESSAGE \1D00\3 \2COLOR \1E00\3", - "__AtPrompt( \1A00, \1B00, \1C00 , \1D00 , \1E00 )",&sC___110 }; - static COMMANDS sC___112 = {0,"MENU",4,"TO \1A00","\1A00 := __MenuTo( {|_1| if(PCount() == 0, \1A00, \1A00 := _1)}, \1A10 )",&sC___111 }; - static COMMANDS sC___113 = {0,"SAVE",4,"SCREEN","__XSaveScreen()",&sC___112 }; - static COMMANDS sC___114 = {0,"RESTORE",7,"SCREEN","__XRestScreen()",&sC___113 }; - static COMMANDS sC___115 = {0,"SAVE",4,"SCREEN TO \1A00","\1A00 := SaveScreen( 0, 0, Maxrow(), Maxcol() )",&sC___114 }; - static COMMANDS sC___116 = {0,"RESTORE",7,"SCREEN FROM \1A00","RestScreen( 0, 0, Maxrow(), Maxcol(), \1A00 )",&sC___115 }; - static COMMANDS sC___117 = {0,"WAIT",4,"\2\1A00\3","__Wait( \1A00 )",&sC___116 }; - static COMMANDS sC___118 = {0,"WAIT",4,"\2\1A00\3 TO \1B00","\1B00 := __Wait( \1A00 )",&sC___117 }; - static COMMANDS sC___119 = {0,"ACCEPT",6,"\2\1A00\3 TO \1B00","\1B00 := __Accept( \1A00 )",&sC___118 }; - static COMMANDS sC___120 = {0,"INPUT",5,"\2\1A00\3 TO \1B00", - "if ( !Empty(__Accept(\1A00)) ) ; \1B00 := &( __AcceptStr() ) ; end",&sC___119 }; - static COMMANDS sC___121 = {0,"KEYBOARD",8,"\1A00","__Keyboard( \1A00 )",&sC___120 }; - static COMMANDS sC___122 = {0,"CLEAR",5,"TYPEAHEAD","__Keyboard()",&sC___121 }; - static COMMANDS sC___123 = {0,"SET",3,"TYPEAHEAD TO \1A00","Set( _SET_TYPEAHEAD, \1A00 )",&sC___122 }; - static COMMANDS sC___124 = {0,"SET",3,"KEY \1A00 TO \1B00","SetKey( \1A00, {|p, l, v| \1B00(p, l, v)} )",&sC___123 }; - static COMMANDS sC___125 = {0,"SET",3,"KEY \1A00 TO \1B00 ( \2\1C10\3 )","SET KEY \1A00 TO \1B00",&sC___124 }; - static COMMANDS sC___126 = {0,"SET",3,"KEY \1A00 TO \1B20&>", - "if ( Empty(\1B30) ) ; SetKey( \1A00, NIL ) ; else ; SetKey( \1A00, {|p, l, v| \1B00(p, l, v)} ) ; end",&sC___125 }; - static COMMANDS sC___127 = {0,"SET",3,"KEY \1A00 \2TO\3","SetKey( \1A00, NIL )",&sC___126 }; - static COMMANDS sC___128 = {0,"SET",3,"FUNCTION \1A00 \2TO\3 \2\1B00\3","__SetFunction( \1A00, \1B00 )",&sC___127 }; - static COMMANDS sC___129 = {0,"CLEAR",5,"MEMORY","__MVClear()",&sC___128 }; - static COMMANDS sC___130 = {0,"RELEASE",7," \1A10","__MVXRelease( \1A30 )",&sC___129 }; - static COMMANDS sC___131 = {0,"RELEASE",7,"ALL","__MVRelease('*', .T.)",&sC___130 }; - static COMMANDS sC___132 = {0,"RELEASE",7,"ALL LIKE \1A00","__MVRelease( \1A10, .T. )",&sC___131 }; - static COMMANDS sC___133 = {0,"RELEASE",7,"ALL EXCEPT \1A00","__MVRelease( \1A10, .F. )",&sC___132 }; - static COMMANDS sC___134 = {0,"RESTORE",7,"\2FROM \1A40\3 \2\1B20 ADDITIVE>\3","__MVRestore( \1A30, \1B50 )",&sC___133 }; - static COMMANDS sC___135 = {0,"SAVE",4,"ALL LIKE \1A00 TO \1B40","__MVSave( \1B30, \1A30, .T. )",&sC___134 }; - static COMMANDS sC___136 = {0,"SAVE",4,"TO \1A40 ALL LIKE \1B00","__MVSave( \1A30, \1B30, .T. )",&sC___135 }; - static COMMANDS sC___137 = {0,"SAVE",4,"ALL EXCEPT \1A00 TO \1B40","__MVSave( \1B30, \1A30, .F. )",&sC___136 }; - static COMMANDS sC___138 = {0,"SAVE",4,"TO \1A40 ALL EXCEPT \1B00","__MVSave( \1A30, \1B30, .F. )",&sC___137 }; - static COMMANDS sC___139 = {0,"SAVE",4,"\2TO \1A40\3 \2ALL\3","__MVSave( \1A30, '*', .T. )",&sC___138 }; - static COMMANDS sC___140 = {0,"ERASE",5,"\1A40","FErase( \1A30 )",&sC___139 }; - static COMMANDS sC___141 = {0,"DELETE",6,"FILE \1A40","FErase( \1A30 )",&sC___140 }; - static COMMANDS sC___142 = {0,"RENAME",6,"\1A40 TO \1B40","FRename( \1A30, \1B30 )",&sC___141 }; - static COMMANDS sC___143 = {0,"COPY",4,"FILE \1A40 TO \1B40","__CopyFile( \1A30, \1B30 )",&sC___142 }; - static COMMANDS sC___144 = {0,"DIR",3,"\2\1A40\3","__Dir( \1A30 )",&sC___143 }; - static COMMANDS sC___145 = {0,"TYPE",4,"\1A40 \2\1B20 TO PRINTER>\3 \2TO FILE \1C40\3", - "__TypeFile( \1A30, \1B50 ) \2; COPY FILE \1A30 TO \1C30 \3",&sC___144 }; - static COMMANDS sC___146 = {0,"TYPE",4,"\1A40 \2\1B20 TO PRINTER>\3","__TypeFile( \1A30, \1B50 )",&sC___145 }; - static COMMANDS sC___147 = {0,"REQUEST",7,"\1A10","EXTERNAL \1A00",&sC___146 }; - static COMMANDS sC___148 = {0,"CANCEL",6,"","__Quit()",&sC___147 }; - static COMMANDS sC___149 = {0,"QUIT",4,"","__Quit()",&sC___148 }; - static COMMANDS sC___150 = {0,"RUN",3,"\1A30","__Run( \1A10 )",&sC___149 }; - static COMMANDS sC___151 = {0,"RUN",3,"( \1A00 )","__Run( \1A00 )",&sC___150 }; - static COMMANDS sC___152 = {0,"!",1,"\1A30","RUN \1A00",&sC___151 }; - static COMMANDS sC___153 = {0,"RUN",3,"= \1A00","( run := \1A00 )",&sC___152 }; - static COMMANDS sC___154 = {0,"RUN",3,":= \1A00","( run := \1A00 )",&sC___153 }; - static COMMANDS sC___155 = {0,"SET",3,"EXCLUSIVE \1A20ON,OFF,&>","Set( _SET_EXCLUSIVE, \1A30 )",&sC___154 }; - static COMMANDS sC___156 = {0,"SET",3,"EXCLUSIVE (\1A00)","Set( _SET_EXCLUSIVE, \1A00 )",&sC___155 }; - static COMMANDS sC___157 = {0,"SET",3,"SOFTSEEK \1A20ON,OFF,&>","Set( _SET_SOFTSEEK, \1A30 )",&sC___156 }; - static COMMANDS sC___158 = {0,"SET",3,"SOFTSEEK (\1A00)","Set( _SET_SOFTSEEK, \1A00 )",&sC___157 }; - static COMMANDS sC___159 = {0,"SET",3,"UNIQUE \1A20ON,OFF,&>","Set( _SET_UNIQUE, \1A30 )",&sC___158 }; - static COMMANDS sC___160 = {0,"SET",3,"UNIQUE (\1A00)","Set( _SET_UNIQUE, \1A00 )",&sC___159 }; - static COMMANDS sC___161 = {0,"SET",3,"DELETED \1A20ON,OFF,&>","Set( _SET_DELETED, \1A30 )",&sC___160 }; - static COMMANDS sC___162 = {0,"SET",3,"DELETED (\1A00)","Set( _SET_DELETED, \1A00 )",&sC___161 }; - static COMMANDS sC___163 = {0,"SELECT",6,"\1A00","dbSelectArea( \1A30 )",&sC___162 }; - static COMMANDS sC___164 = {0,"SELECT",6,"\1A00(\2\1B10\3)","dbSelectArea( \1A00(\1B00) )",&sC___163 }; - static COMMANDS sC___165 = {0,"USE",3,"","dbCloseArea()",&sC___164 }; - static COMMANDS sC___166 = {0,"USE",3,"\1A40 \2VIA \1B00\3 \2ALIAS \1C00\3 \2\1D20 NEW>\3 \2\1E20 EXCLUSIVE>\3 \2\1F20 SHARED>\3 \2\1G20 READONLY>\3 \2CODEPAGE \1H00\3 \2INDEX \1I40 \2, \1J40\3\3", - "dbUseArea( \1D50, \1B00, \1A30, \1C30, if(\1F50 .or. \1E50, !\1E50, NIL), \1G50, \1H30 ) \2; dbSetIndex( \1I30 )\3 \2; dbSetIndex( \1J30 )\3",&sC___165 }; - static COMMANDS sC___167 = {0,"APPEND",6,"BLANK","dbAppend()",&sC___166 }; - static COMMANDS sC___168 = {0,"PACK",4,"","__dbPack()",&sC___167 }; - static COMMANDS sC___169 = {0,"ZAP",3,"","__dbZap()",&sC___168 }; - static COMMANDS sC___170 = {0,"UNLOCK",6,"","dbUnlock()",&sC___169 }; - static COMMANDS sC___171 = {0,"UNLOCK",6,"ALL","dbUnlockAll()",&sC___170 }; - static COMMANDS sC___172 = {0,"COMMIT",6,"","dbCommitAll()",&sC___171 }; - static COMMANDS sC___173 = {0,"GOTO",4,"\1A00","dbGoto(\1A00)",&sC___172 }; - static COMMANDS sC___174 = {0,"GO",2,"\1A00","dbGoto(\1A00)",&sC___173 }; - static COMMANDS sC___175 = {0,"GOTO",4,"TOP","dbGoTop()",&sC___174 }; - static COMMANDS sC___176 = {0,"GO",2,"TOP","dbGoTop()",&sC___175 }; - static COMMANDS sC___177 = {0,"GOTO",4,"BOTTOM","dbGoBottom()",&sC___176 }; - static COMMANDS sC___178 = {0,"GO",2,"BOTTOM","dbGoBottom()",&sC___177 }; - static COMMANDS sC___179 = {0,"SKIP",4,"","dbSkip(1)",&sC___178 }; - static COMMANDS sC___180 = {0,"SKIP",4,"\1A00","dbSkip( \1A00 )",&sC___179 }; - static COMMANDS sC___181 = {0,"SKIP",4,"ALIAS \1A00","\1A00 -> ( dbSkip(1) )",&sC___180 }; - static COMMANDS sC___182 = {0,"SKIP",4,"\1A00 ALIAS \1B00","\1B00 -> ( dbSkip(\1A00) )",&sC___181 }; - static COMMANDS sC___183 = {0,"SEEK",4,"\1A00 \2\1B20 SOFTSEEK>\3","dbSeek( \1A00, if( \1B50, .T., NIL ) )",&sC___182 }; - static COMMANDS sC___184 = {0,"FIND",4,"\1A30","dbSeek( \1A30 )",&sC___183 }; - static COMMANDS sC___185 = {0,"FIND",4,":= \1A00","( find := \1A00 )",&sC___184 }; - static COMMANDS sC___186 = {0,"FIND",4,"= \1A00","( find := \1A00 )",&sC___185 }; - static COMMANDS sC___187 = {0,"CONTINUE",8,"","__dbContinue()",&sC___186 }; - static COMMANDS sC___188 = {0,"LOCATE",6,"\2FOR \1A00\3 \2WHILE \1B00\3 \2NEXT \1C00\3 \2RECORD \1D00\3 \2\1E20REST>\3 \2ALL\3", - "__dbLocate(\1A40,\1B40,\1C00,\1D00,\1E50)",&sC___187 }; - static COMMANDS sC___189 = {0,"SET",3,"RELATION TO","dbClearRelation()",&sC___188 }; - static COMMANDS sC___190 = {0,"SET",3,"RELATION \2\1A20 ADDITIVE>\3 \2TO \1C00 INTO \1D40 \2\1B20 SCOPED>\3 \2,\2TO\3 \1E00 INTO \1F40 \2\1G20 SCOPED>\3\3\3", - "if (!\1A50 ) ; dbClearRelation() ; end ; dbSetRelation(\1D30,\1C40,\1C20,\1B50 ) \2; dbSetRelation(\1F30,\1E40,\1E20,\1G50 )\3",&sC___189 }; - static COMMANDS sC___191 = {0,"SET",3,"FILTER TO","dbClearFilter(NIL)",&sC___190 }; - static COMMANDS sC___192 = {0,"SET",3,"FILTER TO \1A00","dbSetFilter( \1A40, \1A20 )",&sC___191 }; - static COMMANDS sC___193 = {0,"SET",3,"FILTER TO \1A20&>", - "if ( Empty(\1A30) ) ; dbClearFilter() ; else ; dbSetFilter(\1A40,\1A30) ; end",&sC___192 }; - static COMMANDS sC___194 = {0,"REPLACE",7,"\2 \1A00 WITH \1B00 \2, \1C00 WITH \1D00\3 \3 \2FOR \1E00\3 \2WHILE \1F00\3 \2NEXT \1G00\3 \2RECORD \1H00\3 \2\1I20REST>\3 \2ALL\3", - "DBEval( {|| _FIELD->\1A00 := \1B00 \2,_FIELD->\1C00 := \1D00\3},\1E40,\1F40,\1G00,\1H00,\1I50)",&sC___193 }; - static COMMANDS sC___195 = {0,"REPLACE",7,"\1A00 WITH \1B00 \2, \1C00 WITH \1D00 \3", - "_FIELD->\1A00 := \1B00 \2; _FIELD->\1C00 := \1D00\3",&sC___194 }; - static COMMANDS sC___196 = {0,"DELETE",6,"\2FOR \1A00\3 \2WHILE \1B00\3 \2NEXT \1C00\3 \2RECORD \1D00\3 \2\1E20REST>\3 \2ALL\3", - "DBEval( {|| dbDelete()}, \1A40, \1B40, \1C00, \1D00, \1E50 )",&sC___195 }; - static COMMANDS sC___197 = {0,"RECALL",6,"\2FOR \1A00\3 \2WHILE \1B00\3 \2NEXT \1C00\3 \2RECORD \1D00\3 \2\1E20REST>\3 \2ALL\3", - "DBEval( {|| dbRecall()}, \1A40, \1B40, \1C00, \1D00, \1E50 )",&sC___196 }; - static COMMANDS sC___198 = {0,"DELETE",6,"","dbDelete()",&sC___197 }; - static COMMANDS sC___199 = {0,"RECALL",6,"","dbRecall()",&sC___198 }; - static COMMANDS sC___200 = {0,"CREATE",6,"\1A40 \2FROM \1B40\3 \2VIA \1C00\3 \2ALIAS \1D00\3 \2\1E20 NEW>\3 \2CODEPAGE \1F00\3", - "__dbCreate( \1A30, \1B30, \1C00, \1E50, \1D30, \1F30 )",&sC___199 }; - static COMMANDS sC___201 = {0,"COPY",4,"\2STRUCTURE\3 \2EXTENDED\3 \2TO \1A40\3","__dbCopyXStruct( \1A30 )",&sC___200 }; - static COMMANDS sC___202 = {0,"COPY",4,"\2STRUCTURE\3 \2TO \1A40\3 \2FIELDS \1B10\3","__dbCopyStruct( \1A30, { \1B30 } )",&sC___201 }; - static COMMANDS sC___203 = {0,"COPY",4,"\2TO \1A40\3 \2DELIMITED \2WITH \1B30\3\3 \2FIELDS \1C10\3 \2FOR \1D00\3 \2WHILE \1E00\3 \2NEXT \1F00\3 \2RECORD \1G00\3 \2\1H20REST>\3 \2ALL\3", - "__dbDelim( .T., \1A30, \1B30, { \1C30 }, \1D40, \1E40, \1F00, \1G00, \1H50 )",&sC___202 }; - static COMMANDS sC___204 = {0,"COPY",4,"\2TO \1A40\3 \2SDF\3 \2FIELDS \1B10\3 \2FOR \1C00\3 \2WHILE \1D00\3 \2NEXT \1E00\3 \2RECORD \1F00\3 \2\1G20REST>\3 \2ALL\3", - "__dbSDF( .T., \1A30, { \1B30 }, \1C40, \1D40, \1E00, \1F00, \1G50 )",&sC___203 }; - static COMMANDS sC___205 = {0,"COPY",4,"\2TO \1A40\3 \2FIELDS \1B10\3 \2FOR \1C00\3 \2WHILE \1D00\3 \2NEXT \1E00\3 \2RECORD \1F00\3 \2\1G20REST>\3 \2VIA \1H00\3 \2ALL\3", - "__dbCopy( \1A30, { \1B30 }, \1C40, \1D40, \1E00, \1F00, \1G50, \1H00 )",&sC___204 }; - static COMMANDS sC___206 = {0,"APPEND",6,"\2FROM \1A40\3 \2DELIMITED \2WITH \1B30\3\3 \2FIELDS \1C10\3 \2FOR \1D00\3 \2WHILE \1E00\3 \2NEXT \1F00\3 \2RECORD \1G00\3 \2\1H20REST>\3 \2ALL\3", - "__dbDelim( .F., \1A30, \1B30, { \1C30 }, \1D40, \1E40, \1F00, \1G00, \1H50 )",&sC___205 }; - static COMMANDS sC___207 = {0,"APPEND",6,"\2FROM \1A40\3 \2SDF\3 \2FIELDS \1B10\3 \2FOR \1C00\3 \2WHILE \1D00\3 \2NEXT \1E00\3 \2RECORD \1F00\3 \2\1G20REST>\3 \2ALL\3", - "__dbSDF( .F., \1A30, { \1B30 }, \1C40, \1D40, \1E00, \1F00, \1G50 )",&sC___206 }; - static COMMANDS sC___208 = {0,"APPEND",6,"\2FROM \1A40\3 \2FIELDS \1B10\3 \2FOR \1C00\3 \2WHILE \1D00\3 \2NEXT \1E00\3 \2RECORD \1F00\3 \2\1G20REST>\3 \2VIA \1H00\3 \2ALL\3", - "__dbApp( \1A30, { \1B30 }, \1C40, \1D40, \1E00, \1F00, \1G50, \1H00 )",&sC___207 }; - static COMMANDS sC___209 = {0,"SORT",4,"\2TO \1A40\3 \2ON \1B10\3 \2FOR \1C00\3 \2WHILE \1D00\3 \2NEXT \1E00\3 \2RECORD \1F00\3 \2\1G20REST>\3 \2ALL\3", - "__dbSort( \1A30, { \1B30 }, \1C40, \1D40, \1E00, \1F00, \1G50 )",&sC___208 }; - static COMMANDS sC___210 = {0,"TOTAL",5,"\2TO \1A40\3 \2ON \1B00\3 \2FIELDS \1C10\3 \2FOR \1D00\3 \2WHILE \1E00\3 \2NEXT \1F00\3 \2RECORD \1G00\3 \2\1H20REST>\3 \2ALL\3", - "__dbTotal( \1A30, \1B40, { \1C30 }, \1D40, \1E40, \1F00, \1G00, \1H50 )",&sC___209 }; - static COMMANDS sC___211 = {0,"UPDATE",6,"\2FROM \1A40\3 \2ON \1B00\3 \2REPLACE \1C00 WITH \1D00 \2, \1E00 WITH \1F00\3\3 \2\1G20RANDOM>\3", - "__dbUpdate( \1A30, \1B40, \1G50, {|| _FIELD->\1C00 := \1D00 \2, _FIELD->\1E00 := \1F00\3} )",&sC___210 }; - static COMMANDS sC___212 = {0,"JOIN",4,"\2WITH \1A40\3 \2TO \1B00\3 \2FIELDS \1C10\3 \2FOR \1D00\3", - "__dbJoin( \1A30, \1B30, { \1C30 }, \1D40 )",&sC___211 }; - static COMMANDS sC___213 = {0,"COUNT",5,"\2TO \1A00\3 \2FOR \1B00\3 \2WHILE \1C00\3 \2NEXT \1D00\3 \2RECORD \1E00\3 \2\1F20REST>\3 \2ALL\3", - "\1A00 := 0 ; DBEval( {|| \1A00++}, \1B40, \1C40, \1D00, \1E00, \1F50 )",&sC___212 }; - static COMMANDS sC___214 = {0,"SUM",3,"\2 \1A00 \2, \1B00\3 TO \1C00 \2, \1D00\3 \3 \2FOR \1E00\3 \2WHILE \1F00\3 \2NEXT \1G00\3 \2RECORD \1H00\3 \2\1I20REST>\3 \2ALL\3", - "\1C00 := \2 \1D00 := \3 0 ; DBEval( {|| \1C00 += \1A00 \2, \1D00 += \1B00 \3}, \1E40, \1F40, \1G00, \1H00, \1I50 )",&sC___213 }; - static COMMANDS sC___215 = {0,"AVERAGE",7,"\2 \1A00 \2, \1B00\3 TO \1C00 \2, \1D00\3 \3 \2FOR \1E00\3 \2WHILE \1F00\3 \2NEXT \1G00\3 \2RECORD \1H00\3 \2\1I20REST>\3 \2ALL\3", - "M->__Avg := \1C00 := \2 \1D00 := \3 0 ; DBEval( {|| M->__Avg := M->__Avg + 1, \1C00 := \1C00 + \1A00 \2, \1D00 := \1D00 + \1B00\3 }, \1E40, \1F40, \1G00, \1H00, \1I50 ) ; \1C00 := \1C00 / M->__Avg \2; \1D00 := \1D00 / M->__Avg \3",&sC___214 }; - static COMMANDS sC___216 = {0,"LIST",4,"\2\1A10\3 \2\1B20OFF>\3 \2\1C20 TO PRINTER>\3 \2TO FILE \1D40\3 \2FOR \1E00\3 \2WHILE \1F00\3 \2NEXT \1G00\3 \2RECORD \1H00\3 \2\1I20REST>\3 \2ALL\3", - "__dbList( \1B50, { \1A40 }, .T., \1E40, \1F40, \1G00, \1H00, \1I50, \1C50, \1D30 )",&sC___215 }; - static COMMANDS sC___217 = {0,"DISPLAY",7,"\2\1A10\3 \2\1B20OFF>\3 \2\1C20 TO PRINTER>\3 \2TO FILE \1D40\3 \2FOR \1E00\3 \2WHILE \1F00\3 \2NEXT \1G00\3 \2RECORD \1H00\3 \2\1I20REST>\3 \2\1J20ALL>\3", - "__DBList( \1B50, { \1A40 }, \1J50, \1E40, \1F40, \1G00, \1H00, \1I50, \1C50, \1D30 )",&sC___216 }; - static COMMANDS sC___218 = {0,"REPORT",6,"FORM \1A00 \2HEADING \1B00\3 \2\1C20 PLAIN>\3 \2\1D20 NOEJECT>\3 \2\1E20 SUMMARY>\3 \2\1F20 NOCONSOLE>\3 \2\1G20 TO PRINTER>\3 \2TO FILE \1H40\3 \2FOR \1I00\3 \2WHILE \1J00\3 \2NEXT \1K00\3 \2RECORD \1L00\3 \2\1M20REST>\3 \2ALL\3", - "__ReportForm( \1A30, \1G50, \1H30, \1F50, \1I40, \1J40, \1K00, \1L00, \1M50, \1C50, \1B00, \1D50, \1E50 )",&sC___217 }; - static COMMANDS sC___219 = {0,"LABEL",5,"FORM \1A00 \2\1B20 SAMPLE>\3 \2\1C20 NOCONSOLE>\3 \2\1D20 TO PRINTER>\3 \2TO FILE \1E40\3 \2FOR \1F00\3 \2WHILE \1G00\3 \2NEXT \1H00\3 \2RECORD \1I00\3 \2\1J20REST>\3 \2ALL\3", - "__LabelForm( \1A30, \1D50, \1E30, \1C50, \1F40, \1G40, \1H00, \1I00, \1J50, \1B50 )",&sC___218 }; - static COMMANDS sC___220 = {0,"CLOSE",5,"\1A00","\1A00->( dbCloseArea() )",&sC___219 }; - static COMMANDS sC___221 = {0,"CLOSE",5,"","dbCloseArea()",&sC___220 }; - static COMMANDS sC___222 = {0,"CLOSE",5,"DATABASES","dbCloseAll()",&sC___221 }; - static COMMANDS sC___223 = {0,"CLOSE",5,"ALTERNATE","Set(_SET_ALTFILE, "")",&sC___222 }; - static COMMANDS sC___224 = {0,"CLOSE",5,"FORMAT","__SetFormat(NIL)",&sC___223 }; - static COMMANDS sC___225 = {0,"CLOSE",5,"INDEXES","dbClearIndex()",&sC___224 }; - static COMMANDS sC___226 = {0,"CLOSE",5,"PROCEDURE",NULL,&sC___225 }; - static COMMANDS sC___227 = {0,"CLOSE",5,"ALL","CLOSE DATABASES ; SELECT 1 ; CLOSE FORMAT",&sC___226 }; - static COMMANDS sC___228 = {0,"CLEAR",5,"","CLEAR SCREEN ; CLEAR GETS",&sC___227 }; - static COMMANDS sC___229 = {0,"CLEAR",5,"ALL", - "CLOSE DATABASES ; CLOSE FORMAT ; CLEAR MEMORY ; CLEAR GETS ; SET ALTERNATE OFF ; SET ALTERNATE TO",&sC___228 }; - static COMMANDS sC___230 = {0,"INDEX",5,"ON \1A00 \2TAG \1B40 \3 TO \1C40 \2FOR \1D00\3 \2\1E20ALL>\3 \2WHILE \1F00\3 \2NEXT \1G00\3 \2RECORD \1H00\3 \2\1I20REST>\3 \2EVAL \1J00\3 \2EVERY \1K00\3 \2\1L20 UNIQUE>\3 \2\1M20 ASCENDING>\3 \2\1N20 DESCENDING>\3 \2\1O20 USECURRENT>\3 \2\1P20 ADDITIVE>\3 \2\1R20 CUSTOM>\3 \2\1S20 NOOPTIMIZE>\3", - "ordCondSet( \1D20, \1D40, \2\1E50\3, \1F40, \1J40, \1K00, RECNO(), \1G00, \1H00, \2\1I50\3, \2\1N50\3,, \2\1P50\3, \2\1O50\3, \2\1R50\3, \2\1S50\3, \1F20 ) ; ordCreate(\1C30, \1B30, \1A20, \1A40, \2\1L50\3 )",&sC___229 }; - static COMMANDS sC___231 = {0,"INDEX",5,"ON \1A00 TAG \1B40 \2TO \1C40\3 \2FOR \1D00\3 \2\1E20ALL>\3 \2WHILE \1F00\3 \2NEXT \1G00\3 \2RECORD \1H00\3 \2\1I20REST>\3 \2EVAL \1J00\3 \2EVERY \1K00\3 \2\1L20 UNIQUE>\3 \2\1M20 ASCENDING>\3 \2\1N20 DESCENDING>\3 \2\1O20 USECURRENT>\3 \2\1P20 ADDITIVE>\3 \2\1R20 CUSTOM>\3 \2\1S20 NOOPTIMIZE>\3", - "ordCondSet( \1D20, \1D40, \2\1E50\3, \1F40, \1J40, \1K00, RECNO(), \1G00, \1H00, \2\1I50\3, \2\1N50\3,, \2\1P50\3, \2\1O50\3, \2\1R50\3, \2\1S50\3, \1F20 ) ; ordCreate(\1C30, \1B30, \1A20, \1A40, \2\1L50\3 )",&sC___230 }; - static COMMANDS sC___232 = {0,"INDEX",5,"ON \1A00 TO \1B40 \2\1C20 UNIQUE>\3", - "dbCreateIndex( \1B30, \1A20, \1A40, if( \1C50, .T., NIL ) )",&sC___231 }; - static COMMANDS sC___233 = {0,"DELETE",6,"TAG \1A40 \2 IN \1B40 \3 \2, \1C40 \2 IN \1D40 \3 \3", - "ordDestroy( \1A30, \1B30 ) \2; ordDestroy( \1C30, \1D30 ) \3",&sC___232 }; - static COMMANDS sC___234 = {0,"REINDEX",7,"\2EVAL \1A00\3 \2EVERY \1B00\3", - "ordCondSet(,,,, \1A40, \1B00,,,,,,,) ; ordListRebuild()",&sC___233 }; - static COMMANDS sC___235 = {0,"REINDEX",7,"","ordListRebuild()",&sC___234 }; - static COMMANDS sC___236 = {0,"SET",3,"INDEX TO \2 \1A40 \2, \1B40\3\3 \2\1C20 ADDITIVE>\3", - "if !\1C50 ; ordListClear() ; end \2; ordListAdd( \1A30 )\3 \2; ordListAdd( \1B30 )\3",&sC___235 }; - static COMMANDS sC___237 = {0,"SET",3,"ORDER TO \1A00 \2IN \1B40\3","ordSetFocus( \1A00 \2, \1B30\3 )",&sC___236 }; - static COMMANDS sC___238 = {0,"SET",3,"ORDER TO TAG \1A40 \2IN \1B40\3","ordSetFocus( \1A30 \2, \1B30\3 )",&sC___237 }; - static COMMANDS sC___239 = {0,"SET",3,"ORDER TO","ordSetFocus(0)",&sC___238 }; - static COMMANDS sC___240 = {0,"SET",3,"EVENTMASK TO \1A00","Set( _SET_EVENTMASK, \1A00 )",&sC___239 }; - static COMMANDS sC___241 = {0,"SET",3,"OPTIMIZE \1A20ON,OFF,&>","Set( _SET_OPTIMIZE, \1A30 )",&sC___240 }; - static COMMANDS sC___242 = {0,"SET",3,"OPTIMIZE (\1A00)","Set( _SET_OPTIMIZE, \1A00 )",&sC___241 }; - static COMMANDS sC___243 = {0,"SET",3,"AUTOPEN \1A20 ON,OFF,&>","Set(_SET_AUTOPEN,\1A30 )",&sC___242 }; - static COMMANDS sC___244 = {0,"SET",3,"AUTOPEN (\1A00)","Set(_SET_AUTOPEN,\1A00 )",&sC___243 }; - static COMMANDS sC___245 = {0,"SET",3,"FILECASE \1A30","Set(_SET_FILECASE, \1A10 )",&sC___244 }; - static COMMANDS sC___246 = {0,"SET",3,"FILECASE ( \1A00 )","Set(_SET_FILECASE, \1A00 )",&sC___245 }; - static COMMANDS sC___247 = {0,"SET",3,"DIRCASE \1A30","Set(_SET_DIRCASE, \1A10 )",&sC___246 }; - static COMMANDS sC___248 = {0,"SET",3,"DIRCASE ( \1A00 )","Set(_SET_DIRCASE, \1A00 )",&sC___247 }; - static COMMANDS sC___249 = {0,"SET",3,"DIRSEPARATOR \1A30","Set(_SET_DIRSEPARATOR, \1A10 )",&sC___248 }; - static COMMANDS sC___250 = {0,"SET",3,"DIRSEPARATOR ( \1A00 )","Set(_SET_DIRSEPARATOR, \1A00 )",&sC___249 }; - static COMMANDS sC___251 = {0,"SET",3,"MBLOCKSIZE TO \1A00","Set( _SET_MBLOCKSIZE, \1A00 )",&sC___250 }; - static COMMANDS sC___252 = {0,"SET",3,"MEMOBLOCK TO \1A00","Set( _SET_MBLOCKSIZE, \1A00 )",&sC___251 }; - static COMMANDS sC___253 = {0,"SET",3,"MFILEEXT TO \1A00","Set( _SET_MFILEEXT, \1A00 )",&sC___252 }; - static COMMANDS sC___254 = {0,"SET",3,"AUTOSHARE TO \1A00","Set( _SET_AUTOSHARE, \1A00 )",&sC___253 }; - static COMMANDS sC___255 = {0,"SET",3,"AUTOSHARE TO","Set( _SET_AUTOSHARE, 0 )",&sC___254 }; - static COMMANDS sC___256 = {0,"SET",3,"AUTORDER TO \1A00","Set( _SET_AUTORDER, \1A00 )",&sC___255 }; - static COMMANDS sC___257 = {0,"SET",3,"AUTORDER TO","Set( _SET_AUTORDER, 0 )",&sC___256 }; - static COMMANDS sC___258 = {0,"SET",3,"STRICTREAD \1A20 ON,OFF,&>","Set(_SET_STRICTREAD,\1A30 )",&sC___257 }; - static COMMANDS sC___259 = {0,"SET",3,"STRICTREAD (\1A00)","Set(_SET_STRICTREAD,\1A00 )",&sC___258 }; - static COMMANDS sC___260 = {0,"SET",3,"HARDCOMMIT \1A20 ON,OFF,&>","Set(_SET_HARDCOMMIT,\1A30 )",&sC___259 }; - static COMMANDS sC___261 = {0,"SET",3,"HARDCOMMIT (\1A00)","Set(_SET_HARDCOMMIT,\1A00 )",&sC___260 }; - static COMMANDS sC___262 = {0,"SET",3,"DBFLOCKSCHEME TO \1A00","Set(_SET_DBFLOCKSCHEME, \1A00 )",&sC___261 }; - static COMMANDS sC___263 = {0,"SET",3,"DBFLOCKSCHEME TO","Set(_SET_DBFLOCKSCHEME, 0 )",&sC___262 }; - - hb_pp_topDefine = &sD___60; - hb_pp_topCommand = &sC___263; - hb_pp_topTranslate = NULL; -} diff --git a/harbour/examples/pp/hbpragma.c b/harbour/examples/pp/hbpragma.c deleted file mode 100644 index 1a9e8cc158..0000000000 --- a/harbour/examples/pp/hbpragma.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Support for #pragma directive and related functions - * - * Copyright 2000 Jose Lalin - * www - http://harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -/* - * See doc/pragma.txt to learn more about Harbour pragmas. - */ - -#include "hbppdef.h" -#include "hbcomp.h" - -static HB_BOOL StringToBool( char *, HB_BOOL ); -static int StringToInt( char *, int ); -static HB_BOOL IsOnOffSwitch( char *, HB_BOOL ); -static void DebugPragma( char *, int, HB_BOOL ); - -static HB_BOOL s_bTracePragma = HB_FALSE; - -/* Size of abreviated pragma commands */ -#define PRAGMAS_LEN 8 - -/* TODO: Add support for: - RequestLib /R - */ - -static PINLINE hb_compInlineAdd_( char * szFunName ) -{ - HB_SYMBOL_UNUSED( szFunName ); - return NULL; -} - -HB_BOOL hb_pp_ParsePragma( char * szLine ) -{ - HB_BOOL bIgnore = HB_TRUE; - - HB_TRACE( HB_TR_DEBUG, ( "hb_pp_ParsePragma(%s)", szLine ) ); - - HB_SKIPTABSPACES( szLine ); - - if( HB_ISOPTSEP( szLine[ 0 ] ) ) - { - switch( szLine[ 1 ] ) - { - case 'a': - case 'A': - hb_comp_bAutoMemvarAssume = IsOnOffSwitch( szLine, hb_comp_bAutoMemvarAssume ); - DebugPragma( szLine, -1, hb_comp_bAutoMemvarAssume ); - break; - - case 'b': - case 'B': - hb_comp_bDebugInfo = IsOnOffSwitch( szLine, hb_comp_bDebugInfo ); - hb_comp_bLineNumbers = hb_comp_bDebugInfo; - DebugPragma( szLine, -1, hb_comp_bDebugInfo ); - break; - - case 'e': - case 'E': - - if( szLine[ 2 ] == 's' || - szLine[ 2 ] == 'S' ) - { - switch( szLine[ 3 ] ) - { - case '\0': - case '0': - hb_comp_iExitLevel = HB_EXITLEVEL_DEFAULT; - break; - - case '1': - hb_comp_iExitLevel = HB_EXITLEVEL_SETEXIT; - break; - - case '2': - hb_comp_iExitLevel = HB_EXITLEVEL_DELTARGET; - break; - - default: - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_PRAGMA_BAD_VALUE, NULL, NULL ); - } - DebugPragma( szLine, hb_comp_iExitLevel, HB_FALSE ); - } - - break; - - case 'l': - case 'L': - hb_comp_bLineNumbers = IsOnOffSwitch( szLine, hb_comp_bLineNumbers ); - DebugPragma( szLine, -1, hb_comp_bLineNumbers ); - break; - - case 'n': - case 'N': - hb_comp_bStartProc = IsOnOffSwitch( szLine, hb_comp_bStartProc ); - DebugPragma( szLine, -1, hb_comp_bStartProc ); - break; - - case 'p': - case 'P': - hb_comp_bPPO = IsOnOffSwitch( szLine, hb_comp_bPPO ); - DebugPragma( szLine, -1, hb_comp_bPPO ); - break; - - case 'v': - case 'V': - hb_comp_bForceMemvars = IsOnOffSwitch( szLine, hb_comp_bForceMemvars ); - DebugPragma( szLine, -1, hb_comp_bForceMemvars ); - break; - - case 'w': - case 'W': - if( szLine[ 2 ] != '\0' ) - { - /* Check for +/- */ - if( szLine[ strlen( szLine ) - 1 ] == '+' || - szLine[ strlen( szLine ) - 1 ] == '-' ) - hb_comp_iWarnings = IsOnOffSwitch( szLine, hb_comp_iWarnings != 0 ) ? 1 : 0; - else - { - /* There is -w<0,1,2,3> probably */ - hb_comp_iWarnings = szLine[ 2 ] - '0'; - if( hb_comp_iWarnings < 0 || hb_comp_iWarnings > 3 ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_PRAGMA_BAD_VALUE, NULL, NULL ); - - DebugPragma( szLine, -1, hb_comp_iWarnings ); - } - } - break; - - case 'z': - case 'Z': - hb_comp_bShortCuts = IsOnOffSwitch( szLine, hb_comp_bShortCuts ); - DebugPragma( szLine, -1, hb_comp_bShortCuts ); - break; - - default: - break; - } - } - else - { - if( hb_strnicmp( szLine, "AUTOMEMVAR", PRAGMAS_LEN ) == 0 ) - { - hb_comp_bAutoMemvarAssume = StringToBool( szLine, hb_comp_bAutoMemvarAssume ); - DebugPragma( szLine, -1, hb_comp_bAutoMemvarAssume ); - } - else if( hb_strnicmp( szLine, "BEGINDUMP", PRAGMAS_LEN ) == 0 ) - { - char sBuffer[ HB_PP_STR_SIZE ], * pBuffer, sDirective[ 9 ]; - int iSize, iOldSize; - PINLINE pInline; - - if( hb_comp_bPPO ) - { - hb_pp_WrStr( hb_comp_yyppo, "#pragma BEGINDUMP" ); - } - - hb_pp_StreamBlock = HB_PP_STREAM_DUMP_C; - - pInline = hb_compInlineAdd_( NULL ); - - DigestInline: - - iSize = hb_pp_Internal_( hb_comp_bPPO ? hb_comp_yyppo : NULL, sBuffer ); - if( iSize == 0 ) - { - hb_pp_StreamBlock = 0; - return bIgnore; - } - - pBuffer = ( char * ) sBuffer; - - while( *pBuffer == ' ' || *pBuffer == '\t' ) - { - pBuffer++; - } - if( *pBuffer == '#' ) - { - pBuffer++; - while( *pBuffer == ' ' || *pBuffer == '\t' ) - { - pBuffer++; - } - hb_strncpyUpper( sDirective, pBuffer, 6 ); - if( memcmp( sDirective, "PRAGMA", 6 ) == 0 ) - { - pBuffer += 6; - } - while( *pBuffer == ' ' || *pBuffer == '\t' ) - { - pBuffer++; - } - hb_strncpyUpper( sDirective, pBuffer, 7 ); - if( memcmp( sDirective, "ENDDUMP", 7 ) == 0 ) - { - hb_pp_StreamBlock = 0; - return bIgnore; - } - } - - iOldSize = 0; - iSize = strlen( ( char * ) sBuffer ); - if( pInline->pCode == NULL ) - { - pInline->pCode = ( BYTE * ) hb_xgrab( iSize + 1 ); - } - else - { - iOldSize = strlen( ( char * ) pInline->pCode ); - pInline->pCode = ( BYTE * ) hb_xrealloc( pInline->pCode, iOldSize + iSize + 1 ); - } - memcpy( pInline->pCode + iOldSize, sBuffer, iSize + 1 ); - - goto DigestInline; - } - else if( hb_strnicmp( szLine, "DEBUGINFO", PRAGMAS_LEN ) == 0 ) - { - hb_comp_bDebugInfo = StringToBool( szLine, hb_comp_bDebugInfo ); - hb_comp_bLineNumbers = hb_comp_bDebugInfo; - DebugPragma( szLine, -1, hb_comp_bDebugInfo ); - } - else if( hb_strnicmp( szLine, "ENABLEWARNINGS", PRAGMAS_LEN ) == 0 ) - { - hb_comp_iWarnings = StringToBool( szLine, hb_comp_iWarnings != 0 ) ? 1 : 0; - DebugPragma( szLine, hb_comp_iWarnings, HB_FALSE ); - } - else if( hb_strnicmp( szLine, "EXITSEVERITY", PRAGMAS_LEN ) == 0 ) - { - hb_comp_iExitLevel = StringToInt( szLine, hb_comp_iExitLevel ); - if( hb_comp_iExitLevel != HB_EXITLEVEL_DEFAULT && - hb_comp_iExitLevel != HB_EXITLEVEL_SETEXIT && - hb_comp_iExitLevel != HB_EXITLEVEL_DELTARGET ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_PRAGMA_BAD_VALUE, NULL, NULL ); - DebugPragma( szLine, hb_comp_iExitLevel, HB_FALSE ); - } - else if( hb_strnicmp( szLine, "DYNAMICMEMVAR", PRAGMAS_LEN ) == 0 ) - { - hb_comp_bForceMemvars = StringToBool( szLine, hb_comp_bForceMemvars ); - DebugPragma( szLine, -1, hb_comp_bForceMemvars ); - } - else if( hb_strnicmp( szLine, "LINENUMBER", PRAGMAS_LEN ) == 0 ) - { - hb_comp_bLineNumbers = StringToBool( szLine, hb_comp_bLineNumbers ); - DebugPragma( szLine, -1, hb_comp_bLineNumbers ); - } - else if( hb_strnicmp( szLine, "NOSTARTPROC", PRAGMAS_LEN ) == 0 ) - { - hb_comp_bStartProc = StringToBool( szLine, hb_comp_bStartProc ); - DebugPragma( szLine, -1, hb_comp_bStartProc ); - } - else if( hb_strnicmp( szLine, "PREPROCESSING", PRAGMAS_LEN ) == 0 ) - { - hb_comp_bPPO = StringToBool( szLine, hb_comp_bPPO ); - DebugPragma( szLine, -1, hb_comp_bPPO ); - } - else if( hb_strnicmp( szLine, "SHORTCUT", PRAGMAS_LEN ) == 0 ) - { - hb_comp_bShortCuts = StringToBool( szLine, hb_comp_bShortCuts ); - DebugPragma( szLine, -1, hb_comp_bShortCuts ); - } - else if( hb_strnicmp( szLine, "WARNINGLEVEL", PRAGMAS_LEN ) == 0 ) - { - hb_comp_iWarnings = StringToInt( szLine, hb_comp_iWarnings ); - if( hb_comp_iWarnings < 0 || hb_comp_iWarnings > 3 ) - hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_PRAGMA_BAD_VALUE, NULL, NULL ); - DebugPragma( szLine, hb_comp_iWarnings, HB_FALSE ); - } - else if( hb_strnicmp( szLine, "TRACEPRAGMAS", PRAGMAS_LEN ) == 0 ) - { - s_bTracePragma = StringToBool( szLine, s_bTracePragma ); - DebugPragma( szLine, -1, s_bTracePragma ); - } - else if( hb_strnicmp( szLine, "__text", 6 ) == 0 ) - { - bIgnore = hb_pp_StreamBlockBegin( szLine, HB_PP_STREAM_CLIPPER ); - DebugPragma( szLine, -1, s_bTracePragma ); - } - else if( hb_strnicmp( szLine, "__stream", 8 ) == 0 ) - { - bIgnore = hb_pp_StreamBlockBegin( szLine, HB_PP_STREAM_PRG ); - DebugPragma( szLine, -1, s_bTracePragma ); - } - else if( hb_strnicmp( szLine, "__cstream", 8 ) == 0 ) - { - bIgnore = hb_pp_StreamBlockBegin( szLine, HB_PP_STREAM_C ); - DebugPragma( szLine, -1, s_bTracePragma ); - } - else if( hb_strnicmp( szLine, "__endtext", 9 ) == 0 ) - { - hb_pp_BlockEnd(); - DebugPragma( szLine, -1, s_bTracePragma ); - } - else if( hb_strnicmp( szLine, "RECURSELEVEL", PRAGMAS_LEN ) == 0 ) - { - int iOverflow; - int iMax; - - iMax = ( int ) hb_strValInt( szLine, &iOverflow ); - if( iOverflow || iMax < 1 ) - hb_pp_MaxTranslateCycles = 1024; - else - hb_pp_MaxTranslateCycles = ( unsigned int ) iMax; - DebugPragma( szLine, hb_pp_MaxTranslateCycles, HB_FALSE ); - } - } - - return bIgnore; -} - -/* Checks for +/- within the string, sets bDefault if not found */ -static HB_BOOL IsOnOffSwitch( char * pszStr, HB_BOOL bValue ) -{ - int iPos = strlen( pszStr ) - 1; - - if( pszStr[ iPos ] == '+' ) - bValue = HB_TRUE; - else if( pszStr[ iPos ] == '-' ) - bValue = HB_FALSE; - - return bValue; -} - -/* Checks for ON/OFF within the string, sets bDefault if not found */ -static HB_BOOL StringToBool( char * pszStr, HB_BOOL bValue ) -{ - char * pos = strchr( pszStr, '=' ); - - if( ! pos ) - pos = strchr( pszStr, '(' ); - - if( pos ) - { - pos++; - - HB_SKIPTABSPACES( pos ); - - if( hb_strnicmp( pos, "ON", 2 ) == 0 ) - bValue = HB_TRUE; - else if( hb_strnicmp( pos, "OFF", 3 ) == 0 ) - bValue = HB_FALSE; - } - - return bValue; -} - -/* Returns value after =, sets iDefault if not found */ -static int StringToInt( char * pszStr, int iValue ) -{ - char * pos = strchr( pszStr, '=' ); - - if( ! pos ) - pos = strchr( pszStr, '(' ); - - if( pos ) - { - pos++; - - HB_SKIPTABSPACES( pos ); - - if( *pos >= '0' && *pos <= '9' ) - iValue = *pos - '0'; - } - - return iValue; -} - -/* This is only to debug pragmas now */ -static void DebugPragma( char * pszStr, int iValue, HB_BOOL bValue ) -{ - if( s_bTracePragma ) - { - if( iValue >= 0 ) - printf( "#pragma set to %i \'%s\'\n", iValue, pszStr ); - else - printf( "#pragma set to %s \'%s\'\n", bValue ? "ON" : "OFF", pszStr ); - } -} diff --git a/harbour/examples/pp/pp.1 b/harbour/examples/pp/pp.1 deleted file mode 100644 index b5bc573c27..0000000000 --- a/harbour/examples/pp/pp.1 +++ /dev/null @@ -1,30 +0,0 @@ -.TH HBPP 1 - -.SH NAME -hbpp \- Harbour Project Preprocessor - -.SH SYNOPSIS -\fBhbpp\fP \fB\fP \fB[options]\fP - -.SH DESCRIPTION -\fBhbpp\fP is the old Harbour Project preprocessor. - -.SH OPTIONS -.IP "\fB-d[=]\fP" 10 -#define -.IP "\fB-i\fP" 10 -add #include file search path -.IP "\fB-o\fP" 10 -creates hbpp.out with all tables -.IP "\fB-n\fP" 10 -with those only, which defined in your file -.IP "\fB-w\fP" 10 -enable warnings - - -.SH AUTHOR - -Author of hbpp: The Harbour Project (http://harbour-project.org) - -This manual page was written by Luis Mayoral , -for the Debian GNU/Linux system (but may be used by others). diff --git a/harbour/examples/pp/pp.c b/harbour/examples/pp/pp.c deleted file mode 100644 index e9aae11d29..0000000000 --- a/harbour/examples/pp/pp.c +++ /dev/null @@ -1,520 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Preprocessor standalone main module - * - * Copyright 1999 Alexander S.Kresin - * www - http://harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -/* - * Avoid tracing in preprocessor/compiler. - */ -#if ! defined( HB_TRACE_UTILS ) - #if defined( HB_TRACE_LEVEL ) - #undef HB_TRACE_LEVEL - #endif -#endif - -#include -#include -#include -/* malloc.h has been obsoleted by stdlib.h (and does not even exist in gcc 3.x). - #include - */ - -#include "hbppdef.h" -#include "hbcomp.h" -#include "hbset.h" - -extern int hb_pp_ParseDefine_( char * ); - -static void AddSearchPath( char * szPath, HB_PATHNAMES ** pSearchList ); -static void OutTable( DEFINES * endDefine, COMMANDS * endCommand ); -static HB_BOOL hb_pp_fopen( char * szFileName ); - -static char s_szLine[ HB_PP_STR_SIZE ]; -static int s_iWarnings = 0; -static char * hb_buffer; - -HB_PATHNAMES * hb_comp_pIncludePath = NULL; -PHB_FNAME hb_comp_pFileName = NULL; -FILES hb_comp_files; -int hb_comp_iLine = 1; /* currently parsed file line number */ - -/* These are need for the PP #pragma support */ -HB_BOOL hb_comp_bPPO = HB_FALSE; /* flag indicating, is ppo output needed */ -HB_BOOL hb_comp_bStartProc = HB_TRUE; /* holds if we need to create the starting procedure */ -HB_BOOL hb_comp_bLineNumbers = HB_TRUE; /* holds if we need pcodes with line numbers */ -HB_BOOL hb_comp_bShortCuts = HB_TRUE; /* .and. & .or. expressions shortcuts */ -int hb_comp_iWarnings = 0; /* enable parse warnings */ -HB_BOOL hb_comp_bAutoMemvarAssume = HB_FALSE; /* holds if undeclared variables are automatically assumed MEMVAR (-a)*/ -HB_BOOL hb_comp_bForceMemvars = HB_FALSE; /* holds if memvars are assumed when accesing undeclared variable (-v)*/ -HB_BOOL hb_comp_bDebugInfo = HB_FALSE; /* holds if generate debugger required info */ -int hb_comp_iExitLevel = HB_EXITLEVEL_DEFAULT; /* holds if there was any warning during the compilation process */ -FILE * hb_comp_yyppo = NULL; - -int hb_comp_iLinePRG; -int hb_comp_iLineINLINE = 0; - -int main( int argc, char * argv[] ) -{ - FILE * handl_o; - char szFileName[ HB_PATH_MAX ]; - char szPpoName[ HB_PATH_MAX ]; - int iArg = 1; - HB_BOOL bOutTable = HB_FALSE; - HB_BOOL bOutNew = HB_FALSE; - DEFINES * stdef; - COMMANDS * stcmd; - - HB_TRACE( HB_TR_DEBUG, ( "main(%d, %p)", argc, argv ) ); - - printf( "Harbour Preprocessor (old version) %d.%d.%d\n", - HB_VER_MAJOR, HB_VER_MINOR, HB_VER_RELEASE ); - printf( "Copyright (c) 1999-2008, http://harbour-project.org/\n" ); - - hb_pp_Table(); - stdef = hb_pp_topDefine; - stcmd = hb_pp_topCommand; - hb_pp_Init(); - - while( iArg < argc ) - { - if( HB_ISOPTSEP( argv[ iArg ][ 0 ] ) ) - { - switch( argv[ iArg ][ 1 ] ) - { - case 'd': - case 'D': /* defines a #define from the command line */ - { - char * szDefText = hb_strdup( argv[ iArg ] + 2 ), * pAssign, * sDefLine; - unsigned int i = 0; - - while( i < strlen( szDefText ) && ! HB_ISOPTSEP( szDefText[ i ] ) ) - i++; - - szDefText[ i ] = '\0'; - if( szDefText ) - { - if( ( pAssign = strchr( szDefText, '=' ) ) == NULL ) - { - hb_pp_AddDefine_( szDefText, 0 ); - } - else - { - szDefText[ pAssign - szDefText ] = '\0'; - - /* hb_pp_AddDefine_( szDefText, pAssign + 1 ); */ - sDefLine = hb_xstrcpy( NULL, szDefText, " ", pAssign + 1, NULL ); - hb_pp_ParseDefine_( sDefLine ); - hb_xfree( sDefLine ); - } - } - - hb_xfree( szDefText ); - } - break; - case 'i': - case 'I': - AddSearchPath( argv[ iArg ] + 2, &hb_comp_pIncludePath ); - break; - case 'o': - case 'O': - bOutTable = HB_TRUE; - break; - case 'n': - case 'N': - bOutNew = HB_TRUE; - break; - case 'w': - case 'W': - s_iWarnings = 1; - if( argv[ iArg ][ 2 ] ) /* there is -w<0,1,2,3> probably */ - { - s_iWarnings = argv[ iArg ][ 2 ] - '0'; - if( s_iWarnings < 0 || s_iWarnings > 3 ) - printf( "\nInvalid command line option: %s\n", argv[ iArg ] ); - } - break; - default: - printf( "\nInvalid command line option: %s\n", &argv[ iArg ][ 1 ] ); - break; - } - } - else - hb_comp_pFileName = hb_fsFNameSplit( argv[ iArg ] ); - iArg++; - } - - if( hb_comp_pFileName ) - { - if( ! hb_comp_pFileName->szExtension ) - hb_comp_pFileName->szExtension = ".prg"; - - hb_fsFNameMerge( szFileName, hb_comp_pFileName ); - - if( ! hb_pp_fopen( szFileName ) ) - { - printf( "\nCan't open %s\n", szFileName ); - return 1; - } - - printf( "\nParsing file %s\n", szFileName ); - } - else - { - printf( "\nSyntax: %s [options]" - "\n" - "\nOptions: /d[=] #define " - "\n /i add #include file search path" - "\n /o creates hbpp.out with all tables" - "\n /n with those only, which defined in your file" - "\n /w enable warnings" - "\n" - , argv[ 0 ] ); - - if( bOutTable ) - OutTable( NULL, NULL ); - - return 1; - } - - hb_comp_pFileName->szExtension = ".ppo"; - hb_fsFNameMerge( szPpoName, hb_comp_pFileName ); - - if( ( handl_o = fopen( szPpoName, "wt" ) ) == NULL ) - { - printf( "\nCan't open %s\n", szPpoName ); - return 1; - } - - { - char * szInclude = hb_getenv( "INCLUDE" ); - - if( szInclude ) - { - char * pPath; - char * pDelim; - - pPath = szInclude; - while( ( pDelim = strchr( pPath, HB_OS_PATH_LIST_SEP_CHR ) ) != NULL ) - { - *pDelim = '\0'; - AddSearchPath( pPath, &hb_comp_pIncludePath ); - pPath = pDelim + 1; - } - AddSearchPath( pPath, &hb_comp_pIncludePath ); - hb_xfree( szInclude ); - } - } - - hb_buffer = ( char * ) hb_xgrab( HB_PP_STR_SIZE ); - while( hb_pp_Internal_( handl_o, hb_buffer ) > 0 ) - ; - fclose( hb_comp_files.pLast->handle ); - hb_xfree( hb_comp_files.pLast->pBuffer ); - hb_xfree( hb_comp_files.pLast ); - hb_xfree( hb_buffer ); - fclose( handl_o ); - - if( bOutTable ) - OutTable( NULL, NULL ); - else if( bOutNew ) - OutTable( stdef, stcmd ); - - printf( "\nOk" ); - - return 0; -} - -static void OutTable( DEFINES * endDefine, COMMANDS * endCommand ) -{ - FILE * handl_o; - int ipos, len_mpatt = 0, len_value; - int num; - DEFINES * stdef1 = hb_pp_topDefine, * stdef2 = NULL, * stdef3; - COMMANDS * stcmd1 = hb_pp_topCommand, * stcmd2 = NULL, * stcmd3; - - HB_TRACE( HB_TR_DEBUG, ( "OutTable(%p, %p)", endDefine, endCommand ) ); - - while( stdef1 != endDefine ) - { - stdef3 = stdef1->last; - stdef1->last = stdef2; - stdef2 = stdef1; - stdef1 = stdef3; - } - while( stcmd1 != endCommand ) - { - stcmd3 = stcmd1->last; - stcmd1->last = stcmd2; - stcmd2 = stcmd1; - stcmd1 = stcmd3; - } - - if( ( handl_o = fopen( "hbpp.out", "wt" ) ) == NULL ) - { - printf( "\nCan't open hbpp.out\n" ); - return; - } - - num = 1; - while( stdef2 != NULL ) - { - fprintf( handl_o, "\n static DEFINES sD___%i = ", num ); - fprintf( handl_o, "{\"%s\",", stdef2->name ); - if( stdef2->pars ) - fprintf( handl_o, "\"%s\",", stdef2->pars ); - else - fprintf( handl_o, "NULL," ); - fprintf( handl_o, "%d,", stdef2->npars ); - if( stdef2->value ) - fprintf( handl_o, "\"%s\"", stdef2->value ); - else - fprintf( handl_o, "NULL" ); - if( num == 1 ) - fprintf( handl_o, ", NULL };" ); - else - fprintf( handl_o, ", &sD___%i };", num - 1 ); - stdef2 = stdef2->last; - num++; - } - fprintf( handl_o, "\n DEFINES * hb_pp_topDefine = " ); - if( num == 1 ) - fprintf( handl_o, "NULL;" ); - else - fprintf( handl_o, " = &sD___%i;\n", num - 1 ); - - num = 1; - while( stcmd2 != NULL ) - { - fprintf( handl_o, "\n static COMMANDS sC___%i = ", num ); - fprintf( handl_o, "{%d,\"%s\",", stcmd2->com_or_xcom, stcmd2->name ); - if( stcmd2->mpatt != NULL ) - { - len_mpatt = hb_pp_strocpy( s_szLine, stcmd2->mpatt ); - while( ( ipos = hb_strAt( "\1", 1, s_szLine, len_mpatt ) ) > 0 ) - { - hb_pp_Stuff( "\\1", s_szLine + ipos - 1, 2, 1, len_mpatt ); - len_mpatt++; - } - fprintf( handl_o, "\"%s\",", s_szLine ); - } - else - fprintf( handl_o, "NULL," ); - if( stcmd2->value != NULL ) - { - len_value = hb_pp_strocpy( s_szLine, stcmd2->value ); - while( ( ipos = hb_strAt( "\1", 1, s_szLine, len_value ) ) > 0 ) - { - hb_pp_Stuff( "\\1", s_szLine + ipos - 1, 2, 1, len_value ); - len_value++; - } - if( len_mpatt + len_value > 80 ) - fprintf( handl_o, "\n " ); - fprintf( handl_o, "\"%s\"", s_szLine ); - } - else - fprintf( handl_o, "NULL" ); - if( num == 1 ) - fprintf( handl_o, ",NULL };" ); - else - fprintf( handl_o, ",&sC___%i };", num - 1 ); - stcmd2 = stcmd2->last; - num++; - } - fprintf( handl_o, "\n COMMANDS * hb_pp_topCommand = " ); - if( num == 1 ) - fprintf( handl_o, "NULL;" ); - else - fprintf( handl_o, " = &sC___%i;\n", num - 1 ); - - stcmd1 = hb_pp_topTranslate; - stcmd2 = NULL; - while( stcmd1 != NULL ) - { - stcmd3 = stcmd1->last; - stcmd1->last = stcmd2; - stcmd2 = stcmd1; - stcmd1 = stcmd3; - } - num = 1; - while( stcmd2 != NULL ) - { - fprintf( handl_o, "\n static COMMANDS sC___%i = ", num ); - fprintf( handl_o, "{%d,\"%s\",", stcmd2->com_or_xcom, stcmd2->name ); - if( stcmd2->mpatt != NULL ) - { - len_mpatt = hb_pp_strocpy( s_szLine, stcmd2->mpatt ); - while( ( ipos = hb_strAt( "\1", 1, s_szLine, len_mpatt ) ) > 0 ) - { - hb_pp_Stuff( "\\1", s_szLine + ipos - 1, 2, 1, len_mpatt ); - len_mpatt++; - } - fprintf( handl_o, "\"%s\",", s_szLine ); - } - else - fprintf( handl_o, "NULL," ); - if( stcmd2->value != NULL ) - { - len_value = hb_pp_strocpy( s_szLine, stcmd2->value ); - while( ( ipos = hb_strAt( "\1", 1, s_szLine, len_value ) ) > 0 ) - { - hb_pp_Stuff( "\\1", s_szLine + ipos - 1, 2, 1, len_value ); - len_value++; - } - if( len_mpatt + len_value > 80 ) - fprintf( handl_o, "\n " ); - fprintf( handl_o, "\"%s\"", s_szLine ); - } - else - fprintf( handl_o, "NULL" ); - if( num == 1 ) - fprintf( handl_o, ",NULL };" ); - else - fprintf( handl_o, ",&sC___%i };", num - 1 ); - stcmd2 = stcmd2->last; - num++; - } - fprintf( handl_o, "\n COMMANDS * hb_pp_topTranslate = " ); - if( num == 1 ) - fprintf( handl_o, "NULL;" ); - else - fprintf( handl_o, " = &sT___%i;", num ); - - fclose( handl_o ); -} - -/* - * Function that adds specified path to the list of pathnames to search - */ -static void AddSearchPath( char * szPath, HB_PATHNAMES ** pSearchList ) -{ - HB_PATHNAMES * pPath = *pSearchList; - - HB_TRACE( HB_TR_DEBUG, ( "AddSearchPath(%s, %p)", szPath, pSearchList ) ); - - if( pPath ) - { - while( pPath->pNext ) - pPath = pPath->pNext; - pPath->pNext = ( HB_PATHNAMES * ) hb_xgrab( sizeof( HB_PATHNAMES ) ); - pPath = pPath->pNext; - } - else - { - *pSearchList = pPath = ( HB_PATHNAMES * ) hb_xgrab( sizeof( HB_PATHNAMES ) ); - } - pPath->pNext = NULL; - pPath->szPath = szPath; -} - -void hb_compGenError( HB_COMP_DECL, const char * _szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_compGenError(%p, %c, %d, %s, %s)", _szErrors, cPrefix, iError, szError1, szError2 ) ); - - HB_SYMBOL_UNUSED( HB_COMP_PARAM ); - - printf( "\r(%i) ", hb_comp_iLine ); - printf( "Error %c%04i ", cPrefix, iError ); - printf( _szErrors[ iError - 1 ], szError1, szError2 ); - printf( "\n\n" ); - - /* - exit( EXIT_FAILURE ); - */ -} - -void hb_compGenWarning( HB_COMP_DECL, const char * _szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2 ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_compGenWarning(%p, %c, %d, %s, %s)", _szWarnings, cPrefix, iWarning, szWarning1, szWarning2 ) ); - - HB_SYMBOL_UNUSED( HB_COMP_PARAM ); - - if( s_iWarnings ) - { - const char * szText = _szWarnings[ iWarning - 1 ]; - - if( ( ( int ) ( szText[ 0 ] - '0' ) ) <= s_iWarnings ) - { - printf( "\r(%i) ", hb_comp_iLine ); - printf( "Warning %c%04i ", cPrefix, iWarning ); - printf( szText + 1, szWarning1, szWarning2 ); - printf( "\n" ); - } - } -} - -int hb_verSvnID( void ) -{ - return 0; -} - -static HB_BOOL hb_pp_fopen( char * szFileName ) -{ - PFILE pFile; - FILE * handl_i = fopen( szFileName, "r" ); - - if( ! handl_i ) - return HB_FALSE; - - pFile = ( PFILE ) hb_xgrab( sizeof( _FILE ) ); - pFile->handle = handl_i; - pFile->pBuffer = hb_xgrab( HB_PP_BUFF_SIZE ); - pFile->iBuffer = pFile->lenBuffer = 10; - pFile->szFileName = szFileName; - pFile->pPrev = NULL; - - hb_comp_files.pLast = pFile; - hb_comp_files.iFiles = 1; - - return HB_TRUE; -} - -#if defined( HB_OS_WIN_CE ) && ! defined( __CEGCC__ ) -# include "hbwmain.c" -#endif diff --git a/harbour/examples/pp/pp.hbp b/harbour/examples/pp/pp.hbp deleted file mode 100644 index 8c8205f0ec..0000000000 --- a/harbour/examples/pp/pp.hbp +++ /dev/null @@ -1,9 +0,0 @@ -# -# $Id$ -# - -pp.c hbppcomp.c hbppcore.c hbpptbl.c hbpragma.c --lhbcommon --lhbnortl --static --nohblib