* small inter-operability patch for vim 6.1.2 for Cygwin
@ 2002-04-22 11:30 Chris Metcalf
2002-04-22 12:08 ` Bram Moolenaar
0 siblings, 1 reply; 15+ messages in thread
From: Chris Metcalf @ 2002-04-22 11:30 UTC (permalink / raw)
To: Bram; +Cc: cygwin, vim-dev
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. IMHO, the full BACKSLASH_IN_FILENAME mechanism is
inappropriate for Cygwin vim, since it really wants to present a complete
Unix facade to the user. However, when backslashes are supplied in
filenames, the underlying OS *will* treat them as directory separators, so
vim must be aware of special characters as separators.
(I am not subscribed to vim-dev but have cc'ed it based on the comments in
vim's README.txt.)
Thanks,
Chris Metcalf -- InCert Software -- 1 (617) 621 8080
metcalf@incert.com -- http://www.incert.com/~metcalf
--- vim-6.1-2/src/misc1.c Sun Mar 17 08:12:29 2002
+++ vim-6.1-2-build/src/misc1.c Mon Apr 22 13:35:36 2002
@@ -3709,7 +3709,11 @@
return (c == '.' || c == ':');
#else
# ifdef UNIX
+# ifdef __CYGWIN__ /* The OS will truly separate on ':' and '\\' */
+ return (c == ':' || c == '/' || c == '\\');
+# else
return (c == '/'); /* UNIX has ':' inside file names */
+# endif
# else
# ifdef BACKSLASH_IN_FILENAME
return (c == ':' || c == '/' || c == '\\');
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for Cygwin
2002-04-22 11:30 small inter-operability patch for vim 6.1.2 for Cygwin Chris Metcalf
@ 2002-04-22 12:08 ` Bram Moolenaar
2002-04-22 12:14 ` Chris Metcalf
2002-04-22 12:18 ` Corinna Vinschen
0 siblings, 2 replies; 15+ messages in thread
From: Bram Moolenaar @ 2002-04-22 12:08 UTC (permalink / raw)
To: Chris Metcalf; +Cc: cygwin, vim-dev
Chris Metcalf 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. IMHO, the full BACKSLASH_IN_FILENAME mechanism is
> inappropriate for Cygwin vim, since it really wants to present a complete
> Unix facade to the user. However, when backslashes are supplied in
> filenames, the underlying OS *will* treat them as directory separators, so
> vim must be aware of special characters as separators.
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? Or better: Isn't there a cygwin trick for this
already?
> (I am not subscribed to vim-dev but have cc'ed it based on the comments in
> vim's README.txt.)
Your message won't get to the vim-dev list then. And you can't read
responses from others...
--
His head smashed in, and his heart cut out,
And his liver removed, and his bowels unplugged,
And his nostrils raped, and his bottom burned off,
And his penis split ... and his ...
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\
/// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\
\\\ Project leader for A-A-P -- http://www.a-a-p.org ///
\\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for Cygwin
2002-04-22 12:08 ` Bram Moolenaar
@ 2002-04-22 12:14 ` Chris Metcalf
2002-04-22 12:26 ` Corinna Vinschen
2002-04-22 12:18 ` Corinna Vinschen
1 sibling, 1 reply; 15+ messages in thread
From: Chris Metcalf @ 2002-04-22 12:14 UTC (permalink / raw)
To: Bram Moolenaar; +Cc: cygwin, vim-dev
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for Cygwin
2002-04-22 12:14 ` Chris Metcalf
@ 2002-04-22 12:26 ` Corinna Vinschen
0 siblings, 0 replies; 15+ messages in thread
From: Corinna Vinschen @ 2002-04-22 12:26 UTC (permalink / raw)
To: cygwin; +Cc: vim-dev
On Mon, Apr 22, 2002 at 03:08:07PM -0400, Chris Metcalf wrote:
> > 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.
However, I don't see the problem in using `cygpath'. It's designed
for that purpose. I'm not quite sure if it makes sense to tweak
vim if there are already tools which do what you want.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin@cygwin.com
Red Hat, Inc.
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for Cygwin
2002-04-22 12:08 ` Bram Moolenaar
2002-04-22 12:14 ` Chris Metcalf
@ 2002-04-22 12:18 ` Corinna Vinschen
2002-04-22 12:31 ` Bram Moolenaar
1 sibling, 1 reply; 15+ messages in thread
From: Corinna Vinschen @ 2002-04-22 12:18 UTC (permalink / raw)
To: cygwin; +Cc: vim-dev
On Mon, Apr 22, 2002 at 08:35:50PM +0200, Bram Moolenaar wrote:
> 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? Or better: Isn't there a cygwin trick for this
> already?
Sure:
#include <sys/cygwin.h>
cygwin_conv_to_posix_path(const char *win_path, char *posix_path);
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin@cygwin.com
Red Hat, Inc.
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for Cygwin
2002-04-22 12:18 ` Corinna Vinschen
@ 2002-04-22 12:31 ` Bram Moolenaar
2002-04-22 12:39 ` small inter-operability patch for vim 6.1.2 for cygwin Christopher Faylor
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Bram Moolenaar @ 2002-04-22 12:31 UTC (permalink / raw)
To: Corinna Vinschen; +Cc: cygwin, vim-dev
Corinna Vinschen wrote:
> On Mon, Apr 22, 2002 at 08:35:50PM +0200, Bram Moolenaar wrote:
> > 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? Or better: Isn't there a cygwin trick for this
> > already?
>
> Sure:
>
> #include <sys/cygwin.h>
>
> 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).
Actually, it would help a lot if someone with Cygwin installed can look
into this and test a few things.
--
FIRST HEAD: Oh! quick! get the sword out I want to cut his head off.
THIRD HEAD: Oh, cut your own head off.
SECOND HEAD: Yes - do us all a favour.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\
/// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\
\\\ Project leader for A-A-P -- http://www.a-a-p.org ///
\\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for cygwin
2002-04-22 12:31 ` Bram Moolenaar
@ 2002-04-22 12:39 ` Christopher Faylor
2002-04-22 14:35 ` Michael A Chase
2002-04-22 12:41 ` small inter-operability patch for vim 6.1.2 for Cygwin Corinna Vinschen
2002-04-22 12:44 ` Chris Metcalf
2 siblings, 1 reply; 15+ messages in thread
From: Christopher Faylor @ 2002-04-22 12:39 UTC (permalink / raw)
To: Bram Moolenaar; +Cc: cygwin
On Mon, Apr 22, 2002 at 09:18:40PM +0200, Bram Moolenaar wrote:
>That sounds like something we can use. But lacking the manual page it's
>a bit difficult to know exactly how to call it.
Can anyone post the man page for this for Bram? I'm away from my
windows machine right now, and can't do it.
cgf
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for cygwin
2002-04-22 12:39 ` small inter-operability patch for vim 6.1.2 for cygwin Christopher Faylor
@ 2002-04-22 14:35 ` Michael A Chase
2002-04-22 14:53 ` Christopher Faylor
0 siblings, 1 reply; 15+ messages in thread
From: Michael A Chase @ 2002-04-22 14:35 UTC (permalink / raw)
To: Bram Moolenaar, cygwin
On Mon, 22 Apr 2002 15:26:36 -0400 Christopher Faylor <cgf-cygwin@cygwin.com> wrote:
> On Mon, Apr 22, 2002 at 09:18:40PM +0200, Bram Moolenaar wrote:
> >That sounds like something we can use. But lacking the manual page it's
> >a bit difficult to know exactly how to call it.
>
> Can anyone post the man page for this for Bram? I'm away from my
> windows machine right now, and can't do it.
The man page is part of the (new) cygwin-doc package.
--
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.htm
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for cygwin
2002-04-22 14:35 ` Michael A Chase
@ 2002-04-22 14:53 ` Christopher Faylor
2002-04-22 15:27 ` Michael A Chase
0 siblings, 1 reply; 15+ messages in thread
From: Christopher Faylor @ 2002-04-22 14:53 UTC (permalink / raw)
To: cygwin
On Mon, Apr 22, 2002 at 02:24:09PM -0700, Michael A Chase wrote:
>On Mon, 22 Apr 2002 15:26:36 -0400 Christopher Faylor <cgf-cygwin@cygwin.com> wrote:
>>On Mon, Apr 22, 2002 at 09:18:40PM +0200, Bram Moolenaar wrote:
>>>That sounds like something we can use. But lacking the manual page
>>>it's a bit difficult to know exactly how to call it.
>>
>>Can anyone post the man page for this for Bram? I'm away from my
>>windows machine right now, and can't do it.
>
>The man page is part of the (new) cygwin-doc package.
Right. And, that is where, I assume, the posted man pages were coming
from.
cgf
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for cygwin
2002-04-22 14:53 ` Christopher Faylor
@ 2002-04-22 15:27 ` Michael A Chase
2002-04-22 15:30 ` Christopher Faylor
0 siblings, 1 reply; 15+ messages in thread
From: Michael A Chase @ 2002-04-22 15:27 UTC (permalink / raw)
To: cygwin
On Mon, 22 Apr 2002 17:28:32 -0400 Christopher Faylor <cgf@redhat.com> wrote:
> On Mon, Apr 22, 2002 at 02:24:09PM -0700, Michael A Chase wrote:
> >On Mon, 22 Apr 2002 15:26:36 -0400 Christopher Faylor
> <cgf-cygwin@cygwin.com> wrote:
> >>On Mon, Apr 22, 2002 at 09:18:40PM +0200, Bram Moolenaar wrote:
> >>>That sounds like something we can use. But lacking the manual page
> >>>it's a bit difficult to know exactly how to call it.
>
> >The man page is part of the (new) cygwin-doc package.
>
> Right. And, that is where, I assume, the posted man pages were coming
> from.
It looked like the original poster wasn't aware that the man page was
available now. It only happened last week.
--
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.htm
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for cygwin
2002-04-22 15:27 ` Michael A Chase
@ 2002-04-22 15:30 ` Christopher Faylor
0 siblings, 0 replies; 15+ messages in thread
From: Christopher Faylor @ 2002-04-22 15:30 UTC (permalink / raw)
To: cygwin
On Mon, Apr 22, 2002 at 02:52:52PM -0700, Michael A Chase wrote:
>On Mon, 22 Apr 2002 17:28:32 -0400 Christopher Faylor <cgf@redhat.com> wrote:
>
>> On Mon, Apr 22, 2002 at 02:24:09PM -0700, Michael A Chase wrote:
>> >On Mon, 22 Apr 2002 15:26:36 -0400 Christopher Faylor
>> <cgf-cygwin@cygwin.com> wrote:
>> >>On Mon, Apr 22, 2002 at 09:18:40PM +0200, Bram Moolenaar wrote:
>> >>>That sounds like something we can use. But lacking the manual page
>> >>>it's a bit difficult to know exactly how to call it.
>>
>> >The man page is part of the (new) cygwin-doc package.
>>
>> Right. And, that is where, I assume, the posted man pages were coming
>> from.
>
>It looked like the original poster wasn't aware that the man page was
>available now. It only happened last week.
The poster in question was the VIM developer. I assumed he might not even
have Cygwin installed.
cgf
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for Cygwin
2002-04-22 12:31 ` Bram Moolenaar
2002-04-22 12:39 ` small inter-operability patch for vim 6.1.2 for cygwin Christopher Faylor
@ 2002-04-22 12:41 ` Corinna Vinschen
2002-04-22 12:44 ` Chris Metcalf
2 siblings, 0 replies; 15+ messages in thread
From: Corinna Vinschen @ 2002-04-22 12:41 UTC (permalink / raw)
To: Bram Moolenaar; +Cc: cygwin, vim-dev
On Mon, Apr 22, 2002 at 09:18:40PM +0200, Bram Moolenaar wrote:
> Corinna Vinschen wrote:
> > #include <sys/cygwin.h>
> >
> > 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).
============= SNIP ============
CYGWIN_CONV_TO_POSIX_PATH(3) CYGWIN_CONV_TO_POSIX_PATH(3)
SYNOPSIS
extern "C" void
cygwin_conv_to_posix_path (const char * path, char *
posix_path);
DESCRIPTION
Converts a Win32 path to a POSIX path. If path is already
a POSIX path, leaves it alone. If path is relative, then
posix_path will also be relative. Note that posix_path
must point to a buffer of sufficient size; use MAX_PATH if
needed.
COPYRIGHT
Cygwin is Copyright (C) 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002 Red Hat, Inc.
Cygwin is Free software; for complete licensing informa-
tion, refer to:
http://cygwin.com/licensing.html
MAINTAINER
This man page was written and is maintained by Joshua
Daniel Franklin, joshuadfranklin@yahoo.com
SEE ALSO
The full documentation to the Cygwin API is maintained on
the web at:
http://cygwin.com/cygwin-api/cygwin-api.html
The website is updated more frequently than the man pages
and should be considered the authoritative source of
information.
2002 Apr 12 CYGWIN_CONV_TO_POSIX_PATH(3)
============= SNAP ============
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin@cygwin.com
Red Hat, Inc.
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for Cygwin
2002-04-22 12:31 ` Bram Moolenaar
2002-04-22 12:39 ` small inter-operability patch for vim 6.1.2 for cygwin Christopher Faylor
2002-04-22 12:41 ` small inter-operability patch for vim 6.1.2 for Cygwin Corinna Vinschen
@ 2002-04-22 12:44 ` Chris Metcalf
2002-04-22 13:48 ` Bram Moolenaar
2 siblings, 1 reply; 15+ messages in thread
From: Chris Metcalf @ 2002-04-22 12:44 UTC (permalink / raw)
To: Bram Moolenaar; +Cc: Corinna Vinschen, cygwin, vim-dev
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: small inter-operability patch for vim 6.1.2 for Cygwin
2002-04-22 12:44 ` Chris Metcalf
@ 2002-04-22 13:48 ` Bram Moolenaar
0 siblings, 0 replies; 15+ messages in thread
From: Bram Moolenaar @ 2002-04-22 13:48 UTC (permalink / raw)
To: Chris Metcalf; +Cc: Corinna Vinschen, cygwin, vim-dev
Chris Metcalf wrote:
> 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.
Thanks for making this patch. It looks OK to me, but it should be
tested by a few people before I include this.
I'll include the patch again in case some people didn't get it.
> --- 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)
--
FIRST HEAD: All right! All right! We'll kill him first and then have tea and
biscuits.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\
/// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\
\\\ Project leader for A-A-P -- http://www.a-a-p.org ///
\\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: small inter-operability patch for vim 6.1.2 for cygwin
@ 2002-04-22 12:41 Richard Campbell
0 siblings, 0 replies; 15+ messages in thread
From: Richard Campbell @ 2002-04-22 12:41 UTC (permalink / raw)
To: 'cygwin@cygwin.com'
>Can anyone post the man page for this for Bram? I'm away from my
>windows machine right now, and can't do it.
C:\>man cygwin_conv_to_posix_path
CYGWIN_CONV_TO_POSIX_PATH(3) CYGWIN_CONV_TO_POSIX_PATH(3)
SYNOPSIS
extern "C" void
cygwin_conv_to_posix_path (const char * path, char *
posix_path);
DESCRIPTION
Converts a Win32 path to a POSIX path. If path is already
a POSIX path, leaves it alone. If path is relative, then
posix_path will also be relative. Note that posix_path
must point to a buffer of sufficient size; use MAX_PATH if
needed.
COPYRIGHT
Cygwin is Copyright (C) 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002 Red Hat, Inc.
Cygwin is Free software; for complete licensing informa-
tion, refer to:
http://cygwin.com/licensing.html
MAINTAINER
This man page was written and is maintained by Joshua
Daniel Franklin, joshuadfranklin@yahoo.com
SEE ALSO
The full documentation to the Cygwin API is maintained on
the web at:
http://cygwin.com/cygwin-api/cygwin-api.html
The website is updated more frequently than the man pages
and should be considered the authoritative source of
information.
2002 Apr 12 CYGWIN_CONV_TO_POSIX_PATH(3)
--
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/
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2002-04-22 21:59 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-22 11:30 small inter-operability patch for vim 6.1.2 for Cygwin Chris Metcalf
2002-04-22 12:08 ` Bram Moolenaar
2002-04-22 12:14 ` Chris Metcalf
2002-04-22 12:26 ` Corinna Vinschen
2002-04-22 12:18 ` Corinna Vinschen
2002-04-22 12:31 ` Bram Moolenaar
2002-04-22 12:39 ` small inter-operability patch for vim 6.1.2 for cygwin Christopher Faylor
2002-04-22 14:35 ` Michael A Chase
2002-04-22 14:53 ` Christopher Faylor
2002-04-22 15:27 ` Michael A Chase
2002-04-22 15:30 ` Christopher Faylor
2002-04-22 12:41 ` small inter-operability patch for vim 6.1.2 for Cygwin Corinna Vinschen
2002-04-22 12:44 ` Chris Metcalf
2002-04-22 13:48 ` Bram Moolenaar
2002-04-22 12:41 small inter-operability patch for vim 6.1.2 for cygwin Richard Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).