Gentoo Archives: gentoo-perl

From: "David (Sniper) Rigaudiere" <sniper@×××××××××.net>
To: gentoo-perl@l.g.o
Subject: [gentoo-perl] sub ebuild_exists - a lot of lc($dir)
Date: Thu, 12 May 2005 01:11:51
Message-Id: 20050512010448.M45172@rigaudiere.net
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.

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;


$cab->todo->add('svn commit notif email script'); # ;-)

David "Sniper" Rigaudiere
GPG KeyID 0xFF1E982D

-- 
gentoo-perl@g.o mailing list

Replies

Subject Author
Réf. : [gentoo-perl] sub ebuild_exists - a lot of lc($dir) antoine.raillon@××××.com
Re: [gentoo-perl] sub ebuild_exists - a lot of lc($dir) Michael Cummings <mcummings@g.o>