Re: [MacPerl-Porters] [PATCHES] A new catdir()

[email protected] (Thomas Wegner)
Newsgroups perl.macperl.porters
Message-ID <p04320401b7f3642f391d@[149.225.13.166]>
At 8:17 Uhr -0400 17.10.2001, Chris Nandor wrote:
>At 09:42 +0200 2001.10.17, Thomas Wegner wrote:
>>At 20:24 Uhr -0400 15.10.2001, Chris Nandor wrote:
>>>Hm.  I get this error:
>>>
>>>not ok 353 # Mac->abs2rel('hd:','hd:d1:d2:'): got ':::Bourque:', expected
>>>':::'
>>>
>>>Of course, Bourque is my startup volume.  However, I am running the test on
>>>a separate volume, Bird.
>>>
>>
>>Hm ...? That's odd. I cannot reproduce this error and I cannot find an
>>error in F::S::Mac.pm, no matter if I run the test on a separate volume or
>>not (this shouldn't matter anyway). Will you please do me a favour? I've
>>attached a slightly changed debugging version of Mac.pm, which produces
>>some trace output
>for Mac->abs2rel(). Can you please run the test again and send me the
>output for
>
>Hmmm.  Here is your original patch (a chunk of it).  Note the addition of
>the if/else for $path_dirs.
>
>@@ -521,14 +668,18 @@
>         shift @pathchunks ;
>         shift @basechunks ;
>     }
>-
>+
>     # @pathchunks now has the directories to descend in to.
>-    $path_dirs = $self->catdir( @pathchunks );
>+	if ( (@pathchunks) && ($pathchunks[0] ne '') ) {
>+    	$path_dirs = $self->catdir( @pathchunks );
>+	} else {
>+		$path_dirs = '';
>+	}
>
>     # @basechunks now contains the number of directories to climb out of.
>     $base_dirs = (':' x @basechunks) . ':' ;
>
>-    return $self->catpath( '', $base_dirs . $path_dirs, $path_file ) ;
>+    return $self->catpath( '', $self->catdir( $base_dirs, $path_dirs ),
>$path_file ) ;
> }
>
> =item rel2abs
>
>However, in the latest version, you have this line instead:
>
>	$path_dirs = $self->catdir( ':', @pathchunks );
>
>When changing it to use that line, all tests pass.  Thanks, this looks good.
>


Yeah, that's what I meant with "slightly changed" (except the debug additions). To be honest, I don't know why the first version didn't work for you. Regardless, the new version is more elegant and safer. We now have to pay attention not to pass the empty string as first argument by mistake. 

Thanks.

Best regards,

--Thomas


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.