public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* cygwin_conv_path sometimes removes trailing slash
@ 2016-01-30 20:46 Ken Brown
  2016-01-31 22:25 ` Jan Nijtmans
  2016-02-14 19:08 ` Ken Brown
  0 siblings, 2 replies; 10+ messages in thread
From: Ken Brown @ 2016-01-30 20:46 UTC (permalink / raw)
  To: cygwin

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/

Is the removal of the trailing slash in the first example a deliberate 
design decision?  I find it counter-intuitive.

My tests are essentially based on the example at the end of 
https://cygwin.com/cygwin-api/func-cygwin-conv-path.html:

#include <sys/cygwin.h>
#include <stdio.h>
#include <stdlib.h>

int
main ()
{
   wchar_t *win32 = L"d:/";
   ssize_t size;
   char *posix;
   size = cygwin_conv_path (CCP_WIN_W_TO_POSIX, win32, NULL, 0);
   if (size < 0)
     perror ("cygwin_conv_path");
   else
     {
       posix = (char *) malloc (size);
       if (cygwin_conv_path (CCP_WIN_W_TO_POSIX, win32, posix, size))
	perror ("cygwin_conv_path");
     }
   printf ("%s\n", posix);
}

Ken

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cygwin_conv_path sometimes removes trailing slash
  2016-01-30 20:46 cygwin_conv_path sometimes removes trailing slash Ken Brown
@ 2016-01-31 22:25 ` Jan Nijtmans
  2016-02-01 10:29   ` Henri
       [not found]   ` <CAOYw7ds-N=f+JCn-2rtFqOyahmA_M9mVNwv1CZH6__M-K7ht1A@mail.gmail.com>
  2016-02-14 19:08 ` Ken Brown
  1 sibling, 2 replies; 10+ messages in thread
From: Jan Nijtmans @ 2016-01-31 22:25 UTC (permalink / raw)
  To: cygwin

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.

Regards,
     Jan Nijtmans

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cygwin_conv_path sometimes removes trailing slash
  2016-01-31 22:25 ` Jan Nijtmans
@ 2016-02-01 10:29   ` Henri
  2016-02-01 10:38     ` Henri
  2016-02-01 10:45     ` Ray Donnelly
       [not found]   ` <CAOYw7ds-N=f+JCn-2rtFqOyahmA_M9mVNwv1CZH6__M-K7ht1A@mail.gmail.com>
  1 sibling, 2 replies; 10+ messages in thread
From: Henri @ 2016-02-01 10:29 UTC (permalink / raw)
  To: cygwin

Jan Nijtmans <jan.nijtmans <at> gmail.com> writes:

> 
> 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.
> 
> Regards,
>      Jan Nijtmans

For the record ...

 - Ken Brown refers to: win32 -> posix
 - Jan Nijthuis and Ray Donnelly refer to: posix -> win32

Different code paths ...

(and yes, conversions in both directions should be correct)

Regards,
Henri






--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cygwin_conv_path sometimes removes trailing slash
  2016-02-01 10:29   ` Henri
@ 2016-02-01 10:38     ` Henri
  2016-02-01 10:45     ` Ray Donnelly
  1 sibling, 0 replies; 10+ messages in thread
From: Henri @ 2016-02-01 10:38 UTC (permalink / raw)
  To: cygwin

Henri <houder <at> xs4all.nl> writes:

> For the record ...
> 
>  - Ken Brown refers to: win32 -> posix
>  - Jan Nijthuis and Ray Donnelly refer to: posix -> win32
> 
> Different code paths ...
> 
> (and yes, conversions in both directions should be correct)

s/Nijthuis/Nijtmans/

Sigh.

Henri




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cygwin_conv_path sometimes removes trailing slash
  2016-02-01 10:29   ` Henri
  2016-02-01 10:38     ` Henri
@ 2016-02-01 10:45     ` Ray Donnelly
  2016-02-01 10:59       ` Henri
  1 sibling, 1 reply; 10+ messages in thread
From: Ray Donnelly @ 2016-02-01 10:45 UTC (permalink / raw)
  To: cygwin

On Mon, Feb 1, 2016 at 10:29 AM, Henri <houder@xs4all.nl> wrote:
> Jan Nijtmans <jan.nijtmans <at> gmail.com> writes:
>
>>
>> 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.
>>
>> Regards,
>>      Jan Nijtmans
>
> For the record ...
>
>  - Ken Brown refers to: win32 -> posix
>  - Jan Nijthuis and Ray Donnelly refer to: posix -> win32
>
> Different code paths ...
>
> (and yes, conversions in both directions should be correct)

I can't check as I'm at work, but to the best of my knowledge (and yes
I wrote these a long time ago) path_conv::check is used in conversions
both ways so I am talking about both cases here, Jan's with the first
patch and Ken's with the second patch. Please do correct me if I am
wrong though! I will run some detailed tests tonight.

Best regards,

Ray.

>
> Regards,
> Henri
>
>
>
>
>
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cygwin_conv_path sometimes removes trailing slash
  2016-02-01 10:45     ` Ray Donnelly
@ 2016-02-01 10:59       ` Henri
  0 siblings, 0 replies; 10+ messages in thread
From: Henri @ 2016-02-01 10:59 UTC (permalink / raw)
  To: cygwin

Ray Donnelly <mingw.android <at> gmail.com> writes:

> I can't check as I'm at work, but to the best of my knowledge (and yes
> I wrote these a long time ago) path_conv::check is used in conversions
> both ways so I am talking about both cases here, Jan's with the first
> patch and Ken's with the second patch. Please do correct me if I am
> wrong though! I will run some detailed tests tonight.

As I wrote to Ken (private e-mail), let us wait for Corinna: she knows
all the nooks and crannies here ...

As far as I can tell, path_conv::check() is invoked for posix -> win32
only; that is, in cygwin_conv_path() (winsup/cygwin/path.cc).

But, again, let us wait for Corinna.

Regards,
Henri


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cygwin_conv_path sometimes removes trailing slash
       [not found]   ` <CAOYw7ds-N=f+JCn-2rtFqOyahmA_M9mVNwv1CZH6__M-K7ht1A@mail.gmail.com>
@ 2016-02-08 18:13     ` Corinna Vinschen
  2016-02-11 16:50       ` Ray Donnelly
  0 siblings, 1 reply; 10+ messages in thread
From: Corinna Vinschen @ 2016-02-08 18:13 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 2313 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cygwin_conv_path sometimes removes trailing slash
  2016-02-08 18:13     ` Corinna Vinschen
@ 2016-02-11 16:50       ` Ray Donnelly
  0 siblings, 0 replies; 10+ messages in thread
From: Ray Donnelly @ 2016-02-11 16:50 UTC (permalink / raw)
  To: cygwin

On Mon, Feb 8, 2016 at 6:13 PM, Corinna Vinschen
<corinna-cygwin@cygwin.com> wrote:
> Hi Ray,
>

Hi Corinna,

Sorry for the delay, I've been snowed under with day-job things lately.

> 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.

Great!

>
> 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.

It is what we needed on MSYS2. When building a "native" GCC, we'd pass
e.g. --sysroot=/ and that'd get expanded to "C:/cygwin" and have say a
sys include dir of "sys/include" appended making
C:/cygwinsys/include". I can't guarantee that *nothing* else will
break because of this change except to offer that anecdotally no msys2
package (i.e. those packages in MSYS2 that are purely POSIX) build or
execution failure was ever determined to be caused by making this
change.

Best regards,

Ray.

>
>
> Thanks,
> Corinna
>
> --
> Corinna Vinschen                  Please, send mails regarding Cygwin to
> Cygwin Maintainer                 cygwin AT cygwin DOT com
> Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cygwin_conv_path sometimes removes trailing slash
  2016-01-30 20:46 cygwin_conv_path sometimes removes trailing slash Ken Brown
  2016-01-31 22:25 ` Jan Nijtmans
@ 2016-02-14 19:08 ` Ken Brown
  2016-02-15 15:26   ` Corinna Vinschen
  1 sibling, 1 reply; 10+ messages in thread
From: Ken Brown @ 2016-02-14 19:08 UTC (permalink / raw)
  To: cygwin

On 1/29/2016 10:21 PM, Ken Brown wrote:
> 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.

Hi Corinna,

After your recent patch (git commit 8b83da2), I now see the conversion

   d:/ --> /cygdrive/d/

as expected.  But I have

   C: /c some_fs binary,posix=0 0 0

in my /etc/fstab, and I get the conversion

   C:/ --> /c

I would expect conversion to preserve the trailing slash here too.

Ken

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cygwin_conv_path sometimes removes trailing slash
  2016-02-14 19:08 ` Ken Brown
@ 2016-02-15 15:26   ` Corinna Vinschen
  0 siblings, 0 replies; 10+ messages in thread
From: Corinna Vinschen @ 2016-02-15 15:26 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 855 bytes --]

Hi Ken,

On Feb 14 14:08, Ken Brown wrote:
> On 1/29/2016 10:21 PM, Ken Brown wrote:
> >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.
> 
> Hi Corinna,
> 
> After your recent patch (git commit 8b83da2), I now see the conversion
> 
>   d:/ --> /cygdrive/d/
> 
> as expected.  But I have
> 
>   C: /c some_fs binary,posix=0 0 0
> 
> in my /etc/fstab, and I get the conversion
> 
>   C:/ --> /c
> 
> I would expect conversion to preserve the trailing slash here too.

Right.  You're hitting a border case there.  I fixed in in the repo.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-02-15 15:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-30 20:46 cygwin_conv_path sometimes removes trailing slash Ken Brown
2016-01-31 22:25 ` Jan Nijtmans
2016-02-01 10:29   ` Henri
2016-02-01 10:38     ` Henri
2016-02-01 10:45     ` Ray Donnelly
2016-02-01 10:59       ` Henri
     [not found]   ` <CAOYw7ds-N=f+JCn-2rtFqOyahmA_M9mVNwv1CZH6__M-K7ht1A@mail.gmail.com>
2016-02-08 18:13     ` Corinna Vinschen
2016-02-11 16:50       ` Ray Donnelly
2016-02-14 19:08 ` Ken Brown
2016-02-15 15:26   ` Corinna Vinschen

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).