delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/05/06/11:59:42

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-Id: <scd66f61.025@nrcgwia.nrc.gov>
Date: Mon, 06 May 2002 11:56:03 -0400
From: "Christopher Murray" <CJM4 AT nrc DOT gov>
To: <cygwin AT cygwin DOT com>
Subject: Re: canonpath in perl as it relates to cygwin
Mime-Version: 1.0
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id g46FxfL00629

Actually, unless I am totally overlooking something, this looks to be a step 
backward.  Will the following regexp -

$^O =~ m/^(?:qnx|nto)$/ 

cause a match under cygwin in perl 5.8)?   I can't see how, but then again,
I haven't actually run perl 5.8 to check what $^O returns.

If not, then what I see is that the logic goes from

   $path =~ s|/+|/|g unless($^O eq 'cygwin');

to

    $path =~ s|/+|/|g;                             # xx////xx  -> xx/xx

thus converting all paths that begin with // to a single /.  Is this correct 
considering that "//share/path" indicates a network share under
cygwin and probably not something one would want to upset?

Thanks for the timely response, (to you too Larry)
Chris



Perl 5.8:
=========
sub canonpath {
    my ($self,$path) = @_;
    
    # Handle POSIX-style node names beginning with double slash
    my $node = '';
    if ( $^O =~ m/^(?:qnx|nto)$/ && $path =~ s:^(//[^/]+)(/|\z):/:s ) {
      $node = $1;
    }
    # This used to be
    # $path =~ s|/+|/|g unless($^O eq 'cygwin');
    # but that made tests 29, 30, 35, 46, and 213 (as of #13272) to fail
    # (Mainly because trailing "" directories didn't get stripped).
    # Why would cygwin avoid collapsing multiple slashes into one? --jhi
    $path =~ s|/+|/|g;                             # xx////xx  -> xx/xx
    $path =~ s@(/\.)+(/|\Z(?!\n))@/@g;             # xx/././xx -> xx/xx
    $path =~ s|^(\./)+||s unless $path eq "./";    # ./xx      -> xx
    $path =~ s|^/(\.\./)+|/|s;                     # /../../xx -> xx
    $path =~ s|/\Z(?!\n)|| unless $path eq "/";          # xx/       -> xx
    return "$node$path";
}

Looks more sophisticated?


Gerrit
-- 
=^..^=



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

- Raw text -


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