summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Eden <seden@havi.de>2014-10-28 12:44:09 +0100
committerSven Eden <seden@havi.de>2014-10-28 12:44:09 +0100
commit59aa35d0fa3edf777e51c611a8d65bbc6799cf49 (patch)
tree81e2612670033753d951f6d8e3e77e79bb9b4b83
parentTODO: Added plan to support package.use editing. (diff)
downloadufed-59aa35d0fa3edf777e51c611a8d65bbc6799cf49.tar.gz
ufed-59aa35d0fa3edf777e51c611a8d65bbc6799cf49.tar.bz2
ufed-59aa35d0fa3edf777e51c611a8d65bbc6799cf49.zip
Portage.pm : Added fix by Martin Väth from Bug 525876 to allow the reading of directories that used to be files.
-rw-r--r--Portage.pm26
1 files 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;
}