static PHB_EXPR hb_compErrorSyntax( HB_COMP_DECL, PHB_EXPR pExpr ) { const char * szDesc = hb_compExprDescription( pExpr ); hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, szDesc, NULL ); return pExpr; }
PHB_EXPR hb_compErrorAlias( HB_COMP_DECL, PHB_EXPR pExpr ) { const char * szDesc = hb_compExprDescription( pExpr ); hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_INVALID_ALIAS, szDesc, NULL ); return pExpr; }
void hb_compErrorCodeblockWith( HB_COMP_DECL, const char * szMessage ) { HB_BOOL fError = HB_COMP_PARAM->fError; hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_WITHOBJECT_MACROBLOCK, szMessage, NULL ); HB_COMP_PARAM->fError = fError; /* restore error flag for this line */ }
PHB_EXPR hb_compErrorStatic( HB_COMP_DECL, const char * szVarName, PHB_EXPR pExpr ) { const char * szDesc = hb_compExprDescription( pExpr ); hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_ILLEGAL_INIT, szVarName, szDesc ); return pExpr; }
void hb_compErrorCodeblock( HB_COMP_DECL, const char * szBlock ) { HB_BOOL fError = HB_COMP_PARAM->fError; hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_BLOCK, szBlock, NULL ); HB_COMP_PARAM->fError = fError; /* restore error flag for this line */ }
void hb_xfree( void * pMem ) /* frees fixed memory */ { HB_TRACE(HB_TR_DEBUG, ("hb_xfree(%p)", pMem)); if( pMem ) free( pMem ); else hb_compGenError( NULL, hb_pp_szErrors, 'P', HB_PP_ERR_MEMFREE, NULL, NULL ); }
HB_BOOL hb_compFunCallCheck( HB_COMP_DECL, const char * szFuncCall, int iArgs ) { unsigned int uiFirst = 0, uiLast = HB_STD_FUNCOUNT - 1, uiMiddle; int iLen = ( int ) strlen( szFuncCall ), iCmp; /* Respect 4 or more letters shortcuts * SECO() is not allowed because of Clipper function SECONDS() * however SECO32() is a valid name. */ if( iLen < 4 ) iLen = 4; do { uiMiddle = ( uiFirst + uiLast ) >> 1; iCmp = strncmp( szFuncCall, s_stdFunc[ uiMiddle ].cFuncName, iLen ); if( iCmp <= 0 ) uiLast = uiMiddle; else uiFirst = uiMiddle + 1; } while( uiFirst < uiLast ); if( uiFirst != uiMiddle ) iCmp = strncmp( szFuncCall, s_stdFunc[ uiFirst ].cFuncName, iLen ); if( iCmp == 0 ) { const HB_FUNCINFO * pFunc = &s_stdFunc[ uiFirst ]; if( ( pFunc->iMinParam != -1 && iArgs < pFunc->iMinParam ) || ( pFunc->iMaxParam != -1 && iArgs > pFunc->iMaxParam ) ) { char szMsg[ 64 ]; if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_HARBOUR ) ) { if( pFunc->iMinParam == pFunc->iMaxParam ) hb_snprintf( szMsg, sizeof( szMsg ), "\nPassed: %i, expected: %i", iArgs, pFunc->iMinParam ); else if( pFunc->iMaxParam == -1 ) hb_snprintf( szMsg, sizeof( szMsg ), "\nPassed: %i, expected at least: %i", iArgs, pFunc->iMinParam ); else if( pFunc->iMinParam == -1 ) hb_snprintf( szMsg, sizeof( szMsg ), "\nPassed: %i, expected less than: %i", iArgs, pFunc->iMaxParam ); else hb_snprintf( szMsg, sizeof( szMsg ), "\nPassed: %i, expected from: %i to: %i", iArgs, pFunc->iMinParam, pFunc->iMaxParam ); } else szMsg[ 0 ] = '\0'; hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_CHECKING_ARGS, szFuncCall, szMsg ); return HB_FALSE; } } return HB_TRUE; }
void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */ { void * pResult = realloc( pMem, ulSize ); HB_TRACE(HB_TR_DEBUG, ("hb_xrealloc(%p, %lu)", pMem, ulSize)); if( ! pResult ) hb_compGenError( NULL, hb_pp_szErrors, 'P', HB_PP_ERR_MEMREALLOC, NULL, NULL ); return pResult; }
void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on failure */ { void * pMem = malloc( ulSize ); HB_TRACE(HB_TR_DEBUG, ("hb_xgrab(%lu)", ulSize)); if( ! pMem ) hb_compGenError( NULL, hb_pp_szErrors, 'P', HB_PP_ERR_MEMALLOC, NULL, NULL ); return pMem; }
static HB_FIX_FUNC( hb_p_localnearerr ) { HB_SYMBOL_UNUSED( pFunc ); HB_SYMBOL_UNUSED( nPCodePos ); /* * this code should never be executed because compiler should * generate only non size optimized HB_P_POPLOCAL pcodes * for function body */ hb_compGenError( cargo->HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_OPTIMIZEDLOCAL_OUT_OF_RANGE, "", "" ); return 0; }
void hb_compGenPortObj( HB_COMP_DECL, PHB_FNAME pFileName ) { char szFileName[ HB_PATH_MAX ]; HB_SIZE nSize; HB_BYTE * pHrbBody; FILE * yyc; if( ! pFileName->szExtension ) pFileName->szExtension = ".hrb"; hb_fsFNameMerge( szFileName, pFileName ); yyc = hb_fopen( szFileName, "wb" ); if( ! yyc ) { hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_CREATE_OUTPUT, szFileName, NULL ); return; } if( ! HB_COMP_PARAM->fQuiet ) { char buffer[ 80 + HB_PATH_MAX - 1 ]; hb_snprintf( buffer, sizeof( buffer ), "Generating Harbour Portable Object output to \'%s\'... ", szFileName ); hb_compOutStd( HB_COMP_PARAM, buffer ); } hb_compGenBufPortObj( HB_COMP_PARAM, &pHrbBody, &nSize ); if( fwrite( pHrbBody, nSize, 1, yyc ) != 1 ) hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_FILE_WRITE, szFileName, NULL ); hb_xfree( pHrbBody ); fclose( yyc ); if( ! HB_COMP_PARAM->fQuiet ) hb_compOutStd( HB_COMP_PARAM, "Done.\n" ); }
static void hb_pp_ErrorGen( void * cargo, const char * const szMsgTable[], char cPrefix, int iErrorCode, const char * szParam1, const char * szParam2 ) { HB_COMP_DECL = ( PHB_COMP ) cargo; int iCurrLine = HB_COMP_PARAM->currLine; const char * currModule = HB_COMP_PARAM->currModule; HB_COMP_PARAM->currLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP ); HB_COMP_PARAM->currModule = hb_pp_fileName( HB_COMP_PARAM->pLex->pPP ); if( cPrefix == 'W' ) hb_compGenWarning( HB_COMP_PARAM, szMsgTable, cPrefix, iErrorCode, szParam1, szParam2 ); else hb_compGenError( HB_COMP_PARAM, szMsgTable, cPrefix, iErrorCode, szParam1, szParam2 ); HB_COMP_PARAM->fError = HB_FALSE; HB_COMP_PARAM->currLine = iCurrLine; HB_COMP_PARAM->currModule = currModule; }
static void hb_pp_hb_inLine( void * cargo, char * szFunc, char * pBuffer, HB_SIZE nSize, int iLine ) { HB_COMP_DECL = ( PHB_COMP ) cargo; if( HB_COMP_PARAM->iLanguage != HB_LANG_C ) { int iCurrLine = HB_COMP_PARAM->currLine; HB_COMP_PARAM->currLine = iLine; hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_REQUIRES_C, NULL, NULL ); HB_COMP_PARAM->fError = HB_FALSE; HB_COMP_PARAM->currLine = iCurrLine; } else { PHB_HINLINE pInline = hb_compInlineAdd( HB_COMP_PARAM, hb_compIdentifierNew( HB_COMP_PARAM, szFunc, HB_IDENT_COPY ), iLine ); pInline->pCode = ( HB_BYTE * ) hb_xgrab( nSize + 1 ); memcpy( pInline->pCode, pBuffer, nSize ); pInline->pCode[ nSize ] = '\0'; pInline->nPCodeSize = nSize; } }
double CalcConstant( char **pExp ) { char *sToken; PBIOP Exp = BiOp(), Root = Exp; double dExp; int bNot = 0; //printf( "Process: >%s<\n", *pExp ); Top: sToken = NextTokenInConstant( pExp ); if( sToken[0] == '(' ) { if( bNot ) { bNot = 0; Exp->Left = ! CalcConstant( pExp ); } else { Exp->Left = CalcConstant( pExp ); } sToken = NextTokenInConstant( pExp ); if( sToken[0] != ')' ) { *pExp -= strlen( sToken ); hb_compGenError( hb_pp_szErrors, 'F', HB_PP_ERR_INVALID_CONSTANT_EXPRESSION, *pExp, NULL ); } } else if( sToken[0] == '!' ) { bNot = ! bNot; goto Top; } else { if( bNot ) { bNot = 0; Exp->Left = ! VALUE( sToken ); } else { Exp->Left = VALUE( sToken ); } } sToken = NextTokenInConstant( pExp ); if( sToken[0] && strstr( "+;-;*;/;&;|;&&;||;==;!=;<;>;<=;>=", sToken ) ) { strcpy( Exp->Operator, sToken ); Exp->Right = BiOp(); Exp = Exp->Right; goto Top; } *pExp -= strlen( sToken ); dExp = Reduce( Root ); //printf( "Result: %i Next: >%s<\n", (int)dExp, *pExp ); return dExp; }
char * NextTokenInConstant( char **pExp ) { static char sToken[32]; //printf( "Process: >%s<\n", *pExp ); sToken[0] = '\0'; if( *pExp[0] == '\0' ) { return sToken; } while( (*pExp)[0] == ' ' ) { (*pExp)++; } // Numbers if( isdigit( ( BYTE ) (*pExp)[0] ) || (*pExp)[0] == '-' || (*pExp)[0] == '+' ) { int i = 0; if( (*pExp)[0] == '0' && (*pExp)[1] == 'x' ) { sToken[0] = (*pExp)[0]; sToken[1] = (*pExp)[1]; (*pExp) += 2; i = 2; // Hex while( i < 31 && isxdigit( ( BYTE ) (*pExp)[0] ) ) { sToken[i++] = (*pExp)[0]; (*pExp)++; } sToken[i] = '\0'; return sToken; } else { sToken[0] = '\0'; while( (*pExp)[0] == '-' || (*pExp)[0] == '+' ) { if( (*pExp)[0] == '-' ) { if( sToken[0] == '-' ) { sToken[0] = '\0'; i = 0; } else { sToken[0] = '-'; i = 1; } } else { // Postitive is already implied! } (*pExp)++; } } // Number do { sToken[i++] = (*pExp)[0]; (*pExp)++; } while( i < 31 && isdigit( ( BYTE ) (*pExp)[0] ) ); // Decimals if( i < 31 && (*pExp)[0] == '.' ) { sToken[i++] = (*pExp)[0]; (*pExp)++; while( i < 31 && isdigit( ( BYTE ) (*pExp)[0] ) ) { sToken[i++] = (*pExp)[0]; (*pExp)++; } } sToken[i] = '\0'; } // Operators else if( (*pExp)[0] == '<' && (*pExp)[1] == '>' ) { sToken[0] = '!'; sToken[1] = '='; sToken[2] = '\0'; (*pExp) += 2; } else if( strchr( "+-*/&|()!=<>", (*pExp)[0] ) ) { sToken[0] = (*pExp)[0]; sToken[1] = '\0'; (*pExp)++; } else if( (*pExp)[0] == '#' ) { sToken[0] = '!'; sToken[1] = '='; sToken[2] = '\0'; (*pExp)++; } else if( (*pExp)[0] == '.' && toupper( (*pExp)[1] ) == 'A' && toupper( (*pExp)[2] ) == 'N' && toupper( (*pExp)[3] ) == 'D' && toupper( (*pExp)[4] ) == '.' ) { sToken[0] = '&'; sToken[1] = '&'; sToken[2] = '\0'; (*pExp) += 5; } else if( (*pExp)[0] == '.' && toupper( (*pExp)[1] ) == 'N' && toupper( (*pExp)[2] ) == 'O' && toupper( (*pExp)[3] ) == 'T' && toupper( (*pExp)[4] ) == '.' ) { sToken[0] = '!'; sToken[1] = '\0'; (*pExp) += 5; } else if( (*pExp)[0] == '.' && toupper( (*pExp)[1] ) == 'O' && toupper( (*pExp)[2] ) == 'R' && toupper( (*pExp)[3] ) == '.' ) { sToken[0] = '|'; sToken[1] = '|'; sToken[2] = '\0'; (*pExp) += 4; } else if( (*pExp)[0] == '.' && toupper( (*pExp)[1] ) == 'T' && toupper( (*pExp)[2] ) == '.' ) { sToken[0] = '1'; sToken[1] = '\0'; (*pExp) += 3; } else if( (*pExp)[0] == '.' && toupper( (*pExp)[1] ) == 'F' && toupper( (*pExp)[2] ) == '.' ) { sToken[0] = '0'; sToken[1] = '\0'; (*pExp) += 3; } else if( isalpha( ( BYTE ) (*pExp)[0] ) || (*pExp)[0] == '_' ) { int i = 0; do { sToken[i++] = (*pExp)[0]; (*pExp)++; } while( isalnum( ( BYTE ) (*pExp)[0] ) || (*pExp)[0] == '_' ); } // Might be a first char of a double char operator! if( sToken[1] == '\0' && ( ( sToken[0] == '&' && (*pExp)[0] == '&' ) || ( sToken[0] == '|' && (*pExp)[0] == '|' ) || ( sToken[0] == '=' && (*pExp)[0] == '=' ) || ( sToken[0] == '!' && (*pExp)[0] == '=' ) || ( sToken[0] == '<' && (*pExp)[0] == '=' ) || ( sToken[0] == '>' && (*pExp)[0] == '=' ) ) ) { sToken[1] = (*pExp)[0]; sToken[2] = '\0'; (*pExp)++; } else if( sToken[0] == '\0' && (*pExp)[0] ) { hb_compGenError( hb_pp_szErrors, 'F', HB_PP_ERR_INVALID_CONSTANT_EXPRESSION, *pExp, NULL ); } else { //printf( "Token: >%s< Rest: >%s<\n", sToken, *pExp ); } return sToken; }
int hb_pp_Internal( FILE * handl_o, char * sOut ) { PFILE pFile; char * ptr, * ptrOut, * tmpPtr; int lContinue; int lens, rdlen; int lLine = 0; int State = 0; HB_TRACE(HB_TR_DEBUG, ("hb_pp_Internal(%p, %s)", handl_o, sOut)); while( TRUE ) { pFile = hb_comp_files.pLast; lens = lContinue = 0; ptrOut = sOut; while( ( rdlen = hb_pp_RdStr( pFile->handle, s_szLine + lens, HB_PP_STR_SIZE - 1 - lens, lContinue, ( char * ) pFile->pBuffer, &( pFile->lenBuffer ), &( pFile->iBuffer ), State ) ) >= 0 ) { lens += rdlen; hb_comp_iLine ++; // printf( "Line: %i Len: %i <%s>\n", hb_comp_iLine, lens, s_szLine ); if( lens >= HB_PP_STR_SIZE ) { hb_compGenError( hb_pp_szErrors, 'F', HB_PP_ERR_BUFFER_OVERFLOW, NULL, NULL ); } if( hb_pp_bInline ) { break; } 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'; State = STATE_NORMAL; } else { lContinue = 0; lens = 0; State = 0; } if( ! lContinue ) { if( *s_szLine != '\0' ) { ptr = s_szLine; HB_SKIPTABSPACES( ptr ); if( *ptr == '#' ) { hb_pp_ParseDirective( ptr + 1 ); if( pFile != hb_comp_files.pLast ) { pFile = ( PFILE ) ( ( PFILE ) hb_comp_files.pLast )->pPrev; if( lLine ) { hb_snprintf( s_szLine, sizeof( s_szLine ), "#line %d \"%s\"\n", pFile->iLine, pFile->szFileName ); } else { *s_szLine = '\0'; } lLine = 0; hb_snprintf( s_szLine + strlen( s_szLine ), sizeof( s_szLine ) - strlen( s_szLine ), "#line 1 \"%s\"", hb_comp_files.pLast->szFileName ); } else { *s_szLine = '\0'; } } else { if( *ptr == '\0' ) { if( hb_comp_files.iFiles == 1 ) { *s_szLine = '\0'; } else { continue; } } else { if( hb_pp_nCondCompile == 0 || hb_pp_aCondCompile[ hb_pp_nCondCompile - 1 ] > 0 ) { //printf( "Parse: >%s<\n", ptr ); hb_pp_ParseExpression( ptr, s_szOutLine ); //printf( "1-Parsed: >%s<\n", s_szLine ); //printf( "2-Parsed: >%s<\n", s_szOutLine ); } else { *s_szLine = '\0'; } } } } break; } } if( hb_pp_bInComment ) { hb_compGenError( hb_pp_szErrors, 'F', HB_PP_ERR_UNTERMINATED_COMMENTS, NULL, NULL ); } if( rdlen < 0 ) { if( hb_comp_files.iFiles == 1 ) { return 0; /* we have reached the main EOF */ } else { CloseInclude(); lLine = 1; } /* Ron Pinkas added 2000-06-22 */ s_szLine[0] = '\0'; break; /* Ron Pinkas end 2000-06-22 */ } if( *s_szLine ) { break; } else { if( handl_o && s_szOutLine[0] == '#' ) { hb_pp_WrStr( handl_o, s_szOutLine ); s_szOutLine[0] = '\0'; } } } if( lLine ) { if( hb_comp_files.iFiles == 1 ) { hb_pp_LastOutLine = hb_comp_iLine; } sprintf( ptrOut, "#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 */ } lens = hb_pp_strocpy( ptrOut, s_szLine ) + ( ptrOut - sOut ); if( hb_comp_iLineINLINE && hb_pp_bInline == 0 ) { hb_comp_iLine = hb_comp_iLinePRG + ( hb_comp_iLine - hb_comp_iLineINLINE ); hb_comp_iLineINLINE = 0; } if( handl_o ) { char *pTmp = sOut; HB_SKIPTABSPACES( pTmp ); //printf( "1>%s<\n", sOut ); //printf( "2>%s<\n", s_szOutLine ); if( s_szOutLine[0] && ( strstr( s_szOutLine, pTmp ) ) ) { if( pTmp > sOut ) { hb_pp_Stuff( sOut, s_szOutLine, pTmp - sOut, 0, strlen( s_szOutLine ) ); } hb_pp_WrStr( handl_o, s_szOutLine ); } else if( s_szOutLine[0] == '#' && strstr( pTmp, s_szOutLine ) == NULL ) { strcpy( sOut + lens, s_szOutLine ); hb_pp_WrStr( handl_o, sOut ); } else { hb_pp_WrStr( handl_o, sOut ); } s_szOutLine[0] = '\0'; } *( sOut + lens++ ) = '\n'; *( sOut + lens ) = '\0'; #if 0 printf( "%d : %s\n", hb_comp_iLine, sOut ); #endif return lens; }
int hb_pp_ReadRules( void ) { PFILE pFile; char * ptr; int lContinue; int lens, rdlen; int State = 0; HB_TRACE(HB_TR_DEBUG, ("hb_pp_ReadRules()")); while( TRUE ) { pFile = hb_comp_files.pLast; lens = lContinue = 0; while( ( rdlen = hb_pp_RdStr( pFile->handle, s_szLine + lens, HB_PP_STR_SIZE - 1 - lens, lContinue, ( char * ) pFile->pBuffer, &( pFile->lenBuffer ), &( pFile->iBuffer ), State ) ) >= 0 ) { lens += rdlen; hb_comp_iLine++; if( lens >= HB_PP_STR_SIZE ) { hb_compGenError( hb_pp_szErrors, 'F', HB_PP_ERR_BUFFER_OVERFLOW, NULL, NULL ); } 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'; State = STATE_NORMAL; } else { lContinue = 0; lens = 0; State = 0; } if( ! lContinue ) { if( *s_szLine != '\0' ) { ptr = s_szLine; HB_SKIPTABSPACES( ptr ); if( *ptr == '#' ) { hb_pp_ParseDirective( ptr + 1 ); } *s_szLine = '\0'; } break; } } if( hb_pp_bInComment ) { hb_compGenError( hb_pp_szErrors, 'F', HB_PP_ERR_UNTERMINATED_COMMENTS, NULL, NULL ); } if( rdlen < 0 ) { if( hb_comp_files.iFiles == 1 ) { break; /* we have reached the main EOF */ } else { CloseInclude(); hb_pp_LastOutLine = hb_comp_iLine; } *s_szLine = '\0'; } } return 0; }
void hb_compErrorVParams( HB_COMP_DECL, const char * szFuncOrBlock ) { hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_NOT_VPARAMS, szFuncOrBlock, NULL ); }
PHB_EXPR hb_compErrorRefer( HB_COMP_DECL, PHB_EXPR pExpr, const char * szDesc ) { hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_INVALID_REFER, szDesc, NULL ); return pExpr; }
void hb_compErrorMacro( HB_COMP_DECL, const char * szText ) { hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szText, NULL ); }
static void hb_compChkEnvironVar( HB_COMP_DECL, const char * szSwitch ) { if( szSwitch && ! HB_COMP_PARAM->fExit ) { const char * s = szSwitch; /* If szSwitch doesn't start with a HB_OSOPTSEP char * show an error */ if( ! HB_ISOPTSEP( *s ) ) hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); else { s++; switch( *s ) { case 'a': case 'A': if( *( s + 1 ) == '-' ) HB_COMP_PARAM->fAutoMemvarAssume = HB_FALSE; else HB_COMP_PARAM->fAutoMemvarAssume = HB_TRUE; break; case 'b': case 'B': { unsigned int i = 0; char *szOption = hb_strupr( hb_strdup( s ) ); while( i < strlen( szOption ) && ! HB_ISOPTSEP( szOption[ i ] ) ) i++; szOption[ i ] = '\0'; if( strcmp( szOption, "BUILD" ) == 0 ) HB_COMP_PARAM->fBuildInfo = HB_TRUE; else { if( *( s + 1 ) == '-' ) HB_COMP_PARAM->fDebugInfo = HB_FALSE; else { HB_COMP_PARAM->fDebugInfo = HB_TRUE; HB_COMP_PARAM->fLineNumbers = HB_TRUE; } } hb_xfree( szOption ); break; } case 'c': case 'C': { unsigned int i = 0; char *szOption = hb_strupr( hb_strdup( s ) ); while( i < strlen( szOption ) && ! HB_ISOPTSEP( szOption[ i ] ) ) i++; szOption[ i ] = '\0'; if( strcmp( szOption, "CREDITS" ) == 0 || strcmp( szOption, "CREDIT" ) == 0 || strcmp( szOption, "CREDI" ) == 0 || strcmp( szOption, "CRED" ) == 0 ) HB_COMP_PARAM->fCredits = HB_TRUE; else hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, szOption, NULL ); hb_xfree( szOption ); break; } case 'd': case 'D': /* NOTE: Ignore these -d switches will be processed separately */ break; case 'e': case 'E': if( *( s + 1 ) == 's' || *( s + 1 ) == 'S' ) { switch( *( s + 2 ) ) { case '\0': case '0': HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DEFAULT; break; case '1': HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_SETEXIT; break; case '2': HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DELTARGET; break; default: hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); } } else hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); break; case 'g': case 'G': switch( *( s + 1 ) ) { case 'c': case 'C': HB_COMP_PARAM->iLanguage = HB_LANG_C; switch( *( s + 2 ) ) { case '3': HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_REALCODE; break; case '2': HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_VERBOSE; break; case '1': HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_NORMAL; break; case '\0': case '0': HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_COMPACT; break; default: hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); } break; case 'h': case 'H': HB_COMP_PARAM->iLanguage = HB_LANG_PORT_OBJ; break; case 'd': case 'D': if( HB_COMP_PARAM->szDepExt ) { hb_xfree( HB_COMP_PARAM->szDepExt ); HB_COMP_PARAM->szDepExt = NULL; } if( s[ 2 ] == '-' ) HB_COMP_PARAM->iTraceInclude = 0; else if( s[ 2 ] == '.' || s[ 2 ] == '\0' ) { HB_COMP_PARAM->iTraceInclude = 2; if( s[ 2 ] != '\0' ) HB_COMP_PARAM->szDepExt = hb_strdup( s + 2 ); } else hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); break; case 'e': case 'E': switch( *( s + 2 ) ) { case '1': HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_IDE; break; case '\0': case '0': HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_CLIPPER; break; default: hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); } break; default: hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_UNSUPPORTED_LANG, NULL, NULL ); break; } break; /* NOTE: h or H from HELP or help */ case 'h': case 'H': case '?': break; /* NOTE: It already has support for several include files */ case 'i': case 'I': switch( *( s + 1 ) ) { case '-': HB_COMP_PARAM->fINCLUDE = HB_FALSE; break; case '+': HB_COMP_PARAM->fINCLUDE = HB_TRUE; break; default: hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, s + 1, HB_FALSE ); } break; case 'j': case 'J': HB_COMP_PARAM->fI18n = HB_TRUE; if( s[ 1 ] ) HB_COMP_PARAM->pI18nFileName = hb_fsFNameSplit( s + 1 ); break; case 'k': case 'K': { int i = 1; while( s[ i ] && ! HB_COMP_PARAM->fExit ) { switch( s[ i++ ] ) { case '?': hb_compPrintLogo( HB_COMP_PARAM ); hb_compPrintModes( HB_COMP_PARAM ); HB_COMP_PARAM->fLogo = HB_FALSE; HB_COMP_PARAM->fQuiet = HB_TRUE; break; case 'h': case 'H': /* default Harbour mode */ if( s[ i ] == '-' ) { i++; HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HARBOUR; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_HARBOUR; break; case 'c': case 'C': /* clear all flags - minimal set of features */ HB_COMP_PARAM->supported &= HB_COMPFLAG_SHORTCUTS; HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP | HB_COMPFLAG_MACROTEXT; break; case 'x': case 'X': if( s[ i ] == '-' ) { i++; HB_COMP_PARAM->supported &= ~HB_COMPFLAG_XBASE; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_XBASE; break; case 'i': case 'I': if( s[ i ] == '-' ) { i++; HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HB_INLINE; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_HB_INLINE; break; case 'j': case 'J': if( s[ i ] == '+' ) { i++; HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP; } else HB_COMP_PARAM->supported &= ~HB_COMPFLAG_OPTJUMP; break; case 'm': case 'M': if( s[ i ] == '+' ) { i++; HB_COMP_PARAM->supported |= HB_COMPFLAG_MACROTEXT; } else HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACROTEXT; break; case 'd': case 'D': if( s[ i ] == '-' ) { i++; HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACRODECL; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_MACRODECL; break; case 'r': case 'R': if( s[ i ] == '-' ) { i++; HB_COMP_PARAM->supported &= ~HB_COMPFLAG_RT_MACRO; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_RT_MACRO; break; case 's': case 'S': if( s[ i ] == '-' ) { i++; HB_COMP_PARAM->supported &= ~HB_COMPFLAG_ARRSTR; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_ARRSTR; break; case 'o': case 'O': if( s[ i ] == '-' ) { i++; HB_COMP_PARAM->supported &= ~HB_COMPFLAG_EXTOPT; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_EXTOPT; break; case 'u': case 'U': if( s[ i ] == '-' ) { i++; HB_COMP_PARAM->supported &= ~HB_COMPFLAG_USERCP; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_USERCP; break; default: hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); break; } } break; } case 'l': case 'L': if( *( s + 1 ) == '-' ) HB_COMP_PARAM->fLineNumbers = HB_TRUE; else HB_COMP_PARAM->fLineNumbers = HB_FALSE; break; case 'm': case 'M': if( *( s + 1 ) == '-' ) HB_COMP_PARAM->fSingleModule = HB_FALSE; else HB_COMP_PARAM->fSingleModule = HB_TRUE; break; case 'n': case 'N': HB_COMP_PARAM->fNoStartUp = s[ 1 ] == '1'; switch( s[ 1 ] ) { case '-': HB_COMP_PARAM->iStartProc = 0; break; case '\0': case '0': case '1': HB_COMP_PARAM->iStartProc = 1; break; case '2': HB_COMP_PARAM->iStartProc = 2; break; default: hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); } break; case 'o': case 'O': HB_COMP_PARAM->pOutPath = hb_fsFNameSplit( s + 1 ); break; /* Added for preprocessor needs */ case 'p': case 'P': if( s[ 1 ] == '+' && s[ 2 ] == '\0' ) HB_COMP_PARAM->fPPT = HB_TRUE; else { if( HB_COMP_PARAM->pPpoPath ) { hb_xfree( HB_COMP_PARAM->pPpoPath ); HB_COMP_PARAM->pPpoPath = NULL; } if( s[ 1 ] == '-' && s[ 2 ] == '\0' ) HB_COMP_PARAM->fPPO = HB_FALSE; else { if( s[ 1 ] ) HB_COMP_PARAM->pPpoPath = hb_fsFNameSplit( s + 1 ); HB_COMP_PARAM->fPPO = HB_TRUE; } } break; case 'q': case 'Q': switch( *( s + 1 ) ) { case '2': HB_COMP_PARAM->fFullQuiet = HB_TRUE; case '0': HB_COMP_PARAM->fLogo = HB_FALSE; default: HB_COMP_PARAM->fQuiet = HB_TRUE; } break; case 'r': case 'R': if( *( s + 1 ) == ':' ) { int iOverflow; int iCycles = ( int ) hb_strValInt( s + 2, &iOverflow ); if( ! iOverflow && iCycles > 0 ) HB_COMP_PARAM->iMaxTransCycles = iCycles; } else { /* TODO: Implement this switch */ hb_notSupportedInfo( HB_COMP_PARAM, s ); } break; case 's': case 'S': switch( *( s + 1 ) ) { case '\0': HB_COMP_PARAM->iSyntaxCheckOnly = 1; break; case '-': HB_COMP_PARAM->iSyntaxCheckOnly = 0; break; case 'm': case 'M': if( s[ 2 ] == '\0' ) { HB_COMP_PARAM->iSyntaxCheckOnly = 2; break; } default: hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); } break; case 't': case 'T': /* TODO: Implement this switch */ hb_notSupportedInfo( HB_COMP_PARAM, s ); break; case 'u': case 'U': if( ( s[ 1 ] == 'N' || s[ 1 ] == 'n' ) && ( s[ 2 ] == 'D' || s[ 2 ] == 'd' ) && ( s[ 3 ] == 'E' || s[ 3 ] == 'e' ) && ( s[ 4 ] == 'F' || s[ 4 ] == 'f' ) && s[ 5 ] == ':' ) { /* NOTE: Ignore these -undef: switches (will be processed * separately) except -undef:.arch. */ if( s[ 6 ] == '.' && ( s[ 7 ] == 'A' || s[ 7 ] == 'a' ) && ( s[ 8 ] == 'R' || s[ 8 ] == 'r' ) && ( s[ 9 ] == 'C' || s[ 9 ] == 'c' ) && ( s[ 10 ] == 'H' || s[ 10 ] == 'h' ) && s[ 11 ] == '.' ) { HB_COMP_PARAM->fNoArchDefs = HB_TRUE; } break; } /* extended definitions file (-u+<file>) */ if( s[ 1 ] == '+' ) { if( s[ 2 ] ) { if( HB_COMP_PARAM->iStdChExt == 0 ) HB_COMP_PARAM->szStdChExt = ( char ** ) hb_xgrab( sizeof( char * ) ); else HB_COMP_PARAM->szStdChExt = ( char ** ) hb_xrealloc( HB_COMP_PARAM->szStdChExt, ( HB_COMP_PARAM->iStdChExt + 1 ) * sizeof( char * ) ); HB_COMP_PARAM->szStdChExt[ HB_COMP_PARAM->iStdChExt++ ] = hb_strdup( s + 2 ); } else hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); } else { if( HB_COMP_PARAM->szStdCh ) hb_xfree( HB_COMP_PARAM->szStdCh ); HB_COMP_PARAM->szStdCh = hb_strdup( s + 1 ); } break; case 'v': case 'V': if( *( s + 1 ) == '-' ) HB_COMP_PARAM->fForceMemvars = HB_FALSE; else HB_COMP_PARAM->fForceMemvars = HB_TRUE; break; case 'w': case 'W': HB_COMP_PARAM->iWarnings = 1; if( s[ 1 ] ) /* there is -w<0,1,2,3> probably */ { HB_COMP_PARAM->iWarnings = s[ 1 ] - '0'; if( HB_COMP_PARAM->iWarnings < 0 || HB_COMP_PARAM->iWarnings > 3 ) hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); } break; case 'x': case 'X': { unsigned int i = 1; while( s[ i ] && ! HB_ISOPTSEP( s[ i ] ) && i < sizeof( HB_COMP_PARAM->szPrefix ) - 1 ) { ++i; } if( i > 1 ) { memcpy( HB_COMP_PARAM->szPrefix, s + 1, i - 1 ); HB_COMP_PARAM->szPrefix[ i - 1 ] = '_'; HB_COMP_PARAM->szPrefix[ i ] = '\0'; } else { hb_snprintf( HB_COMP_PARAM->szPrefix, sizeof( HB_COMP_PARAM->szPrefix ), "%08lX_", PackDateTime() ); } break; } #ifdef YYDEBUG case 'y': case 'Y': yydebug = HB_TRUE; break; #endif case 'z': case 'Z': if( *( s + 1 ) == '-' ) HB_COMP_PARAM->supported |= HB_COMPFLAG_SHORTCUTS; else HB_COMP_PARAM->supported &= ~HB_COMPFLAG_SHORTCUTS; break; default: hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); break; } } } }
PHB_EXPR hb_compExprNewFunCall( PHB_EXPR pName, PHB_EXPR pParms, HB_COMP_DECL ) #endif { PHB_EXPR pExpr; #ifdef HB_MACRO_SUPPORT if( pName->ExprType == HB_ET_VARIABLE ) { /* My&var.1() executed by macro compiler */ /* NOTE: direct type change */ pName->ExprType = HB_ET_FUNNAME; pName->value.asSymbol.name = hb_compGetFuncID( pName->value.asSymbol.name, &pName->value.asSymbol.funcid, &pName->value.asSymbol.flags ); } #endif if( pName->ExprType == HB_ET_FUNNAME ) { /* The name of a function is specified at compile time * e.g. MyFunc() * * NOTE: 'pName' can be a macro expression that will be resolved * at runtime - in this case pName is an expression of HB_ET_MACRO type * e.g. &MyVar() */ HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewFunCall(%s)", pName->value.asSymbol.name ) ); #if ! defined( HB_MACRO_SUPPORT ) && defined( HB_USE_ENUM_FUNCTIONS ) { int iLen = strlen( pName->value.asSymbol.name ); if( iLen >= 10 && iLen <= 14 && memcmp( "HB_ENUM", pName->value.asSymbol.name, 7 ) == 0 ) { const char * szMessage = pName->value.asSymbol.name + 7; if( iLen == 12 && memcmp( "INDEX", szMessage, 5 ) == 0 ) szMessage = "__ENUMINDEX"; else if( iLen == 12 && memcmp( "VALUE", szMessage, 5 ) == 0 ) szMessage = "__ENUMVALUE"; else if( iLen == 11 && memcmp( "BASE", szMessage, 4 ) == 0 ) szMessage = "__ENUMBASE"; else if( iLen == 10 && memcmp( "KEY", szMessage, 3 ) == 0 ) szMessage = "__ENUMKEY"; else if( iLen == 14 && memcmp( "ISFIRST", szMessage, 7 ) == 0 ) szMessage = "__ENUMISFIRST"; else if( iLen == 13 && memcmp( "ISLAST", szMessage, 6 ) == 0 ) szMessage = "__ENUMISLAST"; else szMessage = NULL; if( szMessage ) { int iCount = ( int ) hb_compExprParamListLen( pParms ); PHB_ENUMERATOR pForVar, pEnumVar = NULL; pForVar = HB_COMP_PARAM->functions.pLast->pEnum; if( iCount == 0 ) { while( pForVar ) { if( pForVar->iForEachDir != 0 ) pEnumVar = pForVar; pForVar = pForVar->pNext; } } else if( iCount == 1 ) { if( pParms->value.asList.pExprList->ExprType == HB_ET_VARIABLE || pParms->value.asList.pExprList->ExprType == HB_ET_VARREF ) { const char * szName = pParms->value.asList.pExprList->value.asSymbol.name; while( pForVar ) { if( pForVar->iForEachDir != 0 && strcmp( pEnumVar->szName, szName ) == 0 ) { pEnumVar = pForVar; break; } pForVar = pForVar->pNext; } } } if( pEnumVar ) { #if 0 if( pEnumVar->iForEachDir < 0 ) { if( strcmp( "__ENUMISFIRST", szMessage ) == 0 ) szMessage = "__ENUMISLAST"; else if( strcmp( "__ENUMISLAST", szMessage ) == 0 ) szMessage = "__ENUMISFIRST"; } #endif if( pParms ) HB_COMP_EXPR_FREE( pParms ); HB_COMP_EXPR_FREE( pName ); return hb_compExprNewMethodObject( hb_compExprNewSend( szMessage, HB_COMP_PARAM ), hb_compExprNewVar( pEnumVar->szName, HB_COMP_PARAM ) ); } } } } #endif if( pName->value.asSymbol.funcid == HB_F_EVAL && hb_compExprParamListLen( pParms ) != 0 ) { /* Optimize Eval( bBlock, [ArgList] ) to: bBlock:Eval( [ArgList] ) */ PHB_EXPR pEval; pEval = hb_compExprNewMethodCall( hb_compExprNewMethodObject( hb_compExprNewSend( "EVAL", HB_COMP_PARAM ), pParms->value.asList.pExprList ), hb_compExprNewArgList( pParms->value.asList.pExprList->pNext, HB_COMP_PARAM ) ); #if ! defined( HB_MACRO_SUPPORT ) /* force reduction */ pEval->nLength = 1; #endif pParms->value.asList.pExprList = NULL; HB_COMP_EXPR_FREE( pParms ); HB_COMP_EXPR_FREE( pName ); return pEval; } else if( pName->value.asSymbol.funcid == HB_F__GET_ && hb_compExprParamListLen( pParms ) != 0 ) { /* Reserved Clipper function used to handle GET variables */ PHB_EXPR pArg, pNext; /* pArg has to be reduced to eliminate possible problems with * cloned expressions in SETGET block */ if( HB_SUPPORT_HARBOUR ) { pParms = HB_EXPR_USE( pParms, HB_EA_REDUCE ); pArg = pParms->value.asList.pExprList; } else { pArg = pParms->value.asList.pExprList; pNext = pArg->pNext; pArg->pNext = NULL; pArg = hb_compExprListStrip( HB_EXPR_USE( pArg, HB_EA_REDUCE ), HB_COMP_PARAM ); pArg->pNext = pNext; pParms->value.asList.pExprList = pArg; } if( pArg->ExprType == HB_ET_ARRAYAT ) { HB_USHORT uiCount; /* replace: _GET_( a[1], "a[1]", , , ) into: __GetA( {||a }, "a", , , , { 1 } ) */ PHB_EXPR pIndex, pVar; PHB_EXPR pBase; pName->value.asSymbol.name = "__GETA"; /* NOTE: a[ i, j ] is stored as: (pExprList)->(pIndex) * ( ( a->[ i ] )->[ j ] ) */ pVar = HB_EXPR_USE( pArg->value.asList.pExprList, HB_EA_REDUCE ); pBase = pVar->ExprType == HB_ET_ARRAYAT ? pVar : NULL; pIndex = HB_EXPR_USE( pArg->value.asList.pIndex, HB_EA_REDUCE ); pIndex->pNext = NULL; while( pVar->ExprType == HB_ET_ARRAYAT ) { /* traverse back to a leftmost expression and build a list * of index expressions */ pVar->value.asList.pIndex->pNext = pIndex; pIndex = pVar->value.asList.pIndex; pVar = pVar->value.asList.pExprList; } /* create a set only codeblock */ if( pVar->ExprType == HB_ET_MACRO ) { /* &var[ 1 ] */ HB_COMP_EXPR_FREE( pVar ); pVar = hb_compExprNewNil( HB_COMP_PARAM ); } else { pVar = hb_compExprAddCodeblockExpr( hb_compExprNewCodeBlock( NULL, 0, 0, HB_COMP_PARAM ), pVar ); } /* pVar will be the first argument now */ pParms->value.asList.pExprList = pVar; /* link the rest of parameters */ pVar->pNext = pArg->pNext; /* Delete an argument that was the first one */ pArg->value.asList.pIndex = NULL; pArg->value.asList.pExprList = NULL; HB_COMP_EXPR_CLEAR( pArg ); /* Create an array with index elements */ pIndex = hb_compExprNewArray( hb_compExprNewList( pIndex, HB_COMP_PARAM ), HB_COMP_PARAM ); /* The array with index elements have to be the sixth argument * of __GetA() call */ uiCount = 1; while( ++uiCount < 6 ) { if( pVar->pNext == NULL ) pVar->pNext = hb_compExprNewNil( HB_COMP_PARAM ); pVar = pVar->pNext; } if( pVar->pNext ) /* Delete 6-th argument if present */ { pIndex->pNext = pVar->pNext->pNext; HB_COMP_EXPR_FREE( pVar->pNext ); } pVar->pNext = pIndex; /* Set a new 6-th argument */ /* Remove the index expression from a string representation */ pVar = pParms->value.asList.pExprList->pNext; if( pVar->ExprType == HB_ET_STRING ) { HB_SIZE i = 0; char * szVar = pVar->value.asString.string; /* NOTE: Clipper strips a string at the first '[' character too */ while( ++i < pVar->nLength ) { if( szVar[ i ] == '[' ) { if( ! pVar->value.asString.dealloc ) { szVar = pVar->value.asString.string = ( char * ) hb_xmemdup( pVar->value.asString.string, i + 1 ); pVar->value.asString.dealloc = HB_TRUE; } szVar[ i ] = 0; pVar->nLength = i; break; } } } /* clear expressions no longer used */ if( pBase ) { while( pBase->ExprType == HB_ET_ARRAYAT ) { pVar = pBase->value.asList.pExprList; pBase->value.asList.pExprList = NULL; HB_COMP_EXPR_CLEAR( pBase ); pBase = pVar; } } } else if( pArg->ExprType == HB_ET_MACRO ) { /* @ 0,0 GET &var => __Get( NIL, var,... ) * @ 0,0 GET var&var => __Get( NIL, "var&var",... ) */ pName->value.asSymbol.name = "__GET"; if( pArg->value.asMacro.pExprList == NULL ) { /* Simple macro expansion (not a parenthesized expressions) */ PHB_EXPR pFirst; pFirst = pArg; /* first argument */ pNext = pFirst->pNext; /* second argument */ if( pNext ) pNext = pNext->pNext; /* third argument */ pArg = hb_compExprNewNil( HB_COMP_PARAM ); /* replace 1st with NIL */ pParms->value.asList.pExprList = pArg; pArg->pNext = pFirst->pNext; if( pFirst->value.asMacro.cMacroOp == '&' ) { /* simple &variable - replace the second argument with * a variable name */ const char * szName = pFirst->value.asMacro.szMacro; if( pFirst->pNext ) HB_COMP_EXPR_FREE( pFirst->pNext ); /* delete a second argument */ pArg->pNext = hb_compExprNewVar( szName, HB_COMP_PARAM ); pArg->pNext->pNext = pNext; /* restore third argument */ } else { /* text substitution text&variable - replace the second * argument with a string */ if( pArg->pNext == NULL ) { /* no second argument */ const char *szText = pFirst->value.asMacro.szMacro; pArg->pNext = hb_compExprNewString( szText, strlen( szText ), HB_FALSE, HB_COMP_PARAM ); pArg->pNext->pNext = pNext; } } HB_COMP_EXPR_FREE( pFirst ); /* delete first argument */ } else { /* @ 0,0 GET &(var) */ #if defined( HB_MACRO_SUPPORT ) hb_macroError( EG_SYNTAX, HB_COMP_PARAM ); #else hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_GET_COMPLEX_MACRO, NULL, NULL ); #endif } } else { pName->value.asSymbol.name = "__GET"; /* store second and a rest of arguments */ pNext = pArg->pNext; pArg->pNext = NULL; /* replace first argument with a set/get codeblock */ #if ! defined( HB_MACRO_SUPPORT ) if( pArg->ExprType == HB_ET_VARIABLE ) { if( hb_compVariableFind( HB_COMP_PARAM, pArg->value.asSymbol.name, NULL, NULL ) ) pArg = hb_compExprSetGetBlock( pArg, HB_COMP_PARAM ); else { /* Undeclared variable name - create a set/get codeblock * at runtime */ if( HB_COMP_PARAM->iWarnings >= 2 ) hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_AMBIGUOUS_VAR, pArg->value.asSymbol.name, NULL ); HB_COMP_EXPR_FREE( pArg ); pArg = hb_compExprNewNil( HB_COMP_PARAM ); } } else #endif { pArg = hb_compExprSetGetBlock( pArg, HB_COMP_PARAM ); } /* restore next arguments */ pArg->pNext = pNext; /* set an updated list of arguments */ pParms->value.asList.pExprList = pArg; } pName->value.asSymbol.name = hb_compGetFuncID( pName->value.asSymbol.name, &pName->value.asSymbol.funcid, &pName->value.asSymbol.flags ); } } else if( pName->ExprType == HB_ET_MACRO ) { /* Signal that macro compiler have to generate a pcode that will * return function name as symbol instead of usual value */ pName->value.asMacro.SubType = HB_ET_MACRO_SYMBOL; HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNewFunCall(&)" ) ); } pExpr = HB_COMP_EXPR_NEW( HB_ET_FUNCALL ); pExpr->value.asFunCall.pParms = pParms; pExpr->value.asFunCall.pFunName = pName; return pExpr; }
static const char * hb_compChkParseSwitch( HB_COMP_DECL, const char * szSwitch, HB_BOOL fEnv ) { const char * szSwPtr = szSwitch; if( szSwPtr[ 0 ] == '-' && szSwPtr[ 1 ] == '-' ) { if( strncmp( szSwPtr + 2, "version", 7 ) == 0 ) { szSwPtr += 9; HB_COMP_PARAM->fLogo = HB_TRUE; HB_COMP_PARAM->fQuiet = HB_TRUE; } else if( strncmp( szSwPtr + 2, "help", 4 ) == 0 ) { szSwPtr += 6; HB_COMP_PARAM->fLogo = HB_TRUE; HB_COMP_PARAM->fQuiet = HB_FALSE; HB_COMP_PARAM->fExit = HB_FALSE; } } else if( HB_ISOPTSEP( *szSwPtr ) ) { ++szSwPtr; switch( HB_TOUPPER( *szSwPtr ) ) { case 'A': ++szSwPtr; if( *szSwPtr == '-' ) { ++szSwPtr; HB_COMP_PARAM->fAutoMemvarAssume = HB_FALSE; } else HB_COMP_PARAM->fAutoMemvarAssume = HB_TRUE; break; case 'B': { char *szOption = hb_compChkOptionDup( szSwPtr ); if( strcmp( szOption, "BUILD" ) == 0 ) { HB_COMP_PARAM->fBuildInfo = HB_TRUE; szSwPtr += 5; } else if( szSwPtr[ 1 ] == '-' ) { HB_COMP_PARAM->fDebugInfo = HB_FALSE; szSwPtr += 2; } else { HB_COMP_PARAM->fDebugInfo = HB_TRUE; HB_COMP_PARAM->fLineNumbers = HB_TRUE; ++szSwPtr; } hb_xfree( szOption ); break; } case 'C': { char *szOption = hb_compChkOptionDup( szSwPtr ); if( strlen( szOption ) >= 4 && strncmp( "CREDITS", szOption, strlen( szOption ) ) == 0 ) { HB_COMP_PARAM->fCredits = HB_TRUE; szSwPtr += strlen( szOption ); } hb_xfree( szOption ); break; } case 'D': szSwPtr = hb_compChkAddDefine( HB_COMP_PARAM, szSwPtr + 1, HB_TRUE, fEnv ); break; case 'E': if( HB_TOUPPER( szSwPtr[ 1 ] ) == 'S' ) { switch( szSwPtr[ 2 ] ) { case '1': szSwPtr += 3; HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_SETEXIT; break; case '2': szSwPtr += 3; HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DELTARGET; break; case '0': ++szSwPtr; /* no break; */ default: szSwPtr += 2; HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DEFAULT; break; } } break; case 'F': switch( HB_TOUPPER( szSwPtr[ 1 ] ) ) { case 'N': if( szSwPtr[ 2 ] == ':' ) { if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'U' ) { szSwPtr += 4; hb_setSetFileCase( HB_SET_CASE_UPPER ); } else if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'L' ) { szSwPtr += 4; hb_setSetFileCase( HB_SET_CASE_LOWER ); } } else { szSwPtr += 2; if( *szSwPtr == '-' ) ++szSwPtr; hb_setSetFileCase( HB_SET_CASE_MIXED ); } break; case 'D': if( szSwPtr[ 2 ] == ':' ) { if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'U' ) { szSwPtr += 4; hb_setSetDirCase( HB_SET_CASE_UPPER ); } else if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'L' ) { szSwPtr += 4; hb_setSetDirCase( HB_SET_CASE_LOWER ); } } else { szSwPtr += 2; if( *szSwPtr == '-' ) ++szSwPtr; hb_setSetDirCase( HB_SET_CASE_MIXED ); } break; case 'P': szSwPtr += 2; if( *szSwPtr == ':' ) { if( szSwPtr[ 1 ] && szSwPtr[ 1 ] != ' ' ) { hb_setSetDirSeparator( szSwPtr[ 1 ] ); szSwPtr += 2; } } else { if( *szSwPtr == '-' ) ++szSwPtr; hb_setSetDirSeparator( HB_OS_PATH_DELIM_CHR ); } break; case 'S': szSwPtr += 2; if( *szSwPtr == '-' ) { ++szSwPtr; hb_setSetTrimFileName( HB_FALSE ); } else hb_setSetTrimFileName( HB_TRUE ); } break; case 'G': switch( HB_TOUPPER( szSwPtr[ 1 ] ) ) { case 'C': HB_COMP_PARAM->iLanguage = HB_LANG_C; szSwPtr += 2; switch( *szSwPtr ) { case '1': ++szSwPtr; HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_NORMAL; break; case '2': ++szSwPtr; HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_VERBOSE; break; case '3': ++szSwPtr; HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_REALCODE; break; case '0': ++szSwPtr; /* no break; */ default: HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_COMPACT; break; } break; case 'H': HB_COMP_PARAM->iLanguage = HB_LANG_PORT_OBJ; szSwPtr += 2; break; case 'D': if( HB_COMP_PARAM->szDepExt ) { hb_xfree( HB_COMP_PARAM->szDepExt ); HB_COMP_PARAM->szDepExt = NULL; } szSwPtr += 2; if( *szSwPtr == '-' ) { HB_COMP_PARAM->iTraceInclude = 0; ++szSwPtr; } else { HB_COMP_PARAM->iTraceInclude = 2; if( *szSwPtr == '.' ) szSwPtr = hb_compChkOptionGet( szSwPtr, &HB_COMP_PARAM->szDepExt, fEnv ); } break; case 'E': szSwPtr += 2; switch( *szSwPtr ) { case '1': ++szSwPtr; HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_IDE; break; case '0': ++szSwPtr; /* no break; */ default: HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_CLIPPER; break; } break; default: hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_UNSUPPORTED_LANG, NULL, NULL ); break; } break; case 'H': case '?': /* HELP message */ break; case 'I': ++szSwPtr; switch( *szSwPtr ) { case '-': HB_COMP_PARAM->fINCLUDE = HB_FALSE; ++szSwPtr; break; case '+': HB_COMP_PARAM->fINCLUDE = HB_TRUE; ++szSwPtr; break; default: szSwPtr = hb_compChkOptionAddPath( HB_COMP_PARAM, szSwPtr, fEnv ); } break; case 'J': ++szSwPtr; HB_COMP_PARAM->fI18n = HB_TRUE; if( *szSwPtr ) szSwPtr = hb_compChkOptionFName( szSwPtr, &HB_COMP_PARAM->pI18nFileName, fEnv ); break; case 'K': ++szSwPtr; while( *szSwPtr && ! HB_COMP_PARAM->fExit ) { int ch = HB_TOUPPER( *szSwPtr ); ++szSwPtr; switch( ch ) { case '?': hb_compPrintLogo( HB_COMP_PARAM ); hb_compPrintModes( HB_COMP_PARAM ); HB_COMP_PARAM->fLogo = HB_FALSE; HB_COMP_PARAM->fQuiet = HB_TRUE; break; case 'H': /* default Harbour mode */ if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HARBOUR; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_HARBOUR; break; case 'C': /* clear all flags - minimal set of features */ HB_COMP_PARAM->supported &= HB_COMPFLAG_SHORTCUTS; HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP | HB_COMPFLAG_MACROTEXT; break; case 'X': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_XBASE; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_XBASE; break; case 'I': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HB_INLINE; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_HB_INLINE; break; case 'J': if( *szSwPtr == '+' ) { HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP; ++szSwPtr; } else HB_COMP_PARAM->supported &= ~HB_COMPFLAG_OPTJUMP; break; case 'M': if( *szSwPtr == '+' ) { HB_COMP_PARAM->supported |= HB_COMPFLAG_MACROTEXT; ++szSwPtr; } else HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACROTEXT; break; case 'D': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACRODECL; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_MACRODECL; break; case 'R': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_RT_MACRO; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_RT_MACRO; break; case 'S': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_ARRSTR; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_ARRSTR; break; case 'O': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_EXTOPT; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_EXTOPT; break; case 'U': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_USERCP; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_USERCP; break; default: ch = -1; --szSwPtr; } if( ch == -1 ) break; } break; case 'L': ++szSwPtr; if( *szSwPtr == '-' ) { HB_COMP_PARAM->fLineNumbers = HB_TRUE; ++szSwPtr; } else HB_COMP_PARAM->fLineNumbers = HB_FALSE; break; case 'M': ++szSwPtr; if( *szSwPtr == '-' ) { HB_COMP_PARAM->fSingleModule = HB_FALSE; ++szSwPtr; } else HB_COMP_PARAM->fSingleModule = HB_TRUE; break; case 'N': ++szSwPtr; HB_COMP_PARAM->fNoStartUp = *szSwPtr == '1'; switch( *szSwPtr ) { case '-': HB_COMP_PARAM->iStartProc = 0; ++szSwPtr; break; case '2': HB_COMP_PARAM->iStartProc = 2; ++szSwPtr; break; case '0': case '1': ++szSwPtr; /* no break; */ default: HB_COMP_PARAM->iStartProc = 1; break; } break; case 'O': szSwPtr = hb_compChkOptionFName( szSwPtr + 1, &HB_COMP_PARAM->pOutPath, fEnv ); break; case 'P': ++szSwPtr; if( *szSwPtr == '+' ) { HB_COMP_PARAM->fPPT = HB_TRUE; ++szSwPtr; } else { if( HB_COMP_PARAM->pPpoPath ) { hb_xfree( HB_COMP_PARAM->pPpoPath ); HB_COMP_PARAM->pPpoPath = NULL; } if( *szSwPtr == '-' ) { HB_COMP_PARAM->fPPT = HB_COMP_PARAM->fPPO = HB_FALSE; ++szSwPtr; } else { if( *szSwPtr ) szSwPtr = hb_compChkOptionFName( szSwPtr, &HB_COMP_PARAM->pPpoPath, fEnv ); HB_COMP_PARAM->fPPO = HB_TRUE; } } break; case 'Q': ++szSwPtr; switch( *szSwPtr ) { case 'l': case 'L': HB_COMP_PARAM->fGauge = HB_FALSE; ++szSwPtr; break; case '2': HB_COMP_PARAM->fFullQuiet = HB_TRUE; /* no break */ case '0': HB_COMP_PARAM->fLogo = HB_FALSE; ++szSwPtr; /* no break */ default: HB_COMP_PARAM->fQuiet = HB_TRUE; } break; case 'R': ++szSwPtr; if( szSwPtr[ 0 ] == ':' ) { if( HB_ISDIGIT( szSwPtr[ 1 ] ) ) { int iCycles = 0; ++szSwPtr; while( HB_ISDIGIT( *szSwPtr ) ) iCycles = iCycles * 10 + *szSwPtr++ - '0'; if( iCycles > 0 ) HB_COMP_PARAM->iMaxTransCycles = iCycles; } } else { /* NOTE: ignored for Cl*pper compatibility: /r[<lib>] request linker to search <lib> (or none) */ hb_compChkIgnoredInfo( HB_COMP_PARAM, "-r[<lib>]" ); szSwPtr = hb_compChkOptionGet( szSwPtr, NULL, fEnv ); } break; case 'S': ++szSwPtr; switch( *szSwPtr ) { case '-': HB_COMP_PARAM->iSyntaxCheckOnly = 0; ++szSwPtr; break; case 'm': case 'M': HB_COMP_PARAM->iSyntaxCheckOnly = 2; ++szSwPtr; break; default: HB_COMP_PARAM->iSyntaxCheckOnly = 1; break; } break; case 'T': /* NOTE: ignored for Cl*pper compatibility: /t<path> path for temp file creation */ hb_compChkIgnoredInfo( HB_COMP_PARAM, "-t<path>" ); szSwPtr = hb_compChkOptionGet( szSwPtr + 1, NULL, fEnv ); break; case 'U': if( hb_strnicmp( szSwPtr, "UNDEF:", 6 ) == 0 ) { if( hb_strnicmp( szSwPtr + 6, ".ARCH.", 6 ) == 0 ) { HB_COMP_PARAM->fNoArchDefs = HB_TRUE; szSwPtr += 12; } else szSwPtr = hb_compChkAddDefine( HB_COMP_PARAM, szSwPtr + 6, HB_FALSE, fEnv ); break; } ++szSwPtr; /* extended definitions file: -u+<file> */ if( *szSwPtr == '+' ) { if( szSwPtr[ 1 ] && hb_compChkOptionLen( szSwPtr + 1, fEnv ) > 0 ) { HB_COMP_PARAM->szStdChExt = ( char ** ) ( HB_COMP_PARAM->iStdChExt == 0 ? hb_xgrab( sizeof( char * ) ) : hb_xrealloc( HB_COMP_PARAM->szStdChExt, ( HB_COMP_PARAM->iStdChExt + 1 ) * sizeof( char * ) ) ); szSwPtr = hb_compChkOptionGet( szSwPtr + 1, &HB_COMP_PARAM->szStdChExt[ HB_COMP_PARAM->iStdChExt++ ], fEnv ); } } else { if( HB_COMP_PARAM->szStdCh ) hb_xfree( HB_COMP_PARAM->szStdCh ); szSwPtr = hb_compChkOptionGet( szSwPtr, &HB_COMP_PARAM->szStdCh, fEnv ); } break; case 'V': ++szSwPtr; if( *szSwPtr == '-' ) { HB_COMP_PARAM->fForceMemvars = HB_FALSE; ++szSwPtr; } else HB_COMP_PARAM->fForceMemvars = HB_TRUE; break; case 'W': ++szSwPtr; HB_COMP_PARAM->iWarnings = 1; if( *szSwPtr >= '0' && *szSwPtr <= '3' ) { HB_COMP_PARAM->iWarnings = *szSwPtr - '0'; ++szSwPtr; } break; #ifdef YYDEBUG case 'Y': ++szSwPtr; extern int hb_comp_yydebug; hb_comp_yydebug = HB_TRUE; break; #endif case 'Z': ++szSwPtr; if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported |= HB_COMPFLAG_SHORTCUTS; ++szSwPtr; } else HB_COMP_PARAM->supported &= ~HB_COMPFLAG_SHORTCUTS; break; } } if( ! HB_COMP_PARAM->fExit ) { if( szSwPtr - szSwitch <= 1 || ( *szSwPtr != '\0' && *szSwPtr != ' ' && ! HB_ISOPTSEP( *szSwPtr ) ) ) hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', fEnv ? HB_COMP_ERR_BADOPTION : HB_COMP_ERR_BADPARAM, szSwitch, NULL ); else return szSwPtr; } return ""; }
void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, const char * const Args[] ) { /* If iArg is passed check the command line options */ if( iArg ) { int i; /* Check all switches in command line They start with an OS_OPT_DELIMITER char */ for( i = 1; i < iArg && ! HB_COMP_PARAM->fExit; i++ ) { const char * szSwitch = Args[ i ]; if( ! HB_ISOPTSEP( szSwitch[ 0 ] ) ) continue; if( szSwitch[ 0 ] == '-' ) { int j = 1; char Switch[ 7 ]; Switch[ 0 ] = '-'; while( szSwitch[ j ] && ! HB_COMP_PARAM->fExit ) { Switch[ 1 ] = szSwitch[ j ]; if( szSwitch[ j + 1 ] == '-' ) { Switch[ 2 ] = '-'; Switch[ 3 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 2; continue; } else { switch( Switch[ 1 ] ) { case 'b': case 'B': if( ( szSwitch[ j + 1 ] == 'U' || szSwitch[ j + 1 ] == 'u' ) && ( szSwitch[ j + 2 ] == 'I' || szSwitch[ j + 2 ] == 'i' ) && ( szSwitch[ j + 3 ] == 'L' || szSwitch[ j + 3 ] == 'l' ) && ( szSwitch[ j + 4 ] == 'D' || szSwitch[ j + 4 ] == 'd' ) ) { Switch[ 2 ] = 'U'; Switch[ 3 ] = 'I'; Switch[ 4 ] = 'L'; Switch[ 5 ] = 'D'; Switch[ 6 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 5; continue; } else if( ! szSwitch[ j + 1 ] ) { Switch[ 2 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 1; continue; } break; case 'c': case 'C': if( ( szSwitch[ j + 1 ] == 'R' || szSwitch[ j + 1 ] == 'r' ) && ( szSwitch[ j + 2 ] == 'E' || szSwitch[ j + 2 ] == 'e' ) && ( szSwitch[ j + 3 ] == 'D' || szSwitch[ j + 3 ] == 'd' ) ) { Switch[ 2 ] = 'R'; Switch[ 3 ] = 'E'; Switch[ 4 ] = 'D'; Switch[ 5 ] = '\0'; j += 4; if( szSwitch[ j ] == 'I' || szSwitch[ j ] == 'i' ) { j++; if( szSwitch[ j ] == 'T' || szSwitch[ j ] == 't' ) { j++; if( szSwitch[ j ] == 'S' || szSwitch[ j ] == 's' ) { j++; } } } hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); } else { Switch[ 2 ] = '\0'; hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL ); } continue; case 'd': case 'D': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as part of #define and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case 'e': case 'E': if( ( szSwitch[ j + 1 ] == 'S' || szSwitch[ j + 1 ] == 's' ) && HB_ISDIGIT( szSwitch[ j + 2 ] ) ) { Switch[ 2 ] = 'S'; Switch[ 3 ] = szSwitch[ j + 2 ]; Switch[ 4 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 3; } else { Switch[ 2 ] = '\0'; hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL ); } continue; case 'g': case 'G': if( szSwitch[ j + 1 ] == 'd' || szSwitch[ j + 1 ] == 'D' ) { szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); j = ( int ) strlen( szSwitch ); } else { /* Required argument */ Switch[ 2 ] = szSwitch[ j + 1 ]; if( Switch[ 2 ] ) { if( HB_ISDIGIT( szSwitch[ j + 2 ] ) ) { /* Optional argument */ Switch[ 3 ] = szSwitch[ j + 2 ]; Switch[ 4 ] = '\0'; j += 3; } else { /* No optional argument */ Switch[ 3 ] = '\0'; j += 2; } hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); } else hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL ); } continue; case 'i': case 'I': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as IncludePath and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case 'j': case 'J': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); j = ( int ) strlen( szSwitch ); continue; case 'k': case 'K': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as part of #define and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case 'n': case 'N': /* Required argument */ if( szSwitch[ j + 1 ] ) { /* Optional argument */ Switch[ 2 ] = szSwitch[ j + 1 ]; Switch[ 3 ] = '\0'; j += 2; } else { /* No optional argument */ Switch[ 2 ] = '\0'; j += 1; } hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); continue; case 'o': case 'O': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as OutputPath and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case 'p': case 'P': if( szSwitch[ j + 1 ] ) { szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as PPOPath and continue with next Args[]. */ j += ( int ) strlen( szSwitch ) - 1; } else { Switch[ 2 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j++; } continue; case 'q': case 'Q': if( HB_ISDIGIT( szSwitch[ j + 1 ] ) ) { Switch[ 2 ] = szSwitch[ j + 1 ]; Switch[ 3 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 2; continue; } else { Switch[ 2 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); } break; case 'r': case 'R': hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); j = ( int ) strlen( szSwitch ) - 1; break; case 's': case 'S': ++j; Switch[ 2 ] = Switch[ 3 ] = Switch[ 4 ] = '\0'; if( szSwitch[ j ] == 'm' || szSwitch[ j ] == 'M' ) { Switch[ 2 ] = szSwitch[ j++ ]; if( HB_ISDIGIT( szSwitch[ j ] ) || szSwitch[ j ] == '-' ) Switch[ 3 ] = szSwitch[ j++ ]; } hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); continue; case 'u': case 'U': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as part of .ch Path or "undef:<id>" and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case 'w': case 'W': if( HB_ISDIGIT( szSwitch[ j + 1 ] ) ) { Switch[ 2 ] = szSwitch[ j + 1 ]; Switch[ 3 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 2; continue; } else { Switch[ 2 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); } break; case 'x': case 'X': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as INIT Symbol and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case '-': { int l = ++j; while( szSwitch[ j ] && ! HB_ISOPTSEP( szSwitch[ j ] ) ) j++; if( szSwitch[ l - 1 ] == '-' && j - l == 7 && memcmp( &szSwitch[ l ], "version", 7 ) == 0 ) { HB_COMP_PARAM->fLogo = HB_TRUE; HB_COMP_PARAM->fQuiet = HB_TRUE; } else if( szSwitch[ l - 1 ] == '-' && j - l == 4 && memcmp( &szSwitch[ l ], "help", 4 ) == 0 ) { HB_COMP_PARAM->fLogo = HB_TRUE; HB_COMP_PARAM->fQuiet = HB_FALSE; HB_COMP_PARAM->fExit = HB_FALSE; } else hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, &szSwitch[ l ], NULL ); if( szSwitch[ j ] ) ++j; continue; } default: Switch[ 2 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); } } j++; } continue; } while( ! HB_COMP_PARAM->fExit ) { int j = 1; const char * szSwitch1 = szSwitch + j; /* hack to avoid what is seems a bug in 'Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)' / XCode 4.1 [vszakats] */ while( *szSwitch1 && ! HB_ISOPTSEP( *szSwitch1 ) ) { j++; szSwitch1++; } if( szSwitch[ j ] == '/' ) { char * szTmp = hb_strndup( szSwitch, j ); hb_compChkEnvironVar( HB_COMP_PARAM, szTmp ); hb_xfree( szTmp ); szSwitch += j; } else { hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); break; } } } } else /* Check the environment variables */ { /* NOTE: CLIPPERCMD enviroment variable is overriden if HARBOURCMD exists */ char * szStrEnv = hb_getenv( "HARBOURCMD" ); if( ! szStrEnv || szStrEnv[ 0 ] == '\0' ) { if( szStrEnv ) hb_xfree( szStrEnv ); szStrEnv = hb_getenv( "CLIPPERCMD" ); } if( szStrEnv ) { char * szSwitch, * szPtr; szPtr = szStrEnv; while( *szPtr && ! HB_COMP_PARAM->fExit ) { while( *szPtr == ' ' ) ++szPtr; szSwitch = szPtr; if( *szSwitch ) { while( *++szPtr ) { if( *szPtr == ' ' ) { *szPtr++ = '\0'; break; } } hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); } } hb_xfree( szStrEnv ); } } }
HB_BOOL hb_compI18nSave( HB_COMP_DECL, HB_BOOL fFinal ) { PHB_I18NTABLE pI18n; PHB_I18NSTRING pString; HB_FNAME FileName; char szFileName[ HB_PATH_MAX ]; char* szText; HB_UINT uiIndex, uiLine; FILE* file; pI18n = HB_COMP_PARAM->pI18n; if( ! pI18n ) return HB_FALSE; FileName.szPath = FileName.szName = FileName.szExtension = FileName.szDrive = NULL; if( HB_COMP_PARAM->pOutPath ) { FileName.szDrive = HB_COMP_PARAM->pOutPath->szDrive; FileName.szPath = HB_COMP_PARAM->pOutPath->szPath; } if( HB_COMP_PARAM->pI18nFileName ) { if( HB_COMP_PARAM->pI18nFileName->szName ) FileName.szName = HB_COMP_PARAM->pI18nFileName->szName; if( HB_COMP_PARAM->pI18nFileName->szExtension ) FileName.szExtension = HB_COMP_PARAM->pI18nFileName->szExtension; if( HB_COMP_PARAM->pI18nFileName->szPath ) { FileName.szDrive = HB_COMP_PARAM->pI18nFileName->szDrive; FileName.szPath = HB_COMP_PARAM->pI18nFileName->szPath; } } if( ! FileName.szName ) FileName.szName = HB_COMP_PARAM->pFileName->szName; else if( ! fFinal ) /* The exact file name was given generate single .pot file for * all compiled .prg files in final phase. */ return HB_FALSE; if( ! FileName.szExtension ) FileName.szExtension = ".pot"; hb_fsFNameMerge( szFileName, &FileName ); file = hb_fopen( szFileName, "w" ); if( ! file ) { hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_CREATE_OUTPUT, szFileName, NULL ); return HB_FALSE; } szText = hb_verHarbour(); fprintf( file, "#\n# This file is generated by %s\n#\n\n", szText ); hb_xfree( szText ); for( uiIndex = 0; uiIndex < pI18n->uiCount; uiIndex++ ) { pString = &pI18n->pString[ uiIndex ]; fprintf( file, "#: %s:%d", hb_compI18nFileName( szFileName, pString->pPos.szFile ), pString->pPos.uiLine ); for( uiLine = 0; uiLine < pString->uiPosCount; ++uiLine ) fprintf( file, " %s:%d", hb_compI18nFileName( szFileName, pString->pPosLst[ uiLine ].szFile ), pString->pPosLst[ uiLine ].uiLine ); fprintf( file, "\n#, c-format\n" ); if( pString->szContext ) { fprintf( file, "msgctxt \"" ); hb_compI18nEscapeString( file, pString->szContext ); fprintf( file, "\"\n" ); } fprintf( file, "msgid \"" ); hb_compI18nEscapeString( file, pString->szText ); for( uiLine = 0; uiLine < pString->uiPlurals; ++uiLine ) { if( uiLine == 0 ) fprintf( file, "\"\nmsgid_plural \"" ); else fprintf( file, "\"\nmsgid_plural%d \"", uiLine + 1 ); hb_compI18nEscapeString( file, pString->szPlurals[ uiLine ] ); } fprintf( file, "\"\nmsgstr%s \"\"\n\n", pString->uiPlurals ? "[0]" : "" ); } fclose( file ); return HB_TRUE; }
static void hb_compErrorDuplVar( HB_COMP_DECL, const char * szVarName ) { hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_VAR_DUPL, szVarName, NULL ); }