Bug 116393 - Support backslashes in paths to source files in REFERENCE comments
Summary: Support backslashes in paths to source files in REFERENCE comments
Status: RESOLVED FIXED
Alias: None
Product: kbabel
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR wishlist
Target Milestone: ---
Assignee: Stanislav Visnovsky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-15 02:30 UTC by Daniel Hahler
Modified: 2005-12-26 11:15 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Hahler 2005-11-15 02:30:55 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    Ubuntu Packages

To be compatible across platforms I'd like KBabel to support backslashes also for "#: REFERENCE" comments.

In https://bugs.kde.org/show_bug.cgi?id=114041#c6 Nicolas Goutte says that QFileInfo is being used.

I hope this can quite easily be done.
Comment 1 Nicolas Goutte 2005-12-26 11:15:45 UTC
SVN commit 491448 by goutte:

- replace backslashes in source references' paths into slahes
  (support for MS Windows' paths in PO files; bug #116393)
- fix a typo of the name extractattr in a comment
- use cont_iterator in the loop processing each comment line.
BUG:116393


 M  +8 -4      context.cpp  


--- branches/KDE/3.5/kdesdk/kbabel/commonui/context.cpp #491447:491448
@@ -143,10 +143,9 @@
     //kdDebug() << "PO FILE DIR: " << poDir  << endl;
     
     QStringList prefixes;
-    QStringList paths = _project->settings()->paths();
+    const QStringList paths = _project->settings()->paths();
     
-    for( QStringList::Iterator it = paths.begin() 
-	; it!=paths.end() ; ++it)
+    for( QStringList::const_iterator it = paths.constBegin(); it!=paths.constEnd() ; ++it )
     {
 	QString pref = (*it);
 
@@ -165,7 +164,7 @@
 
     QValueList<ContextInfo> rawRefList; // raw references
     QRegExp re("^\\s*(.+):(\\d+)\\s*$"); // Reg. exp. for Gettext references
-    QRegExp rex( "^#. i18n: file (.+) line (\\d+)\\s*$" ); //Reg. exp. for KDE extractrc/etxractattr references
+    QRegExp rex( "^#. i18n: file (.+) line (\\d+)\\s*$" ); //Reg. exp. for KDE extractrc/extractattr references
     QRegExp res( "^# [Ff]ile: (.+), line(?: number)?: (\\d+)\\s*$"); // Reg. exp. for "strict" PO format
     const QStringList lines = QStringList::split( "\n", gettextComment );
     for ( QStringList::const_iterator it = lines.constBegin() ; it != lines.constEnd() ; ++it)
@@ -182,6 +181,8 @@
                     ContextInfo ref;
                     ref.line = re.cap(2).toInt();
                     ref.path = re.cap(1);
+                    // ### TODO KDE4: perhaps we should not do the replace if compiled for Windows
+                    ref.path.replace( QChar( '\\' ), QChar( '/' ) );
                     rawRefList.append( ref );
                 }
             }
@@ -200,6 +201,7 @@
                 ContextInfo ref;
                 ref.line = rex.cap(2).toInt();
                 ref.path = rex.cap(1);
+                // KDE is not extracted on Windows, so no backslash conversion is needed.
                 rawRefList.append( ref );
             }
         }
@@ -211,6 +213,8 @@
                 ContextInfo ref;
                 ref.line = res.cap(2).toInt();
                 ref.path = res.cap(1);
+                // ### TODO KDE4: perhaps we should not do the replace if compiled for Windows
+                ref.path.replace( QChar( '\\' ), QChar( '/' ) );
                 rawRefList.append( ref );
             }
         }