[arch-commits] Commit in kate/trunk (PKGBUILD kdebug-363297.patch)

Antonio Rojas arojas at archlinux.org
Sun May 29 16:24:27 UTC 2016


    Date: Sunday, May 29, 2016 @ 18:24:26
  Author: arojas
Revision: 268734

Fix opening urls with file:// protocol (FS#49391)

Added:
  kate/trunk/kdebug-363297.patch
Modified:
  kate/trunk/PKGBUILD

---------------------+
 PKGBUILD            |   11 +++--
 kdebug-363297.patch |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 111 insertions(+), 3 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2016-05-29 14:27:16 UTC (rev 268733)
+++ PKGBUILD	2016-05-29 16:24:26 UTC (rev 268734)
@@ -7,16 +7,21 @@
 pkgname=('kwrite'
          'kate')
 pkgver=16.04.1
-pkgrel=1
+pkgrel=2
 arch=('i686' 'x86_64')
 license=('GPL' 'LGPL' 'FDL')
 makedepends=('extra-cmake-modules' 'kdoctools' 'python' 'plasma-framework' 'knewstuff' 'ktexteditor'
              'threadweaver' 'kitemmodels' 'kactivities')
-source=("http://download.kde.org/stable/applications/${pkgver}/src/${pkgbase}-${pkgver}.tar.xz")
-sha1sums=('ba9a31b7293f9b31f55090287804a8d0e9196a36')
+source=("http://download.kde.org/stable/applications/${pkgver}/src/${pkgbase}-${pkgver}.tar.xz" kdebug-363297.patch)
+sha1sums=('ba9a31b7293f9b31f55090287804a8d0e9196a36'
+          '1efebf617f8407a5b2d58338ea8860fbe86cdf90')
 
 prepare() {
   mkdir -p build
+
+# Fix opening file:// url's http://bugs.kde.org/show_bug.cgi?id=363297
+  cd $pkgbase-$pkgver
+  patch -p1 -i ../kdebug-363297.patch
 }
 
 build() {

Added: kdebug-363297.patch
===================================================================
--- kdebug-363297.patch	                        (rev 0)
+++ kdebug-363297.patch	2016-05-29 16:24:26 UTC (rev 268734)
@@ -0,0 +1,103 @@
+--- a/urlinfo.h.orig	2016-04-30 21:08:20.000000000 +0000
++++ b/urlinfo.h	2016-05-29 16:12:59.684139033 +0000
+@@ -25,38 +25,79 @@
+ #include <QRegularExpression>
+ #include <QString>
+ 
+-// Represents a file to be opened, consisting of its URL and the cursor to jump to.
+-struct UrlInfo
++/**
++ * Represents a file to be opened, consisting of its URL and the cursor to jump to.
++ */
++class UrlInfo
+ {
+-    // Parses a file path argument and determines its line number and column and full path
++public:
++    /**
++     * Parses a file path argument and determines its line number and column and full path
++     * @param path path passed on e.g. command line to parse into an URL
++     */
+     UrlInfo(QString path)
+         : cursor(KTextEditor::Cursor::invalid())
+     {
+-        // convert to an url
+-        const QRegularExpression withProtocol(QStringLiteral("^[a-zA-Z]+://")); // TODO: remove after Qt supports this on its own
+-        if (withProtocol.match(path).hasMatch()) {
+-            url = QUrl::fromUserInput(path);
+-        } else {
++        /**
++         * construct url:
++         *   - make relative paths absolute using the current working directory
++         *   - prefer local file, if in doubt!
++         */
++        url = QUrl::fromUserInput(path, QDir::currentPath(), QUrl::AssumeLocalFile);
++
++        /**
++         * in some cases, this will fail, e.g. if you have line/column specs like test.c:10:1
++         * => fallback: assume a local file and just convert it to an url
++         */
++        if (!url.isValid()) {
++            /**
++             * create absolute file path, we will e.g. pass this over dbus to other processes
++             */
+             url = QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
+         }
+ 
+-        if (url.isLocalFile() && !QFile::exists(path)) {
+-            // Allow opening specific lines in documents, like mydoc.cpp:10
+-            // also supports columns, i.e. mydoc.cpp:10:42
+-            static const QRegularExpression pattern(QStringLiteral(":(\\d+)(?::(\\d+))?$"));
+-            const auto match = pattern.match(path);
+-            if (match.isValid()) {
+-                path.chop(match.capturedLength());
+-                int line = match.captured(1).toInt() - 1;
+-                // don't use an invalid column when the line is valid
+-                int column = qMax(0, match.captured(2).toInt() - 1);
+-                url = QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
+-                cursor = {line, column};
+-            }
++        /**
++         * Allow opening specific lines in documents, like mydoc.cpp:10
++         * also supports columns, i.e. mydoc.cpp:10:42
++         * ignores trailing colons, as compile errors often use that format
++         */
++        if (url.isLocalFile() && !QFile::exists(url.toLocalFile())) {
++            /**
++             * update path from url, might have been file://...
++             */
++            path = url.toLocalFile();
++
++            /**
++             * try to match the line/colum spec, else we are done here
++             */
++            const auto match = QRegularExpression(QStringLiteral(":(\\d+)(?::(\\d+))?:?$")).match(path);
++            if (!match.isValid())
++                return;
++
++            /**
++             * cut away the line/column specification from the path and update the url
++             */
++            path.chop(match.capturedLength());
++            url = QUrl::fromLocalFile(path);
++
++            /**
++             * set right cursor position
++             */
++            int line = match.captured(1).toInt() - 1;
++            // don't use an invalid column when the line is valid
++            int column = qMax(0, match.captured(2).toInt() - 1);
++            cursor = {line, column};
+         }
+     }
+ 
++    /**
++     * url computed out of the passed path
++     */
+     QUrl url;
++
++    /**
++     * initial cursor position, if any found inside the path as line/colum specification at the end
++     */
+     KTextEditor::Cursor cursor;
+ };
+ 



More information about the arch-commits mailing list