Mail Archives: cygwin/2002/04/22/15:09:05
Earlier, I wrote:
> This small change fixes an interoperability problem with vim in Cygwin.
> If the Cygwin vim is invoked by non-Cygwin aware tools, it may be passed
> a backslash-separated path. Since vim is essentially Unix-built for
> Cygwin, it doesn't realize it should recognize the backslashes as path
> separators, and fails to create a valid .swp file path (error "E303").
>
> For example, the Cygwin cvs.exe is substantially slower at updates than
> a non-Cygwin build, presumably because of stat() overheads. Both
> versions of cvs.exe will use $EDITOR to get checkin comments from the
> user, but the non-Cygwin version will pass a C:\TEMP\... path to vim.
> (While it is possible to set up a $CVSEDITOR .bat file that runs
> "cygpath -u" on its argument, this seems more like a bandaid than a
> proper fix.)
>
> The attached patch just modifies the vim_ispathsep() function to be
> Cygwin-aware. [...]
Bram Moolenaar replied:
> I'm quite sure this is not a good solution. It's just waiting to fail
> in another place. The Unix code just isn't prepared for backslashes in
> a file name to be path separators, they are seen as escaping the special
> meaning of characters.
>
> Why not add something at the start of main() to change backslashes to
> forward slashes?
Sure. How does the attached look? I'm not sure whether overloading
slash_adjust() is the right thing here (or if it would be better to enable
the call to slash_adjust() in alist_add() instead). I'm also not sure
whether any backslash-escaping is expected to be performed on command-line
arguments as well, or if in this context it's safe to assume all filename
arguments are plain vanilla file names.
> Or better: Isn't there a cygwin trick for this already?
Well, "cygpath -u PATH" will convert a Windows path to a Unix path.
However, this means you can't just set $EDITOR to a simple executable,
but have to walk it through a script (or dedicated binary) first.
Also, it just seems wrong that vim doesn't handle a Windows path
plausibly, when almost all of the other Cygwin tools do.
> Your message won't get to the vim-dev list then. And you can't read
> responses from others...
Sorry, I was careless. Fixed, and context added to this reply.
Chris
diff -u vim-6.1-2/src/main.c vim-6.1-2-build/src/main.c
--- 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 14:50:36 2002
@@ -972,6 +972,14 @@
}
}
#endif
+#ifdef __CYGWIN__
+ /*
+ * If vim is invoked by non-Cygwin tools, eliminate backslashes
+ * early on. Otherwise the OS will continue to see the
+ * backslashes as path separators, but vim will not.
+ */
+ slash_adjust(p);
+#endif
alist_add(&global_alist, p,
#if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE)
literal ? 2 : 0 /* add buffer number after expanding */
diff -u vim-6.1-2/src/os_unix.c vim-6.1-2-build/src/os_unix.c
--- vim-6.1-2/src/os_unix.c Thu Mar 14 16:05:16 2002
+++ vim-6.1-2-build/src/os_unix.c Mon Apr 22 14:49:12 2002
@@ -1911,7 +1911,7 @@
#endif
}
-#if defined(OS2) || defined(PROTO)
+#if defined(OS2) || defined(__CYGWIN__) || defined(PROTO)
/*
* Replace all slashes by backslashes.
* When 'shellslash' set do it the other way around.
@@ -1922,8 +1922,13 @@
{
while (*p)
{
+#ifdef __CYGWIN__
+ if (*p == '\\')
+ *p = '/';
+#else
if (*p == psepcN)
*p = psepc;
+#endif
#ifdef FEAT_MBYTE
if (has_mbyte)
p += (*mb_ptr2len_check)(p);
--
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/
- Raw text -