Gentoo Logo
Gentoo Spaceship

Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-perl
Lists: gentoo-perl: < Prev By Thread Next > < Prev By Date Next >
To: gentoo-perl@g.o
From: Michael Cummings <mcummings@g.o>
Subject: Re: sub ebuild_exists - a lot of lc($dir)
Date: Thu, 12 May 2005 08:08:01 -0400

 The answers :)

>  sub ebuild_exists {
> -    my ($dir) = lc $_[0];
> +    my ($dir) = $_[0];
>      # need to try harder here - see &portage_dir comments.
>      # should return an ebuild name from this, as case matters.
> @@ -264,8 +270,9 @@
>          next if not -d $sdir;
>          opendir PDIR, $sdir or fatal(ERR_FOLDER_OPEN, $sdir, $!);
>          while(my $file = readdir PDIR) {
> -            if(lc $file eq $dir) {
> -                $found = $dir;
> +            if(lc $file eq lc $dir) {
> +               my $cat = basename($sdir);
> +                $found = "$cat/$file";
> I don't understand this modification.
> Why lc($dir) for each file in PDIR, best is one and only lc($dir) at the
> start of sub for best performances.

Because when you lc it on the way in, it's lc for the scope. But I needed to 
have the name as it really was for $found="$cat/$file" since this needs to be 
able to translate to the real name in the tree. The (lc $file eq lc $dir) is 
merely to cover our bases that we didn't change the case of the name on our 
end vs cpan's. It was all about reducing reduplicated work later on - if I 
can build $cat/$file correctly in this sub, I could drop an entire sub later 
on (which is dropped usage wise, just not from the code - I was tired :) ) 
that was doing the exact same thing over again. The other part of the change 
was that I needed found to point to file, not dir - we're building a list of 
the existing ebuilds we depend on, and file references what we're reading 
straight from the tree. I know, shouldn't matter, but when I was working on 
it it did (probably if I was still working through the scoping issues in 
lc(). )

> If $found must be the original $dir w/o case change, I propose :
> sub ebuild_exists {
>      my ($dir) =  @_;
>      my $lcase_dir = lc $dir;
> [...later...]
>          while(my $file = readdir PDIR) {
>              if(lc $file eq $lcase_dir) {
>                  $found = $dir;

eh, either way, i'm easy - but that should be $found = "$cat/$dir" - we need 
that $cat in there so we can minimize rewriting the same code over again just 
to go back and see where we had the file and get the cat - when all we needed 
to do was include the cat in the finding.


Michael Cummings   |    #gentoo-dev, #gentoo-perl
Gentoo Perl Dev    |    on 
pgpCz0oNI7MnT.pgp (PGP signature)
sub ebuild_exists - a lot of lc($dir)
-- David (Sniper) Rigaudiere
Lists: gentoo-perl: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Réf. : Re: Réf. : sub ebuild _exists - a lot of lc($dir)
Next by thread:
Previous by date:
Re: Réf. : look'n'feel
Next by date:
Re: Réf. : sub ebuild_exists - a lot of lc($dir)

Updated Jun 17, 2009

Summary: Archive of the gentoo-perl mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.