00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "compileerrorfilter.h"
00013 #include "compileerrorfilter.moc"
00014 #include "makeitem.h"
00015
00016 #include <kdebug.h>
00017
00018 CompileErrorFilter::ErrorFormat::ErrorFormat( const char * regExp, int file, int line, int text )
00019 : expression( regExp )
00020 , fileGroup( file )
00021 , lineGroup( line )
00022 , textGroup( text )
00023 {
00024 }
00025
00026 CompileErrorFilter::ErrorFormat::ErrorFormat( const char * regExp, int file, int line, int text, QString comp )
00027 : expression( regExp )
00028 , fileGroup( file )
00029 , lineGroup( line )
00030 , textGroup( text )
00031 , compiler( comp )
00032 {
00033 }
00034
00035
00036 CompileErrorFilter::CompileErrorFilter( OutputFilter& next )
00037 : OutputFilter( next )
00038 {
00039 }
00040
00041 CompileErrorFilter::ErrorFormat* CompileErrorFilter::errorFormats()
00042 {
00044 static ErrorFormat formats[] = {
00045
00046 ErrorFormat( "([^: \t]+):([0-9]+):(?:[0-9]+):([^0-9]+)", 1, 2, 3 ),
00047
00048 ErrorFormat( "([^: \t]+):([0-9]+):([^0-9]+)", 1, 2, 3 ),
00049
00050 ErrorFormat( "([^: \\t]+)\\(([0-9]+)\\):([^0-9]+)", 1, 2, 3, "intel" ),
00051
00052 ErrorFormat( "(libtool):( link):( warning): ", 0, 0, 0 ),
00053
00054 ErrorFormat( "\"(.*)\", line ([0-9]+):(.*)", 1, 2, 3 ),
00055
00056 ErrorFormat( "[a-zA-Z]+:([^: \t]+):([0-9]+):[0-9]+:[a-zA-Z]:(.*)", 1, 2, 3 ),
00057
00058 ErrorFormat( 0, 0, 0, 0 )
00059 };
00060
00061 return formats;
00062 }
00063
00064 void CompileErrorFilter::processLine( const QString& line )
00065 {
00066 bool hasmatch = false;
00067 QString file;
00068 int lineNum = 0;
00069 QString text;
00070 QString compiler;
00071 int i = 0;
00072 bool isWarning = false;
00073 ErrorFormat* errFormats = errorFormats();
00074 ErrorFormat* format = &errFormats[i];
00075 while( !format->expression.isEmpty() )
00076 {
00077 QRegExp regExp = format->expression;
00078
00079 if ( regExp.search( line ) != -1 ) {
00080 hasmatch = true;
00081 file = regExp.cap( format->fileGroup );
00082 lineNum = regExp.cap( format->lineGroup ).toInt() - 1;
00083 text = regExp.cap( format->textGroup );
00084 compiler = format->compiler;
00085 if (regExp.cap(3).contains("warning", false))
00086 isWarning = true;
00087 break;
00088 }
00089
00090 format = &errFormats[++i];
00091 }
00092
00093 if( hasmatch )
00094 {
00095
00096 if( text.find( QString::fromLatin1("(Each undeclared identifier is reported only once") ) >= 0
00097 || text.find( QString::fromLatin1("for each function it appears in.)") ) >= 0 )
00098 hasmatch = false;
00099 }
00100
00101 if ( hasmatch )
00102 {
00103 emit item( new ErrorItem( file, lineNum, text, line, isWarning, compiler ) );
00104 }
00105 else
00106 {
00107 OutputFilter::processLine( line );
00108 }
00109 }