diff options
| author | martin f. krafft | 2017-02-15 22:14:05 +0100 |
|---|---|---|
| committer | martin f. krafft | 2017-02-15 22:34:44 +0100 |
| commit | 9a06b4ae868eb006c1db46c61502ff8d49ebec4f (patch) | |
| tree | b76065e9be15c743c33b313a267b85899c22a8ec /scripts/ctrlact.pl | |
| parent | 70893f08280e062732e84bed4314419ecfdfcd7a (diff) | |
| download | scripts.irssi.org-9a06b4ae868eb006c1db46c61502ff8d49ebec4f.tar.bz2 | |
Properly handle mappings file creation
Signed-off-by: martin f. krafft <madduck@madduck.net>
Diffstat (limited to 'scripts/ctrlact.pl')
| -rw-r--r-- | scripts/ctrlact.pl | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/scripts/ctrlact.pl b/scripts/ctrlact.pl index 28263ef..c35a2c4 100644 --- a/scripts/ctrlact.pl +++ b/scripts/ctrlact.pl @@ -370,7 +370,7 @@ sub get_mappings_fh { my $ftc = from_data_level($fallback_channel_threshold); my $ftq = from_data_level($fallback_query_threshold); print $fh <<"EOF"; -# ctrlact mappings file (version:$VERSION) +# ctrlact mappings file (version: $VERSION) # # type: window, channel, query # server: the server tag (chatnet) @@ -411,6 +411,7 @@ sub get_mappings_fh { # vim:noet:tw=0:ts=16 EOF Irssi::print("ctrlact: created new/empty mappings file: $filename"); + seek($fh, 0, 0) || croak "Cannot rewind $filename."; } return $fh; } @@ -419,9 +420,9 @@ sub load_mappings { my ($filename) = @_; @window_thresholds = @channel_thresholds = @query_thresholds = (); my $fh = get_mappings_fh($filename); - my $firstline = <$fh>; + my $firstline = <$fh> || croak "Cannot read from $filename.";; my $version; - if ($firstline =~ m/^#+\s+ctrlact mappings file \(version:([\d.]+)\)/) { + if ($firstline =~ m/^#+\s+ctrlact mappings file \(version: *([\d.]+)\)/) { $version = $1; } else { |
