Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-Id: <200204222039.g3MKdvR03179@moolenaar.net> To: Chris Metcalf cc: Corinna Vinschen , cygwin AT cygwin DOT com, vim-dev AT vim DOT org Subject: Re: small inter-operability patch for vim 6.1.2 for Cygwin In-Reply-To: From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Mon, 22 Apr 2002 22:39:57 +0200 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 > #endif > > +#ifdef __CYGWIN__ > +# include > +#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 AT moolenaar DOT 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/