commit: 59aa35d0fa3edf777e51c611a8d65bbc6799cf49
Author: Sven Eden <seden <AT> havi <DOT> de>
AuthorDate: Tue Oct 28 11:44:09 2014 +0000
Commit: Sven Eden <sven.eden <AT> gmx <DOT> de>
CommitDate: Tue Oct 28 11:44:09 2014 +0000
URL:
http://sources.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=59aa35d0
Portage.pm : Added fix by Martin Väth from Bug 525876 to allow the reading of
directories that used to be files.
---
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;
}