diff --git a/harbour/ChangeLog b/harbour/ChangeLog index dbc9940f2c..3661a4cb52 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,24 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-18 16:34 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * include/hbcompdf.h + * src/compiler/cmdcheck.c + * src/compiler/hbmain.c + * src/compiler/hbcomp.c + * src/compiler/hbopt.c + * src/compiler/hbusage.c + * src/compiler/hbgenerr.c + + Added options to control error/warning output format/style + in Harbour, to make it possible to switch to formats which + are handled by popular IDEs, like Eclipse, Code::Blocks. + Currently these are supported: + -ge[0]: Clipper compatible (default) + -ge1: "IDE friendly". Mimics the one submitted by Lorenzo + for Eclipse. + The goal is to cover the most IDEs with the less options, + so please test them to reach this optimum. + 2010-01-18 15:53 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/common/hbwince.c - removed LocalLock()/LocalUnlock()/LocalHandle() function wrappers @@ -6529,8 +6547,8 @@ Peer-review me pls. 2009-12-13 22:47 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) - * src/compiler/hbmain.c * src/compiler/cmdcheck.c + * src/compiler/hbmain.c * src/compiler/hbcomp.c * src/compiler/hbusage.c * include/hbcompdf.h diff --git a/harbour/include/hbcompdf.h b/harbour/include/hbcompdf.h index d4eeb4dbc1..9a76c309ae 100644 --- a/harbour/include/hbcompdf.h +++ b/harbour/include/hbcompdf.h @@ -71,6 +71,13 @@ typedef enum HB_LANG_PORT_OBJ_BUF /* Portable objects in memory buffer */ } HB_LANGUAGES; /* supported Harbour output languages */ +/* Error message format modes */ +typedef enum +{ + HB_ERRORFMT_CLIPPER, + HB_ERRORFMT_IDE +} HB_ERRORFMT; + struct _COMCLASS; /* forward declaration */ /* Declared Function/Method support structure */ @@ -699,6 +706,7 @@ typedef struct _HB_COMP int ilastLineErr; /* line numer with last syntax error */ int iTraceInclude; /* trace included files and generate dependencies list */ int iSyntaxCheckOnly; /* syntax check only */ + int iErrorFmt; /* error message formatting mode (default: Clipper) */ HB_BOOL fQuiet; /* be quiet during compilation (-q) */ HB_BOOL fFullQuiet; /* be quiet during compilation disable all messages */ diff --git a/harbour/src/compiler/cmdcheck.c b/harbour/src/compiler/cmdcheck.c index 82875119b2..16ad96fee3 100644 --- a/harbour/src/compiler/cmdcheck.c +++ b/harbour/src/compiler/cmdcheck.c @@ -272,6 +272,24 @@ static void hb_compChkEnvironVar( HB_COMP_DECL, const char *szSwitch ) 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; + #ifdef HB_GEN_OBJ32 case 'w': case 'W': diff --git a/harbour/src/compiler/hbcomp.c b/harbour/src/compiler/hbcomp.c index c4d95485d3..384c8071ad 100644 --- a/harbour/src/compiler/hbcomp.c +++ b/harbour/src/compiler/hbcomp.c @@ -238,9 +238,10 @@ HB_COMP_PTR hb_comp_new( void ) pComp->iWarnings = 0; /* enable parse warnings */ pComp->iErrorCount = 0; /* number of compile errors */ - pComp->iGenCOutput= HB_COMPGENC_COMPACT; /* C code generation default mode */ - pComp->iExitLevel = HB_EXITLEVEL_DEFAULT; /* holds if there was any warning during the compilation process */ - pComp->iLanguage = HB_LANG_C; /* default Harbour generated output language */ + pComp->iGenCOutput = HB_COMPGENC_COMPACT; /* C code generation default mode */ + pComp->iExitLevel = HB_EXITLEVEL_DEFAULT; /* holds if there was any warning during the compilation process */ + pComp->iLanguage = HB_LANG_C; /* default Harbour generated output language */ + pComp->iErrorFmt = HB_ERRORFMT_CLIPPER; /* default Harbour generated output language */ } return pComp; diff --git a/harbour/src/compiler/hbgenerr.c b/harbour/src/compiler/hbgenerr.c index 7f102e94e7..f30b4a21bc 100644 --- a/harbour/src/compiler/hbgenerr.c +++ b/harbour/src/compiler/hbgenerr.c @@ -156,13 +156,26 @@ static void hb_compDispMessage( HB_COMP_DECL, char cPrefix, int iValue, if( HB_COMP_PARAM->currModule ) { - hb_snprintf( buffer, sizeof( buffer ), "\r%s(%i) ", + if( HB_COMP_PARAM->iErrorFmt == HB_ERRORFMT_CLIPPER ) + hb_snprintf( buffer, sizeof( buffer ), "\r%s(%i) ", + HB_COMP_PARAM->currModule, HB_COMP_PARAM->currLine ); + else if( HB_COMP_PARAM->currLine ) + hb_snprintf( buffer, sizeof( buffer ), "\n%s:%i: ", HB_COMP_PARAM->currModule, HB_COMP_PARAM->currLine ); + else + hb_snprintf( buffer, sizeof( buffer ), "\n%s:%s ", + HB_COMP_PARAM->currModule, szPar2 ); + hb_compOutErr( HB_COMP_PARAM, buffer ); } - hb_snprintf( buffer, sizeof( buffer ), "%s %c%04i ", - cPrefix == 'W' ? "Warning" : "Error", cPrefix, iValue ); + if( HB_COMP_PARAM->iErrorFmt == HB_ERRORFMT_CLIPPER ) + hb_snprintf( buffer, sizeof( buffer ), "%s %c%04i ", + cPrefix == 'W' ? "Warning" : "Error", cPrefix, iValue ); + else + hb_snprintf( buffer, sizeof( buffer ), "%s %c%04i ", + cPrefix == 'W' ? "warning" : "error", cPrefix, iValue ); + hb_compOutErr( HB_COMP_PARAM, buffer ); hb_snprintf( buffer, sizeof( buffer ), szText, szPar1, szPar2 ); hb_compOutErr( HB_COMP_PARAM, buffer ); diff --git a/harbour/src/compiler/hbmain.c b/harbour/src/compiler/hbmain.c index 99bfe96d91..aaa1215a25 100644 --- a/harbour/src/compiler/hbmain.c +++ b/harbour/src/compiler/hbmain.c @@ -1706,7 +1706,10 @@ static void hb_compWarnUnusedVar( HB_COMP_DECL, const char * szFuncName, const char * szVarName, int iDeclLine ) { char szFun[ HB_SYMBOL_NAME_LEN + 17 ]; - hb_snprintf( szFun, sizeof( szFun ), "%s(%i)", szFuncName, iDeclLine ); + if( HB_COMP_PARAM->iErrorFmt == HB_ERRORFMT_CLIPPER ) + hb_snprintf( szFun, sizeof( szFun ), "%s(%i)", szFuncName, iDeclLine ); + else + hb_snprintf( szFun, sizeof( szFun ), "%i:%s", iDeclLine, szFuncName ); hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_VAR_NOT_USED, szVarName, szFun ); } diff --git a/harbour/src/compiler/hbopt.c b/harbour/src/compiler/hbopt.c index 0f35b3e560..9b31066273 100644 --- a/harbour/src/compiler/hbopt.c +++ b/harbour/src/compiler/hbopt.c @@ -1424,7 +1424,10 @@ static void hb_compPCodeEnumAssignedUnused( HB_COMP_DECL, PFUNCTION pFunc, PHB_O To obtain real line number we need one more tree scan or other algorithm. [Mindaugas] */ - hb_snprintf( szFun, sizeof( szFun ), "%s(%i)", pFunc->szName, usLine ); + if( HB_COMP_PARAM->iErrorFmt == HB_ERRORFMT_CLIPPER ) + hb_snprintf( szFun, sizeof( szFun ), "%s(%i)", pFunc->szName, usLine ); + else + hb_snprintf( szFun, sizeof( szFun ), "%i:%s", usLine, pFunc->szName ); hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGNED_UNUSED, pVar->szName, szFun ); } } @@ -1600,9 +1603,12 @@ void hb_compPCodeTraceOptimizer( HB_COMP_DECL ) if( usIndex >= pFunc->wParamCount && pLocals[ usIndex ].bFlags == OPT_LOCAL_FLAG_PUSH ) { - char szFun[ 256 ]; + char szFun[ 256 ]; - hb_snprintf( szFun, sizeof( szFun ), "%s(%i)", pFunc->szName, pVar->iDeclLine ); + if( HB_COMP_PARAM->iErrorFmt == HB_ERRORFMT_CLIPPER ) + hb_snprintf( szFun, sizeof( szFun ), "%s(%i)", pFunc->szName, pVar->iDeclLine ); + else + hb_snprintf( szFun, sizeof( szFun ), "%i:%s", pVar->iDeclLine, pFunc->szName ); hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_NEVER_ASSIGNED, pVar->szName, szFun ); } diff --git a/harbour/src/compiler/hbusage.c b/harbour/src/compiler/hbusage.c index 5bb96e1013..81b377e814 100644 --- a/harbour/src/compiler/hbusage.c +++ b/harbour/src/compiler/hbusage.c @@ -78,6 +78,8 @@ void hb_compPrintUsage( HB_COMP_DECL, const char * szSelf ) #endif "\n %cgh output type: Harbour Portable Object (.hrb)", "\n %cgd[.] generate dependencies list into (.d) file", + "\n %cge[] error output : 0=Clipper (default)", + "\n 1=IDE friendly", "\n %ci #include file search path", "\n %ci[-|+] disable/enable support for INCLUDE envvar", "\n %cj[] generate i18n gettext file (.pot)",