From a4ec35927e0a6afe42690f917d14e20a3e9d70cd Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 22 Nov 1999 15:29:17 +0000 Subject: [PATCH] 19991122-16:12 GMT+1 Victor Szel --- harbour/ChangeLog | 18 +++++ harbour/include/compiler.h | 4 -- harbour/include/extend.h | 3 +- harbour/include/hbpp.h | 25 ++++--- harbour/source/common/hbstr.c | 26 +++++-- harbour/source/compiler/genc.c | 2 +- harbour/source/compiler/harbour.c | 54 +++++--------- harbour/source/compiler/harbour.l | 115 ++++++++++++++---------------- harbour/source/compiler/harbour.y | 11 +-- harbour/source/pp/hbpp.c | 28 ++------ harbour/source/pp/stdalone/hbpp.c | 4 +- 11 files changed, 138 insertions(+), 152 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 71545927de..4a46cea054 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,21 @@ +19991122-16:12 GMT+1 Victor Szel + * source/common/hbstr.c + include/extend.h + + hb_strdup() function added. + + hb_strupr() corrected to return a pointer. + * source/pp/hbpp.c + source/pp/stdalone/hbpp.c + include/hbpp.h + % hb_pp_strodup() -> hb_strdup() + - hb_pp_strodup() removed. + * source/compiler/harbour.* + source/compiler/genc.c + include/compiler.h + % yy_strupr() -> hb_strupr() + % yy_strdup() -> hb_strdup() + - Removed redundant function declarations (yy_*, hb_x*()) + - yy_strdup(), yy_strupr() removed. + 19991122-15:03 GMT+1 Victor Szel * source/pp/hbppint.c ! .PPO file generation fixed (/p was not working since yesterday). diff --git a/harbour/include/compiler.h b/harbour/include/compiler.h index fe94d55057..86c8130b03 100644 --- a/harbour/include/compiler.h +++ b/harbour/include/compiler.h @@ -182,10 +182,6 @@ typedef struct HB_EXPR_ } HB_EXPR, *HB_EXPR_PTR; -char * yy_strdup( char * p ); /* this will exit if there is not enough memory */ -char * yy_strupr( char * p ); - - #define VS_LOCAL 1 #define VS_STATIC 2 #define VS_FIELD 4 diff --git a/harbour/include/extend.h b/harbour/include/extend.h index fd0af0c423..cd2d2a0c7a 100644 --- a/harbour/include/extend.h +++ b/harbour/include/extend.h @@ -334,7 +334,8 @@ extern PHB_ITEM hb_arrayClone( PHB_ITEM pArray ); extern int hb_stricmp( const char * s1, const char * s2 ); extern int hb_strnicmp( const char * s1, const char * s2, ULONG ulLen ); -extern void hb_strupr( char * szText ); +extern char * hb_strupr( char * pszText ); +extern char * hb_strdup( const char * pszText ); extern BOOL hb_strMatchRegExp( const char * szString, const char * szMask ); extern BOOL hb_strEmpty( const char * szText, ULONG ulLen ); extern void hb_strDescend( char * szStringTo, const char * szStringFrom, ULONG ulLen ); diff --git a/harbour/include/hbpp.h b/harbour/include/hbpp.h index 6798a906c1..bc4f9cc4c1 100644 --- a/harbour/include/hbpp.h +++ b/harbour/include/hbpp.h @@ -47,28 +47,28 @@ /* the list of pathnames to search with #include */ typedef struct _PATHNAMES { - char * szPath; - struct _PATHNAMES *pNext; + char * szPath; + struct _PATHNAMES *pNext; } PATHNAMES; struct _DEFINES; typedef struct _DEFINES { - char * name; - char * pars; - int npars; - char * value; - struct _DEFINES * last; + char * name; + char * pars; + int npars; + char * value; + struct _DEFINES * last; } DEFINES; struct _COMMANDS; typedef struct _COMMANDS { - int com_or_xcom; - char * name; - char * mpatt; - char * value; - struct _COMMANDS * last; + int com_or_xcom; + char * name; + char * mpatt; + char * value; + struct _COMMANDS * last; } COMMANDS; #define HB_PP_STR_SIZE 8192 @@ -85,7 +85,6 @@ extern int hb_pp_WrStr( FILE *, char * ); extern int hb_pp_RdStr( FILE *, char *, int, BOOL, char *, int *, int * ); extern void hb_pp_Stuff( char *, char *, int, int, int ); extern int hb_pp_strocpy( char *, char * ); -extern char * hb_pp_strodup( char * ); extern DEFINES * hb_pp_AddDefine( char *, char * ); /* Add new #define to a linked list */ /* HBPPINT.C exported functions */ diff --git a/harbour/source/common/hbstr.c b/harbour/source/common/hbstr.c index c5ab41dfc9..30ba85b202 100644 --- a/harbour/source/common/hbstr.c +++ b/harbour/source/common/hbstr.c @@ -63,10 +63,28 @@ ULONG hb_strAt( const char * szSub, ULONG ulSubLen, const char * szText, ULONG u return 0; } -void hb_strupr( char * szText ) +char * hb_strupr( char * pszText ) { - HB_TRACE(HB_TR_DEBUG, ("hb_strupr(%s)", szText)); + char * pszPos; - for(; *szText; szText++ ) - *szText = toupper( *szText ); + HB_TRACE(HB_TR_DEBUG, ("hb_strupr(%s)", pszText)); + + for( pszPos = pszText; *pszPos; pszPos++ ) + *pszPos = toupper( *pszPos ); + + return pszText; +} + +char * hb_strdup( const char * pszText ) +{ + char * pszDup; + int iLen; + + HB_TRACE(HB_TR_DEBUG, ("hb_strdup(%s)", pszText)); + + iLen = strlen( pszText ) + 1; + pszDup = ( char * ) hb_xgrab( iLen ); + memcpy( pszDup, pszText, iLen ); + + return pszDup; } diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index 52867b9c39..58ce294b99 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -105,7 +105,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */ /* writes the symbol table */ /* Generate the wrapper that will initialize local symbol table */ - yy_strupr( pFileName->szName ); + hb_strupr( pFileName->szName ); fprintf( yyc, "\n\nHB_INIT_SYMBOLS_BEGIN( hb_vm_SymbolInit_%s%s )\n", hb_comp_szPrefix, pFileName->szName ); if( ! hb_comp_bStartProc ) diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 711e57f937..7d626ab965 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -364,7 +364,7 @@ int main( int argc, char * argv[] ) case 'D': /* defines a Lex #define from the command line */ { unsigned int i = 0; - char * szDefText = yy_strdup( argv[ iArg ] + 2 ); + char * szDefText = hb_strdup( argv[ iArg ] + 2 ); while( i < strlen( szDefText ) && szDefText[ i ] != '=' ) i++; if( szDefText[ i ] != '=' ) @@ -469,7 +469,7 @@ int main( int argc, char * argv[] ) char * pDelim; char * szInclude; - pPath = szInclude = yy_strdup( argv[ iArg ] + 2 ); + pPath = szInclude = hb_strdup( argv[ iArg ] + 2 ); while( ( pDelim = strchr( pPath, OS_PATH_LIST_SEPARATOR ) ) != NULL ) { * pDelim = '\0'; @@ -650,7 +650,7 @@ int main( int argc, char * argv[] ) char * pPath; char * pDelim; - pPath = szInclude = yy_strdup( szInclude ); + pPath = szInclude = hb_strdup( szInclude ); while( ( pDelim = strchr( pPath, OS_PATH_LIST_SEPARATOR ) ) != NULL ) { *pDelim = '\0'; @@ -957,28 +957,6 @@ void hb_xfree( void * pMem ) /* frees fixed memory */ hb_compGenError( hb_comp_szErrors, 'F', ERR_MEMFREE, NULL, NULL ); } -char * yy_strupr( char * p ) -{ - char * p1; - - for( p1 = p; * p1; p1++ ) - * p1 = toupper( * p1 ); - - return p; -} - -char * yy_strdup( char * p ) -{ - char * pDup; - int iLen; - - iLen = strlen( p ) + 1; - pDup = ( char * ) hb_xgrab( iLen ); - memcpy( pDup, p, iLen ); - - return pDup; -} - /* ------------------------------------------------------------------------- */ void hb_compGenError( char* _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 ) @@ -1301,7 +1279,7 @@ void hb_compVariableAdd( char * szVarName, char cValueType ) pSym = hb_compSymbolFind( szVarName, &wPos ); /* check if symbol exists already */ if( ! pSym ) - pSym = hb_compSymbolAdd( yy_strdup( szVarName ), &wPos ); + pSym = hb_compSymbolAdd( hb_strdup( szVarName ), &wPos ); pSym->cScope |= VS_MEMVAR; hb_compGenPCode3( HB_P_PARAMETER, HB_LOBYTE( wPos ), HB_HIBYTE( wPos ) ); hb_compGenPCode1( HB_LOBYTE( hb_comp_functions.pLast->wParamNum ) ); @@ -1316,7 +1294,7 @@ void hb_compVariableAdd( char * szVarName, char cValueType ) if( bNewParameter ) { pVar = ( PVAR ) hb_xgrab( sizeof( VAR ) ); - pVar->szName = yy_strdup( szVarName ); + pVar->szName = hb_strdup( szVarName ); pVar->szAlias = NULL; pVar->cType = cValueType; pVar->iUsed = 0; @@ -1336,9 +1314,9 @@ void hb_compVariableAdd( char * szVarName, char cValueType ) break; case VS_PRIVATE: { - hb_compGenPushSymbol( yy_strdup( "__MVPRIVATE" ), 1); + hb_compGenPushSymbol( hb_strdup( "__MVPRIVATE" ), 1); hb_compGenPushNil(); - hb_compGenPushSymbol( yy_strdup( szVarName ), 0 ); + hb_compGenPushSymbol( hb_strdup( szVarName ), 0 ); hb_compGenPCode3( HB_P_DO, 1, 0 ); pSym = hb_compSymbolFind( szVarName, NULL ); pSym->cScope |= VS_MEMVAR; @@ -1346,9 +1324,9 @@ void hb_compVariableAdd( char * szVarName, char cValueType ) break; case VS_PUBLIC: { - hb_compGenPushSymbol( yy_strdup( "__MVPUBLIC" ), 1); + hb_compGenPushSymbol( hb_strdup( "__MVPUBLIC" ), 1); hb_compGenPushNil(); - hb_compGenPushSymbol( yy_strdup( szVarName ), 0 ); + hb_compGenPushSymbol( hb_strdup( szVarName ), 0 ); hb_compGenPCode3( HB_P_DO, 1, 0 ); pSym = hb_compSymbolFind( szVarName, NULL ); pSym->cScope |= VS_MEMVAR; @@ -1638,7 +1616,7 @@ PCOMSYMBOL hb_compSymbolKill( PCOMSYMBOL pSym ) void hb_compGenBreak( void ) { - hb_compGenPushSymbol( yy_strdup("BREAK"), 1 ); + hb_compGenPushSymbol( hb_strdup("BREAK"), 1 ); hb_compGenPushNil(); } @@ -1647,7 +1625,7 @@ void hb_compExternGen( void ) /* generates the symbols for the EXTERN names */ PEXTERN pDelete; if( hb_comp_bDebugInfo ) - hb_compExternAdd( yy_strdup( "__DBGENTRY" ) ); + hb_compExternAdd( hb_strdup( "__DBGENTRY" ) ); while( hb_comp_pExterns ) { @@ -2188,7 +2166,7 @@ static void hb_compVariableGenPCode( BYTE bPCode, char * szVarName ) /* * Push alias symbol before the field symbol */ - hb_compGenPushSymbol( yy_strdup( pField->szAlias ), 0 ); + hb_compGenPushSymbol( hb_strdup( pField->szAlias ), 0 ); } else { /* this is unaliased field */ @@ -2315,7 +2293,7 @@ void hb_compGenPopAliasedVar( char * szVarName, } else { /* database alias */ - hb_compGenPushSymbol( yy_strdup( szAlias ), 0 ); + hb_compGenPushSymbol( hb_strdup( szAlias ), 0 ); hb_compFieldGenPCode( HB_P_POPALIASEDFIELD, szVarName ); } } @@ -2423,7 +2401,7 @@ void hb_compGenPushAliasedVar( char * szVarName, } else { /* database alias */ - hb_compGenPushSymbol( yy_strdup( szAlias ), 0 ); + hb_compGenPushSymbol( hb_strdup( szAlias ), 0 ); hb_compFieldGenPCode( HB_P_PUSHALIASEDFIELD, szVarName ); } } @@ -2470,7 +2448,7 @@ void hb_compGenPushFunCall( char * szFunName ) { /* Abbreviated function name was used - change it for whole name */ - hb_compGenPushSymbol( yy_strdup( szFunction ), 1 ); + hb_compGenPushSymbol( hb_strdup( szFunction ), 1 ); } else hb_compGenPushSymbol( szFunName, 1 ); @@ -2741,7 +2719,7 @@ void hb_compStaticDefStart( void ) { BYTE pBuffer[ 5 ]; - hb_comp_pInitFunc = hb_compFunctionNew( yy_strdup("(_INITSTATICS)"), FS_INIT ); + hb_comp_pInitFunc = hb_compFunctionNew( hb_strdup("(_INITSTATICS)"), FS_INIT ); hb_comp_pInitFunc->pOwner = hb_comp_functions.pLast; hb_comp_pInitFunc->bFlags = FUN_USES_STATICS | FUN_PROCEDURE; hb_comp_pInitFunc->cScope = FS_INIT | FS_EXIT; diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index c50d96f4b0..e7f26ffc29 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -46,11 +46,6 @@ #include "hberrors.h" #include "hbdefs.h" -/* Functions defined in harbour.y */ -char * yy_strupr( char * p ); -char * yy_strdup( char * p ); -extern void hb_xfree( void * pMem ); /* frees memory */ - /* helper functions */ static int yy_ConvertNumber( char * szBuffer ); @@ -160,7 +155,7 @@ Separator {SpaceTab} yyleng--; yytext[yyleng] = 0; - yylval.string = yy_strdup( yytext ); + yylval.string = hb_strdup( yytext ); /*printf( "\nLITERAL = %s\n", yylval.string );*/ return LITERAL; } @@ -172,7 +167,7 @@ Separator {SpaceTab} yyleng--; yytext[yyleng] = 0; - yylval.string = yy_strdup( yytext ); + yylval.string = hb_strdup( yytext ); /*printf( "\nLITERAL = %s\n", yylval.string );*/ return LITERAL; } @@ -184,7 +179,7 @@ Separator {SpaceTab} yyleng--; yytext[yyleng] = 0; - yylval.string = yy_strdup( yytext ); + yylval.string = hb_strdup( yytext ); /*printf( "\nLITERAL = %s\n", yylval.string );*/ return LITERAL; } @@ -241,7 +236,7 @@ Separator {SpaceTab} BEGIN BREAK_; else { - yylval.string = yy_strupr( yy_strdup( yytext ) ); + yylval.string = hb_strupr( hb_strdup( yytext ) ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -264,7 +259,7 @@ Separator {SpaceTab} %} {Separator}*(":="|"+="|"-="|"->"|"*="|"/="|"^="|"==") { /* operators */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - yylval.string = yy_strdup( "BREAK" ); + yylval.string = hb_strdup( "BREAK" ); unput( yytext[ yyleng-1 ] ); unput( yytext[ yyleng-2 ] ); hb_comp_iState =IDENTIFIER; @@ -276,7 +271,7 @@ Separator {SpaceTab} * For this reason we are allowing the BREAK statement only */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - yylval.string = yy_strdup( "BREAK" ); + yylval.string = hb_strdup( "BREAK" ); unput( yytext[ yyleng-1 ] ); unput( yytext[ yyleng-2 ] ); hb_comp_iState =BREAK; @@ -284,7 +279,7 @@ Separator {SpaceTab} } {Separator}*[\=\(] { /* operators = ( */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - yylval.string = yy_strdup( "BREAK" ); + yylval.string = hb_strdup( "BREAK" ); unput( yytext[ yyleng-1 ] ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; @@ -303,7 +298,7 @@ Separator {SpaceTab} "case" BEGIN CASE_; {Separator}*[\:\=\|\$\%\*\,\/\]\)\}\^] { /* there is an operator after "case" */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - yylval.string = yy_strdup( "CASE" ); + yylval.string = hb_strdup( "CASE" ); hb_comp_iState =IDENTIFIER; unput( yytext[ yyleng-1 ] ); return IDENTIFIER; @@ -315,7 +310,7 @@ Separator {SpaceTab} } {Separator}*("+="|"-="|"->") { /* operators */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - yylval.string = yy_strdup( "CASE" ); + yylval.string = hb_strdup( "CASE" ); hb_comp_iState =IDENTIFIER; unput( yytext[ yyleng-1 ] ); unput( yytext[ yyleng-2 ] ); @@ -338,7 +333,7 @@ Separator {SpaceTab} } else { /* there is another item in line already */ - yylval.string = yy_strdup( "CASE" ); + yylval.string = hb_strdup( "CASE" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -347,7 +342,7 @@ Separator {SpaceTab} /* ************************************************************************ */ %} "decl"("are"|"ar"|"a")? { BEGIN PRIVATE_; - yylval.string = yy_strupr( yy_strdup( yytext ) ); + yylval.string = hb_strupr( hb_strdup( yytext ) ); } %{ /* ************************************************************************ */ @@ -376,7 +371,7 @@ Separator {SpaceTab} } else { /* there is another item in line already */ - yylval.string = yy_strdup( "DO" ); + yylval.string = hb_strdup( "DO" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -384,7 +379,7 @@ Separator {SpaceTab} {Separator}*(.|\n) { /* end of line or any operator */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; unput( yytext[ yyleng-1 ] ); - yylval.string = yy_strdup( "DO" ); + yylval.string = hb_strdup( "DO" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -437,7 +432,7 @@ Separator {SpaceTab} { /* Clipper does not like end[] & end() at the begining of line */ hb_compGenError( hb_comp_szErrors, 'E', ERR_ENDIF, NULL, NULL ); } - yylval.string = yy_strdup( "END" ); + yylval.string = hb_strdup( "END" ); hb_comp_iState =IDENTIFIER; unput( yytext[ yyleng-1 ] ); return IDENTIFIER; @@ -448,7 +443,7 @@ Separator {SpaceTab} { /* Clipper does not like end-> & end++ at the begining of line */ hb_compGenError( hb_comp_szErrors, 'E', ERR_ENDIF, NULL, NULL ); } - yylval.string = yy_strdup( "END" ); + yylval.string = hb_strdup( "END" ); hb_comp_iState =IDENTIFIER; unput( yytext[ yyleng-1 ] ); unput( yytext[ yyleng-2 ] ); @@ -456,7 +451,7 @@ Separator {SpaceTab} } {Separator}*[\+\-\:\=\|\$\%\*\,\/\[\]\)\}\^] { /* there is an operator after "end" */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - yylval.string = yy_strdup( "END" ); + yylval.string = hb_strdup( "END" ); hb_comp_iState =IDENTIFIER; unput( yytext[ yyleng-1 ] ); return IDENTIFIER; @@ -471,7 +466,7 @@ Separator {SpaceTab} } else { /* there is another item in line already */ - yylval.string = yy_strdup( "END" ); + yylval.string = hb_strdup( "END" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -493,7 +488,7 @@ Separator {SpaceTab} } else { /* there is another item in line already */ - yylval.string = yy_strdup( "EXIT" ); + yylval.string = hb_strdup( "EXIT" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -508,14 +503,14 @@ Separator {SpaceTab} } else { /* there is another item in line already */ - yylval.string = yy_strdup( "EXIT" ); + yylval.string = hb_strdup( "EXIT" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } } {Separator}*. { /* any character (not identifier) after EXIT */ unput( yytext[ yyleng-1 ] ); - yylval.string = yy_strdup( "EXIT" ); + yylval.string = hb_strdup( "EXIT" ); if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; hb_comp_iState =IDENTIFIER; return IDENTIFIER; @@ -524,7 +519,7 @@ Separator {SpaceTab} /* ************************************************************************ */ %} "exte"|"exter"|"extern"|"externa"|"external" { BEGIN EXTERNAL_; - yylval.string = yy_strupr( yy_strdup( yytext ) ); + yylval.string = hb_strupr( hb_strdup( yytext ) ); } {Separator}+[_a-zA-Z] { /* an identifier after the EXTERNAL */ unput( yytext[ yyleng-1 ] ); @@ -552,11 +547,11 @@ Separator {SpaceTab} /* ************************************************************************ */ %} "_fie"|"_fiel"|"_field" { BEGIN FIELD_; - yylval.string = yy_strupr( yy_strdup( yytext ) ); + yylval.string = hb_strupr( hb_strdup( yytext ) ); } "fiel"|"field" { BEGIN FIELD_; - yylval.string = yy_strupr( yy_strdup( yytext ) ); + yylval.string = hb_strupr( hb_strdup( yytext ) ); } {Separator}+[_a-zA-Z] { /* an identifier after the FIELD */ unput( yytext[ yyleng-1 ] ); @@ -602,7 +597,7 @@ Separator {SpaceTab} } else { /* for example: DO for WITH variable */ - yylval.string = yy_strdup( "FOR" ); + yylval.string = hb_strdup( "FOR" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -613,14 +608,14 @@ Separator {SpaceTab} { /* Clipper does not like FOR() at the begining of line */ hb_compGenError( hb_comp_szErrors, 'E', ERR_SYNTAX, yytext, NULL ); } - yylval.string = yy_strdup( "FOR" ); + yylval.string = hb_strdup( "FOR" ); hb_comp_iState =IDENTIFIER; unput( yytext[ yyleng-1 ] ); return IDENTIFIER; } {Separator}*[^_a-zA-Z] { /* there is no identifier after "FOR" */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - yylval.string = yy_strdup( "FOR" ); + yylval.string = hb_strdup( "FOR" ); unput( yytext[ yyleng-1 ] ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; @@ -709,7 +704,7 @@ Separator {SpaceTab} return IN; else { - yylval.string =yy_strdup( "IN" ); + yylval.string =hb_strdup( "IN" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -717,7 +712,7 @@ Separator {SpaceTab} {Separator}*\n { if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; unput( yytext[ yyleng-1 ] ); - yylval.string =yy_strdup( "IN" ); + yylval.string =hb_strdup( "IN" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -727,7 +722,7 @@ Separator {SpaceTab} {Separator}*. { if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; unput( yytext[ yyleng-1 ] ); - yylval.string =yy_strdup( "IN" ); + yylval.string =hb_strdup( "IN" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -745,14 +740,14 @@ Separator {SpaceTab} } else { /* there is another item in line already */ - yylval.string = yy_strdup( "INIT" ); + yylval.string = hb_strdup( "INIT" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } } {Separator}*[^fFpP] { /* any character (not identifier) after EXIT */ unput( yytext[ yyleng-1 ] ); - yylval.string = yy_strdup( "INIT" ); + yylval.string = hb_strdup( "INIT" ); if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; hb_comp_iState =IDENTIFIER; return IDENTIFIER; @@ -762,7 +757,7 @@ Separator {SpaceTab} %} "#"{Separator}*"line" return LINE; "loca"|"local" { BEGIN LOCAL_; - yylval.string = yy_strupr( yy_strdup( yytext ) ); + yylval.string = hb_strupr( hb_strdup( yytext ) ); } {Separator}+[_a-zA-Z] { /* an identifier after LOCAL */ unput( yytext[ yyleng-1 ] ); @@ -801,14 +796,14 @@ Separator {SpaceTab} } else { /* there is another item in line already */ - yylval.string = yy_strdup( "LOOP" ); + yylval.string = hb_strdup( "LOOP" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } } {Separator}*. { /* any character (not LF) after LOOP */ unput( yytext[ yyleng-1 ] ); - yylval.string = yy_strdup( "LOOP" ); + yylval.string = hb_strdup( "LOOP" ); if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; hb_comp_iState =IDENTIFIER; return IDENTIFIER; @@ -817,7 +812,7 @@ Separator {SpaceTab} /* ************************************************************************ */ %} "memv"|"memva"|"memvar" { BEGIN MEMVAR_; - yylval.string = yy_strupr( yy_strdup( yytext ) ); + yylval.string = hb_strupr( hb_strdup( yytext ) ); } {Separator}+[_a-zA-Z] { /* an identifier after MEMVAR */ unput( yytext[ yyleng-1 ] ); @@ -856,7 +851,7 @@ Separator {SpaceTab} } else { /* there is another item in line already */ - yylval.string = yy_strdup( "NEXT" ); + yylval.string = hb_strdup( "NEXT" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -867,7 +862,7 @@ Separator {SpaceTab} { /* Clipper does not like NEXT[] & NEXT() at the begining of line */ hb_compGenError( hb_comp_szErrors, 'E', ERR_NEXTFOR, NULL, NULL ); } - yylval.string = yy_strdup( "NEXT" ); + yylval.string = hb_strdup( "NEXT" ); hb_comp_iState =IDENTIFIER; unput( yytext[ yyleng-1 ] ); return IDENTIFIER; @@ -878,7 +873,7 @@ Separator {SpaceTab} { /* Clipper does not like next-> & next++ at the begining of line */ hb_compGenError( hb_comp_szErrors, 'E', ERR_NEXTFOR, NULL, NULL ); } - yylval.string = yy_strdup( "NEXT" ); + yylval.string = hb_strdup( "NEXT" ); hb_comp_iState =IDENTIFIER; unput( yytext[ yyleng-1 ] ); unput( yytext[ yyleng-2 ] ); @@ -886,7 +881,7 @@ Separator {SpaceTab} } {Separator}*[^_a-zA-Z] { /* there is no identifier after "next" */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - yylval.string = yy_strdup( "NEXT" ); + yylval.string = hb_strdup( "NEXT" ); unput( yytext[ yyleng-1 ] ); return IDENTIFIER; } @@ -902,7 +897,7 @@ Separator {SpaceTab} } else { - yylval.string = yy_strdup( "NEXT" ); + yylval.string = hb_strdup( "NEXT" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -917,7 +912,7 @@ Separator {SpaceTab} %} "para"|"param"|"parame"|"paramet"|"paramete"|"parameter"|"parameters" { BEGIN PARAM_; - yylval.string = yy_strupr( yy_strdup( yytext ) ); + yylval.string = hb_strupr( hb_strdup( yytext ) ); } {Separator}+[_a-zA-Z] { /* an identifier after PARAMETERS */ unput( yytext[ yyleng-1 ] ); @@ -944,7 +939,7 @@ Separator {SpaceTab} /* ************************************************************************ */ %} "priv"("ate"|"at"|"a")? { BEGIN PRIVATE_; - yylval.string = yy_strupr( yy_strdup( yytext ) ); + yylval.string = hb_strupr( hb_strdup( yytext ) ); } {Separator}+[_a-zA-Z] { /* an Identifier after PRIVATE */ unput( yytext[ yyleng-1 ] ); @@ -976,7 +971,7 @@ Separator {SpaceTab} /* ************************************************************************ */ %} "publ"("ic"|"i")? { BEGIN PUBLIC_; - yylval.string = yy_strupr( yy_strdup( yytext ) ); + yylval.string = hb_strupr( hb_strdup( yytext ) ); } {Separator}+[_a-zA-Z] { /* an identifier after PUBLIC */ unput( yytext[ yyleng-1 ] ); @@ -1021,7 +1016,7 @@ Separator {SpaceTab} { /* we have DO while - replace it with while() */ unput( ')' ); unput( '(' ); } - yylval.string = yy_strdup( "WHILE" ); + yylval.string = hb_strdup( "WHILE" ); return IDENTIFIER; } {Separator}*[\[] { /* array */ @@ -1031,13 +1026,13 @@ Separator {SpaceTab} } {Separator}*[\:\=\|\$\%\*\,\/\]\)\}\^] { /* there is an operator after "case" */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - yylval.string = yy_strdup( "WHILE" ); + yylval.string = hb_strdup( "WHILE" ); unput( yytext[ yyleng-1 ] ); return IDENTIFIER; } {Separator}*("+="|"-="|"->") { /* operators */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - yylval.string = yy_strdup( "WHILE" ); + yylval.string = hb_strdup( "WHILE" ); unput( yytext[ yyleng-1 ] ); unput( yytext[ yyleng-2 ] ); return IDENTIFIER; @@ -1059,7 +1054,7 @@ Separator {SpaceTab} } else { /* there is another item in line already */ - yylval.string = yy_strdup( "WHILE" ); + yylval.string = hb_strdup( "WHILE" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -1071,7 +1066,7 @@ Separator {SpaceTab} {Separator}*\n { /* at the end of line */ if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; unput( '\n' ); - yylval.string = yy_strdup( "WITH" ); + yylval.string = hb_strdup( "WITH" ); return IDENTIFIER; } {Separator}*"with" { @@ -1080,7 +1075,7 @@ Separator {SpaceTab} if( hb_comp_iState == DO ) { /* DO with */ hb_comp_iState =IDENTIFIER; - yylval.string = yy_strdup( "WITH" ); + yylval.string = hb_strdup( "WITH" ); return IDENTIFIER; } else @@ -1103,7 +1098,7 @@ Separator {SpaceTab} } else { - yylval.string = yy_strdup( "WITH" ); + yylval.string = hb_strdup( "WITH" ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } @@ -1152,7 +1147,7 @@ Separator {SpaceTab} [\(] ++_iOpenBracket; hb_comp_iState =SEPARATOR; return yytext[ 0 ]; [\)] --_iOpenBracket; hb_comp_iState =SEPARATOR; return yytext[ 0 ]; -{InvalidNumber} BEGIN INVALIDNUM_; yylval.string = yy_strupr( yy_strdup( yytext ) ); +{InvalidNumber} BEGIN INVALIDNUM_; yylval.string = hb_strupr( hb_strdup( yytext ) ); ("."|{Separator}+) { hb_compGenError( hb_comp_szErrors, 'E', ERR_NUMERIC_FORMAT, NULL, NULL ); } @@ -1167,7 +1162,7 @@ Separator {SpaceTab} {Number} { return yy_ConvertNumber( yytext ); } -{HexNumber} { +{HexNumber} { long lNumber = 0; sscanf( yytext, "%lxI", &lNumber ); @@ -1220,8 +1215,8 @@ Separator {SpaceTab} yytext[ 10 ] = 0; yyleng = 10; } - yylval.string = yy_strupr( yy_strdup( yytext ) ); - /*printf( "\nIdentifier = '%s'\n", yy_strupr( yy_strdup( yytext ) ) );*/ + yylval.string = hb_strupr( hb_strdup( yytext ) ); + /*printf( "\nIdentifier = '%s'\n", hb_strupr( hb_strdup( yytext ) ) );*/ hb_comp_iState = IDENTIFIER; return IDENTIFIER; } @@ -1276,7 +1271,7 @@ Separator {SpaceTab} yytext[ 10 ] = 0; yyleng = 10; } - yylval.string = yy_strupr( yy_strdup( yytext ) ); + yylval.string = hb_strupr( hb_strdup( yytext ) ); hb_comp_iState =IDENTIFIER; return IDENTIFIER; } diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index dd20e6f299..27cf08a40a 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -80,11 +80,6 @@ static void * hb_compElseIfGen( void * pFirstElseIf, ULONG ulOffset ); /* genera static void hb_compElseIfFix( void * pIfElseIfs ); /* implements the ElseIfs pcode fixups */ /* Misc functions defined in harbour.c */ -extern void * hb_xgrab( ULONG ulSize ); /* allocates fixed memory, exits on failure */ -extern void * hb_xrealloc( void * pMem, ULONG ulSize ); /* reallocates memory */ -extern void hb_xfree( void * pMem ); /* frees fixed memory */ -extern char * yy_strupr( char * p ); -extern char * yy_strdup( char * p ); extern void hb_compGenError( char* _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 ); extern void hb_compGenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2); @@ -1322,7 +1317,7 @@ DoProc : DO IDENTIFIER | DO IDENTIFIER WITH DoArgList { $$ = hb_compExprNewFunCall( $2, $4 ); } | WHILE WITH DoArgList - { $$ = hb_compExprNewFunCall( yy_strdup("WHILE"), $3 ); } + { $$ = hb_compExprNewFunCall( hb_strdup("WHILE"), $3 ); } ; DoArgList : ',' { $$ = hb_compExprAddListExpr( hb_compExprNewArgList( hb_compExprNewNil() ), hb_compExprNewNil() ); } @@ -1353,13 +1348,13 @@ int harbour_main( char * szName ) /* Generate the starting procedure frame */ if( hb_comp_bStartProc ) - hb_compFunctionAdd( yy_strupr( yy_strdup( szName ) ), FS_PUBLIC, FUN_PROCEDURE ); + hb_compFunctionAdd( hb_strupr( hb_strdup( szName ) ), FS_PUBLIC, FUN_PROCEDURE ); else /* Don't pass the name of module if the code for starting procedure * will be not generated. The name cannot be placed as first symbol * because this symbol can be used as function call or memvar's name. */ - hb_compFunctionAdd( yy_strupr( yy_strdup( "" ) ), FS_PUBLIC, FUN_PROCEDURE ); + hb_compFunctionAdd( hb_strupr( hb_strdup( "" ) ), FS_PUBLIC, FUN_PROCEDURE ); yyparse(); diff --git a/harbour/source/pp/hbpp.c b/harbour/source/pp/hbpp.c index 6f3603139f..7b7561e173 100644 --- a/harbour/source/pp/hbpp.c +++ b/harbour/source/pp/hbpp.c @@ -280,7 +280,7 @@ static int ParseDefine( char * sLine ) lastdef = hb_pp_AddDefine( defname, ( *sLine == '\0' )? NULL : sLine ); lastdef->npars = npars; - lastdef->pars = ( npars <= 0 )? NULL : hb_pp_strodup( pars ); + lastdef->pars = ( npars <= 0 )? NULL : hb_strdup( pars ); } else hb_compGenError( hb_pp_szErrors, 'F', ERR_DEFINE_ABSENT, NULL, NULL ); @@ -307,10 +307,10 @@ DEFINES * hb_pp_AddDefine( char * defname, char * value ) stdef = ( DEFINES * ) hb_xgrab( sizeof( DEFINES ) ); stdef->last = hb_pp_topDefine; hb_pp_topDefine = stdef; - stdef->name = hb_pp_strodup( defname ); + stdef->name = hb_strdup( defname ); s_kolAddDefs++; } - stdef->value = ( value == NULL )? NULL : hb_pp_strodup( value ); + stdef->value = ( value == NULL )? NULL : hb_strdup( value ); return stdef; } @@ -473,8 +473,8 @@ static void ParseCommand( char * sLine, BOOL com_or_xcom, BOOL com_or_tra ) stcmd = AddTranslate( cmdname ); stcmd->com_or_xcom = com_or_xcom; - stcmd->mpatt = hb_pp_strodup( mpatt ); - stcmd->value = ( rlen > 0 ) ? hb_pp_strodup( rpatt ) : NULL; + stcmd->mpatt = hb_strdup( mpatt ); + stcmd->value = ( rlen > 0 ) ? hb_strdup( rpatt ) : NULL; } else hb_compGenError( hb_pp_szErrors, 'F', ERR_COMMAND_DEFINITION, NULL, NULL ); @@ -589,7 +589,7 @@ static COMMANDS * AddCommand( char * cmdname ) stcmd = ( COMMANDS * ) hb_xgrab( sizeof( COMMANDS ) ); stcmd->last = hb_pp_topCommand; hb_pp_topCommand = stcmd; - stcmd->name = hb_pp_strodup( cmdname ); + stcmd->name = hb_strdup( cmdname ); return stcmd; } @@ -602,7 +602,7 @@ static COMMANDS* AddTranslate( char * traname ) sttra = ( COMMANDS * ) hb_xgrab( sizeof( COMMANDS ) ); sttra->last = hb_pp_topTranslate; hb_pp_topTranslate = sttra; - sttra->name = hb_pp_strodup( traname ); + sttra->name = hb_strdup( traname ); return sttra; } @@ -2106,20 +2106,6 @@ static int strincpy( char * ptro, char * ptri ) return lens; } -char * hb_pp_strodup( char * stroka ) -{ - char *ptr; - int lens = 0; - - HB_TRACE(HB_TR_DEBUG, ("hb_pp_strodup(%s)", stroka)); - - while( *(stroka+lens) != '\0' ) lens++; - ptr = ( char * ) hb_xgrab( lens + 1 ); - memcpy( ptr, stroka, lens+1 ); - *(ptr+lens) = '\0'; - return ptr; -} - static int strotrim( char * stroka ) { char *ptr = stroka, lastc = '0', curc; diff --git a/harbour/source/pp/stdalone/hbpp.c b/harbour/source/pp/stdalone/hbpp.c index dcd419d3a8..2651d0a556 100644 --- a/harbour/source/pp/stdalone/hbpp.c +++ b/harbour/source/pp/stdalone/hbpp.c @@ -89,7 +89,7 @@ int main( int argc, char * argv[] ) case 'D': /* defines a #define from the command line */ { i = 0; - szDefText = hb_pp_strodup( argv[ iArg ] + 2 ); + szDefText = hb_strdup( argv[ iArg ] + 2 ); while( i < strlen( szDefText ) && szDefText[ i ] != '=' ) i++; if( szDefText[ i ] != '=' ) @@ -182,7 +182,7 @@ int main( int argc, char * argv[] ) char * pPath; char * pDelim; - pPath = szInclude = hb_pp_strodup( szInclude ); + pPath = szInclude = hb_strdup( szInclude ); while( ( pDelim = strchr( pPath, OS_PATH_LIST_SEPARATOR ) ) != NULL ) { *pDelim = '\0';