[SCM] Debian package checker branch, master, updated. 2.5.6-95-g504c311
The following commit has been merged in the master branch:
commit 504c311a6d20d95cdf81e77eb07375bf19c86db5
Author: Niels Thykier <niels@thykier.net>
Date: Sat Apr 14 15:20:52 2012 +0200
L::Util: Auto-close handles in slurp_entire_file
When passed a handle, slurp_entire_file will now close the handle
by default.
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/lib/Lintian/Util.pm b/lib/Lintian/Util.pm
index 6925658..625623d 100644
--- a/lib/Lintian/Util.pm
+++ b/lib/Lintian/Util.pm
@@ -227,12 +227,14 @@ sub _ensure_file_is_sane {
return 0;
}
+# slurp_entire_file ($file[, $noclose])
+#
# Reads an entire file(-handle) and return it as a scalar.
#
-# NB: When given a handle, it will *not* close the handle for
-# the caller.
+# NB: When given a handle, it will close the handle for the caller
+# except when $noclose is passed and a truth value.
sub slurp_entire_file {
- my $file = shift;
+ my ($file, $noclose) = @_;
my $fd;
my $res;
if (openhandle $file) {
@@ -243,7 +245,7 @@ sub slurp_entire_file {
}
local $/;
local $_ = <$fd>;
- close $fd unless openhandle $file;
+ close $fd unless $noclose && openhandle $file;
return $_;
}
--
Debian package checker
Reply to: