[Commits] [SCM] clawsker branch, master, updated. 1.3.8-13-g73cc06b
mones at claws-mail.org
mones at claws-mail.org
Wed Aug 28 15:59:59 UTC 2024
The branch, master has been updated
via 73cc06b3925b49d1de3dc18e1e81428977ce757a (commit)
from b1d8fce1bb1475db0abc3cd44f7010476a5f4c43 (commit)
Summary of changes:
clawsker | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
- Log -----------------------------------------------------------------
commit 73cc06b3925b49d1de3dc18e1e81428977ce757a
Author: Ricardo Mones <ricardo at mones.org>
Date: Wed Aug 28 17:59:07 2024 +0200
Close filehandles as soon as possible
diff --git a/clawsker b/clawsker
index ae0d097..e6e6170 100755
--- a/clawsker
+++ b/clawsker
@@ -2708,8 +2708,10 @@ sub load_resource {
my $line = 0;
open (my $RCF, '<:encoding(utf8)', $rc)
or die _("Error: opening '{file}' for reading", file => $rc) . ": $!\n";
+ my @lines = <$RCF>;
+ close ($RCF);
my $section = '_'; # default unnamed section
- while (<$RCF>) {
+ for (@lines) {
chomp;
++$line;
next if (/^\s*$/);
@@ -2728,25 +2730,23 @@ sub load_resource {
push (@{$data{$section}{'_'}}, $1);
}
}
- close ($RCF);
return (\%data, \%meta);
}
sub save_resource {
my ($rc, $data, $meta) = @_;
- open (my $RCF, '>:encoding(utf8)', $rc)
- or die _("Error: opening '{file}' for writing", file => $rc) . ": $!\n";
my @sections = keys %$data;
if (defined $meta) {
@sections = sort {
$meta->{$a}{'#'} <=> $meta->{$b}{'#'}
} @sections
}
+ my @lines = ();
foreach my $section (@sections) {
- say $RCF "[$section]";
+ push @lines, "[$section]";
if (ref ($data->{$section}{'_'}) eq 'ARRAY') {
foreach my $val (@{$data->{$section}{'_'}}) {
- say $RCF $val;
+ push @lines, $val;
}
delete $data->{$section}{'_'};
}
@@ -2758,10 +2758,13 @@ sub save_resource {
}
foreach my $key (@keys) {
my $val = $data->{$section}{$key};
- say $RCF "$key=$val";
+ push @lines, "$key=$val";
}
- say $RCF "";
+ push @lines, "";
}
+ open (my $RCF, '>:encoding(utf8)', $rc)
+ or die _("Error: opening '{file}' for writing", file => $rc) . ": $!\n";
+ for (@lines) { say $RCF $_ }
close ($RCF);
}
@@ -2782,9 +2785,11 @@ sub load_menurc {
my $rc = shift;
open (my $RCF, '<:encoding(utf8)', $rc)
or die _("Error: opening '{file}' for reading", file => $rc) . ": $!\n";
+ my @lines = <$RCF>;
+ close ($RCF);
my %groups = ();
my $line = 0;
- while (<$RCF>) {
+ for (@lines) {
chomp;
if (/^; \(gtk_accel_path "<([A-Za-z]+)>([^"]+)" ([^\)]+)\)$/) {
my %data = ('key' => $3, 'enabled' => FALSE, 'line' => $line);
@@ -2797,7 +2802,6 @@ sub load_menurc {
}
++$line;
}
- close ($RCF);
return \%groups;
}
-----------------------------------------------------------------------
hooks/post-receive
--
Hidden preferences editor for Claws Mail
More information about the Commits
mailing list