From 59aa35d0fa3edf777e51c611a8d65bbc6799cf49 Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Tue, 28 Oct 2014 12:44:09 +0100 Subject: Portage.pm : Added fix by Martin Väth from Bug 525876 to allow the reading of directories that used to be files. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Portage.pm | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Portage.pm b/Portage.pm index 229ebba..5aacd42 100644 --- a/Portage.pm +++ b/Portage.pm @@ -705,19 +705,27 @@ sub _merge_env { } -# returns a list of all lines of a given file +# returns a list of all lines of a given file/dir # that are no pure comments -# Parameter 1: filename +# Parameter 1: filename/dirname sub _noncomments { my ($fname) = @_; - my @result; - local $/; - if(open my $file, '<', $fname) { - binmode( $file, ":encoding(UTF-8)" ); - @result = split /(?:[^\S\n]*(?:#.*)?\n)+/, <$file>."\n"; - shift @result if @result>0 && $result[0] eq ''; - close $file; + my @result = (); + + if(-d $fname) { + for my $i (_get_files_from_dir($fname)) { + (-f $i) && push @result, _noncomments($i); + } + } else { + local $/; + if(open my $file, '<', $fname) { + binmode( $file, ":encoding(UTF-8)" ); + @result = split /(?:[^\S\n]*(?:#.*)?\n)+/, <$file>."\n"; + shift @result if @result>0 && $result[0] eq ''; + close $file; + } } + return @result; } -- cgit v1.2.3-65-gdbad