[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE_3_4_BRANCH: kdevelop/parts/ctags2
From:       Jens Dagerbo <jens.dagerbo () swipnet ! se>
Date:       2005-04-26 19:07:51
Message-ID: 20050426190751.8F806664 () office ! kde ! org
[Download RAW message or body]

CVS commit by dagerbo: 

Backport. Fixes bug #99964 and bug #104510


  M +24 -4     ctags2_part.cpp   1.12.4.1


--- kdevelop/parts/ctags2/ctags2_part.cpp  #1.12:1.12.4.1
@@ -241,8 +241,28 @@ void CTags2Part::slotGotoDeclaration( )
 int CTags2Part::getFileLineFromStream( QTextStream & istream, QString const & pattern )
 {
+        if ( pattern.isEmpty() ) return -1;
 
-        QString reduced = pattern.mid( 2, pattern.length() -4 );
-        QString escaped = QRegExp::escape( reduced );
-        QString re_string( "^" + escaped + "$" );
+        // ctags interestingly escapes "/", but apparently nothing else. lets revert that
+        QString unescaped = pattern;
+        unescaped.replace( "\\/", "/" );
+        
+        // most of the time, the ctags pattern has the form /^foo$/
+        // but this isn't true for some macro definitions
+        // where the form is only /^foo/
+        // I have no idea if this is a ctags bug or not, but we have to deal with it
+
+        QString reduced, escaped, re_string;
+        if ( unescaped.endsWith( "$/" ) )
+        {
+                reduced = unescaped.mid( 2, unescaped.length() -4 );
+                escaped = QRegExp::escape( reduced );
+                re_string = QString( "^" + escaped + "$" );
+        }
+        else
+        {
+                reduced = unescaped.mid( 2, unescaped.length() -3 );
+                escaped = QRegExp::escape( reduced );
+                re_string = QString( "^" + escaped );
+        }
         
         QRegExp re( re_string );
@@ -251,5 +271,5 @@ int CTags2Part::getFileLineFromStream( Q
         while ( !istream.atEnd() )
         {
-                if ( re.exactMatch( istream.readLine() ) )
+                if ( re.search( istream.readLine() ) > -1 )
                 {
                         return n;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic