small inter-operability patch for vim 6.1.2 for Cygwin

Chris Metcalf metcalf@incert.com
Mon Apr 22 12:44:00 GMT 2002


On Mon, 22 Apr 2002, Bram Moolenaar wrote:
> >    cygwin_conv_to_posix_path(const char *win_path, char *posix_path);
> 
> That sounds like something we can use.  But lacking the manual page it's
> a bit difficult to know exactly how to call it.  Also, can this function
> be used when the path is already a "posix" path?  Or do we need a test
> whether this function needs to be called (a backslash being present).

(POSIX paths are passed through unchanged; I've attached the man page.)

Corinna is right; this is cleaner than doing slash-modification by hand.
It also gives you the nice property that if you have used "mount" to map
DOS paths to Unix paths, you get the proper Unix path from the mountpoint,
not just a slash-converted path.

Corinna expressed some concern about hacking up vim rather than using
existing tools to convert paths when needed.  I think the reason that
modifying vim feels correct to me is that vim is something that is likely
to be called, standalone, from a variety of different contexts -- Cygwin
and non-Cygwin tools that have "edit" escapes of some kind -- and it
should Just Work in all of them.

Additionally, it seems right to me that vim should be able to handle any
kind of path that is valid at the OS level.  Most of the other Cygwin
tools do handle both Unix and DOS paths, though by and large simply
because they treat the paths as opaque character strings; vim is just a
more sophisticated filename consumer and therefore needs more care to
support the full range of path types.

> Actually, it would help a lot if someone with Cygwin installed can look
> into this and test a few things.

I'd be happy to be the guinea pig, certainly.  I've attached yet
another possible patch.

Chris

--- vim-6.1-2/src/main.c	Sun Mar 24 06:05:17 2002
+++ vim-6.1-2-build/src/main.c	Mon Apr 22 15:32:30 2002
@@ -22,6 +22,10 @@
 # include <fcntl.h>
 #endif
 
+#ifdef __CYGWIN__
+# include <sys/cygwin.h>
+#endif
+
 #if defined(UNIX) || defined(VMS)
 static int file_owned __ARGS((char *fname));
 #endif
@@ -971,6 +975,21 @@
 		    p = r;
 		}
 	    }
 #endif
+#ifdef __CYGWIN__
+            /*
+             * If vim is invoked by non-Cygwin tools, convert away any
+             * DOS paths, so things like .swp files are created correctly.
+             * Look for evidence of non-Cygwin paths before we bother.
+             */
+            if (strpbrk(p, "\\:") != NULL) {
+                char posix_path[PATH_MAX];
+                cygwin_conv_to_posix_path(p, posix_path);
+                vim_free(p);
+                p = vim_strsave(posix_path);
+                if (p == NULL)
+                    mch_exit(2);
+            }
+#endif
 	    alist_add(&global_alist, p,
 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE)



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list