Subject: Re: lyx has problem with network directory names
From: Enrico Forestieri <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Sat, 7 Oct 2006 23:15:47 +0200

On Sat, Oct 07, 2006 at 02:36:46PM +0000, Eric Blake wrote:

> > > It appears that lyx is trying to access the root directory (/). It
> > > does not seem to know how to interpret the Windows syntax "//."
> > 
> > This is because lyx uses the boostfs library with BOOST_POSIX defined,
> > so any path of the form //xxx/yyy is normalized to /xxx/yyy.
> > I understand that //machine/path is a windowism, but I think that it
> > should be allowed on cygwin. Can this be seen a boost bug?
> 
> Yes, it is most definitely a boost bug and should be reported
> upstream.  POSIX allows implementations to treat leading //
> specially, so boost is violating POSIX by normalizing it.

Sorry for the noise, but boostfs seems innocent. I investigated
the problem and it turned out that qt3 is to be blamed here.
Indeed, UNC paths are accounted for only when Q_OS_WIN32 is defined.

The attached patch for qt 3.3.5 allows UNC paths on cygwin, too.

-- 
Enrico
diff -uNr qt3.orig/src/dialogs/qfiledialog.cpp qt3/src/dialogs/qfiledialog.cpp
--- qt3.orig/src/dialogs/qfiledialog.cpp	2005-09-30 17:58:32.000000000 +0200
+++ qt3/src/dialogs/qfiledialog.cpp	2006-10-07 22:54:36.000000000 +0200
@@ -5732,6 +5732,17 @@
      QString p = QDir::convertSeparators(u.path());
      if(p.contains(':') == 1)
 	return TRUE;
+#elif defined(Q_OS_CYGWIN)
+     QString p = u.path();
+     if ( p == "/" )
+	 return TRUE;
+     if ( p[0] == '/' && p[1] == '/' ) {
+	 int slashes = p.contains( '/' );
+	 if ( slashes <= 2 )
+	     return TRUE;
+	 if ( slashes == 3 && p[ (int)p.length() - 1 ] == '/' )
+	     return TRUE;
+     }
 #elif defined(Q_OS_UNIX)
     if ( u.path() == "/" )
 	return TRUE;
diff -uNr qt3.orig/src/kernel/qurl.cpp qt3/src/kernel/qurl.cpp
--- qt3.orig/src/kernel/qurl.cpp	2006-02-16 04:23:44.000000000 +0100
+++ qt3/src/kernel/qurl.cpp	2006-10-07 22:56:36.000000000 +0200
@@ -833,7 +833,7 @@
     if ( !d->host.isEmpty() && d->host[ 0 ] == '@' )
 	d->host.remove( (uint)0, 1 );
 
-#if defined(Q_OS_WIN32)
+#if defined(Q_OS_WIN32) || defined (Q_OS_CYGWIN)
     // hack for windows file://machine/path syntax
     if ( d->protocol == "file" ) {
 	if ( url.left( 7 ) == "file://" &&
@@ -1027,7 +1027,7 @@
 	if ( QDir::isRelativePath( d->path ) ) {
 	    d->cleanPath = d->path;
 	} else if ( isLocalFile() ) {
-#if defined(Q_OS_WIN32)
+#if defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN)
 	    // hack for stuff like \\machine\path and //machine/path on windows
 	    if ( ( d->path.left( 1 ) == "/" || d->path.left( 1 ) == "\\" ) &&
 		 d->path.length() > 1 ) {
diff -uNr qt3.orig/src/tools/qdir.cpp qt3/src/tools/qdir.cpp
--- qt3.orig/src/tools/qdir.cpp	2006-02-15 19:26:24.000000000 +0100
+++ qt3/src/tools/qdir.cpp	2006-10-07 23:00:02.000000000 +0200
@@ -1293,6 +1293,9 @@
 	} else {
 	    newPath = name.left(2) + newPath;
 	}
+#elif defined(Q_OS_CYGWIN)
+	if ( name[0] == '/' && name[1] == '/' ) // "//machine/x/ ..."
+	    newPath.insert( 0, '/' );
 #endif
     }
     return newPath;

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/