cygwin_conv_path sometimes removes trailing slash

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Feb 8 18:13:00 GMT 2016


Hi Ray,

On Jan 31 22:17, Ray Donnelly wrote:
> On Sun, Jan 31, 2016 at 11:38 AM, Jan Nijtmans <jan.nijtmans@gmail.com> wrote:
> > 2016-01-30 4:21 GMT+01:00 Ken Brown:
> >> I'm using cygwin_conv_path to convert Win32 paths to POSIX paths, and I'm
> >> puzzled by the conversion
> >>
> >>   d:/ --> /cygdrive/d
> >>
> >> without the trailing slash.  By contrast, we have
> >>
> >>   d:/foo/ --> /cygdrive/d/foo/
> >
> > This came up before:
> >    <https://cygwin.com/ml/cygwin/2015-10/msg00048.html>
> > I had to workaround it in tkimg.
> >
> > It's easy to workaround in your program, but - indeed -
> > that shouldn't be necessary. I too would expect that
> > when the input contains a slash, the output should too.
> >
> 
> I've attached the patch that we use on MSYS2 for this. We found
> ourselves patching projects all over the open-source landscape
> otherwise

How many projects require exposure to the conversion from POSIX to Win32
paths?  This is something which should be used in applications only very
rarely.  Usually they just feed the POSIX path into functions like open,
etc., and that's it.

> so fixing it once and for all seems sensible. Note however,
> a full fix also requires another patch that I posted two years ago [1]
> that Corinna chose not to apply. In the two years since, we've yet to
> find any issue with that patch. I will rebase it shortly in-case
> there's any interest in reconsidering it.
> 
> [1] https://cygwin.com/ml/cygwin-patches/2014-q1/msg00010.html

Your patches don't work for Ken's case since path_conv::check is never
called for CCP_WIN_A_TO_POSIX/CCP_WIN_W_TO_POSIX conversion.  I have a
patch in the loop to fix that.

I'm not quite sure what your first patch is supposed to accomplish in
the POSIX->WIN case.  tail == path_copy + 1 means the incoming path is
"/".  Your patch will result in changing the conversion of 

  /  -->  C:\cygwin

to

  /  -->  C:\cygwin\

Is that really desired?  What especially bugs me is that this occurs in
the very core of the path conversion which isn't only used in places
exposed to user space.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160208/e28e4f38/attachment.sig>


More information about the Cygwin mailing list