delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/10/05/10:21:18

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; q=dns; s=default; b=Qq
Hnn1jSccahs8g1nwXbmcFi6GiVuY8YzEZVNiZGzop1XgjuYU4FR1Vo4HfoltEzit
/F17aTC8KKS0eqWltPGzLk7FxOCHkzojphcv2MFsRsknxiMgnoICWhW4+bEZEGB5
PA1+GLK6CHTku51qh3bb06/CB6Jpg26fLCem0FrE8=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; s=default; bh=nzIHiG4e
N8igqDMKKwOKtzbUSSI=; b=serE34wLfNFwkFJUlSaRI3L6PAlLcdGPFiJzG6FH
uvu5HmmnnhwDCeBF1/UEeOGhzkX47tEjKmdBtG42faW8tum+jPewWDutH6f7s+3y
UD/EjSRPdMHNIk5tDqof9yJBctxNCiya35wVMt13CvfA2rckTp2ADS9MUszNT6cP
2b4=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=0.5 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-ig0-f178.google.com
MIME-Version: 1.0
X-Received: by 10.50.43.170 with SMTP id x10mr10164187igl.89.1444054857895; Mon, 05 Oct 2015 07:20:57 -0700 (PDT)
In-Reply-To: <caaf01d0b0a80e077f56abed63864729@webmail.webfaction.com>
References: <caaf01d0b0a80e077f56abed63864729 AT webmail DOT webfaction DOT com>
Date: Mon, 5 Oct 2015 16:20:57 +0200
Message-ID: <CAO1jNwvxk6_B1RF4AKksZpfQJkk-CoQgmi=BeFrsz9MxOtaPKg@mail.gmail.com>
Subject: Re: cygpath and partial normalization of trailing /.
From: Jan Nijtmans <jan DOT nijtmans AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

2015-10-05 14:29 GMT+02:00 Poor Yorick:
> Rather than normalizing half of it away and leaving half of it, Wouldn't it
> be
> better to either not normalize the trailing slash-dot sequence at all, or to
> completely normalize it away?  If that which is delimited is removed, it
> would
> seem to make sense to removed the delimiter as well.

Here is a small test program, which shows that the
function cygwin_conv_path(CCP_POSIX_TO_WIN_A, ....)
does the stripping of the '.' and/or '/'. This function is
used by cygpath to do the actual conversion.

Output of the test program:
  /cygdrive/c/Windows -> C:\Windows
  /cygdrive/c/Windows/ -> C:\Windows     <-- (1)
  /cygdrive/c/Windows/. -> C:\Windows
  /home/foo -> C:\Users\foo
  /home/foo/ -> C:\Users\foo\
  /home/foo/. -> C:\Users\foo\                <-- (2)

It indeed makes sense to:
   - either strip both the '.' and the backslash
   - or keep both of them.
The arrows (<--) mark lines that give inconsistant
results, when the input ends with a separator
and the output doesn't (1), or reverse (2).

Thanks for the bug report. I'm not confident enough in
the Cygwin source code, but I hope someone else
can shine some light on it and give advise.

================ test.c =================
#include <sys/cygwin.h>
#include <stdio.h>

static const char *paths[] = {
    "/cygdrive/c/Windows",
    "/cygdrive/c/Windows/",
    "/cygdrive/c/Windows/.",
    "/home/foo",
    "/home/foo/",
    "/home/foo/.",
   0
};


void main() {
   char buf[320];
   const char **p = paths;

   do {
   cygwin_conv_path(CCP_POSIX_TO_WIN_A, *p, buf, sizeof(buf));
   printf("%s -> %s\n", *p, buf);
   } while (*++p);
}

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019