1 |
Snip, |
2 |
|
3 |
The answers :) |
4 |
|
5 |
> sub ebuild_exists { |
6 |
> - my ($dir) = lc $_[0]; |
7 |
> + my ($dir) = $_[0]; |
8 |
> |
9 |
> # need to try harder here - see &portage_dir comments. |
10 |
> # should return an ebuild name from this, as case matters. |
11 |
> @@ -264,8 +270,9 @@ |
12 |
> next if not -d $sdir; |
13 |
> opendir PDIR, $sdir or fatal(ERR_FOLDER_OPEN, $sdir, $!); |
14 |
> while(my $file = readdir PDIR) { |
15 |
> - if(lc $file eq $dir) { |
16 |
> - $found = $dir; |
17 |
> + if(lc $file eq lc $dir) { |
18 |
> + my $cat = basename($sdir); |
19 |
> + $found = "$cat/$file"; |
20 |
> |
21 |
> |
22 |
> |
23 |
> I don't understand this modification. |
24 |
> Why lc($dir) for each file in PDIR, best is one and only lc($dir) at the |
25 |
> start of sub for best performances. |
26 |
|
27 |
Because when you lc it on the way in, it's lc for the scope. But I needed to |
28 |
have the name as it really was for $found="$cat/$file" since this needs to be |
29 |
able to translate to the real name in the tree. The (lc $file eq lc $dir) is |
30 |
merely to cover our bases that we didn't change the case of the name on our |
31 |
end vs cpan's. It was all about reducing reduplicated work later on - if I |
32 |
can build $cat/$file correctly in this sub, I could drop an entire sub later |
33 |
on (which is dropped usage wise, just not from the code - I was tired :) ) |
34 |
that was doing the exact same thing over again. The other part of the change |
35 |
was that I needed found to point to file, not dir - we're building a list of |
36 |
the existing ebuilds we depend on, and file references what we're reading |
37 |
straight from the tree. I know, shouldn't matter, but when I was working on |
38 |
it it did (probably if I was still working through the scoping issues in |
39 |
lc(). ) |
40 |
|
41 |
> |
42 |
> If $found must be the original $dir w/o case change, I propose : |
43 |
> |
44 |
> |
45 |
> sub ebuild_exists { |
46 |
> my ($dir) = @_; |
47 |
> my $lcase_dir = lc $dir; |
48 |
> |
49 |
> [...later...] |
50 |
> |
51 |
> while(my $file = readdir PDIR) { |
52 |
> if(lc $file eq $lcase_dir) { |
53 |
> $found = $dir; |
54 |
|
55 |
eh, either way, i'm easy - but that should be $found = "$cat/$dir" - we need |
56 |
that $cat in there so we can minimize rewriting the same code over again just |
57 |
to go back and see where we had the file and get the cat - when all we needed |
58 |
to do was include the cat in the finding. |
59 |
|
60 |
-- |
61 |
|
62 |
-----o()o--------------------------------------------- |
63 |
Michael Cummings | #gentoo-dev, #gentoo-perl |
64 |
Gentoo Perl Dev | on irc.freenode.net |
65 |
-----o()o--------------------------------------------- |