From c43400792b637c744ca840a4ecb339ffdb27c604 Mon Sep 17 00:00:00 2001
From: Ritt Konstantin <ritt.ks@gmail.com>
Date: Fri, 29 Jan 2010 13:12:39 +0100
Subject: QDir::cleanPath: strip trailing slash for "/:/" on non-win platforms
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Merge-request: 445
Reviewed-by: João Abecasis <joao@trolltech.com>
---
 src/corelib/io/qdir.cpp      | 9 ++++++---
 tests/auto/qdir/tst_qdir.cpp | 7 +++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 6b79cae..f465e73 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -2193,9 +2193,12 @@ QString QDir::cleanPath(const QString &path)
 	ret = QString(out, used);
 
     // Strip away last slash except for root directories
-    if (ret.endsWith(QLatin1Char('/'))
-        && !(ret.size() == 1 || (ret.size() == 3 && ret.at(1) == QLatin1Char(':'))))
-        ret = ret.left(ret.length() - 1);
+    if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) {
+#ifdef Q_OS_WIN
+        if (!(ret.length() == 3 && ret.at(1) == QLatin1Char(':')))
+#endif
+            ret.chop(1);
+    }
 
     return ret;
 }
diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp
index c7f9b6b..1d909c9 100644
--- a/tests/auto/qdir/tst_qdir.cpp
+++ b/tests/auto/qdir/tst_qdir.cpp
@@ -982,6 +982,13 @@ tst_QDir::cleanPath_data()
     QTest::newRow("data7") << ".//file1.txt" << "file1.txt";
     QTest::newRow("data8") << "/foo/bar/..//file1.txt" << "/foo/file1.txt";
     QTest::newRow("data9") << "//" << "/";
+#if !defined(Q_OS_WINCE)
+#if defined Q_OS_WIN
+    QTest::newRow("data10") << "c:\\" << "c:/";
+#else
+    QTest::newRow("data10") << "/:/" << "/:";
+#endif
+#endif
 }
 
 
-- 
cgit v0.12