Snip,
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.
--
-----o()o---------------------------------------------
Michael Cummings | #gentoo-dev, #gentoo-perl
Gentoo Perl Dev | on irc.freenode.net
-----o()o---------------------------------------------
|