From 74c036b5a725d8d268ea62ace595bce9d4eaf36f Mon Sep 17 00:00:00 2001 From: martin f. krafft Date: Fri, 24 Feb 2017 07:33:08 +1300 Subject: Fix network matching for query subcommand In the absence of a network tag passed to the `query` subcommand, no rules but the default would match and so the returned match(es) would potentially not actually be the ones used in context of ctrlact's normal operation. This commit fixes #354 by special-casing the threshold match when the data to be looked up doesn't actually specify a network tag. In this case, the output for net will be '(ignored)'. Signed-off-by: martin f. krafft --- scripts/ctrlact.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/ctrlact.pl b/scripts/ctrlact.pl index 534b00a..aa9dcfb 100644 --- a/scripts/ctrlact.pl +++ b/scripts/ctrlact.pl @@ -111,7 +111,7 @@ use Carp qw( croak ); use Irssi; use Text::ParseWords; -our $VERSION = '1.1'; +our $VERSION = '1.2'; our %IRSSI = ( authors => 'martin f. krafft', @@ -119,7 +119,7 @@ our %IRSSI = ( name => 'ctrlact', description => 'allows per-channel control over activity indication', license => 'MIT', - changed => '2017-02-15' + changed => '2017-02-24' ); ### DEFAULTS AND SETTINGS ###################################################### @@ -208,7 +208,8 @@ sub from_data_level { sub walk_match_array { my ($name, $net, $type, @arr) = @_; foreach my $quadruplet (@arr) { - my $netmatch = match($quadruplet->[0], $net); + my $netmatch = $net eq '*' ? '(ignored)' + : match($quadruplet->[0], $net); my $match = match($quadruplet->[1], $name); next unless $netmatch and $match; -- cgit v1.2.3 From 85e74f61af85356830030596e9ff77faf2f7c05f Mon Sep 17 00:00:00 2001 From: martin f. krafft Date: Fri, 24 Feb 2017 07:41:29 +1300 Subject: Loosen version check on data file read The versioning of the data file allows for making changes to the format, but if the script version increases without the data file-format being changed, things are expected to work as before, and thus there ought not be an error spouted. Let's only use the versioning to patch up handling for formats of the past. Signed-off-by: martin f. krafft --- scripts/ctrlact.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/ctrlact.pl b/scripts/ctrlact.pl index aa9dcfb..da39804 100644 --- a/scripts/ctrlact.pl +++ b/scripts/ctrlact.pl @@ -432,14 +432,14 @@ sub load_mappings { my $nrcols = 4; if ($version eq $VERSION) { - # current version + # current version, i.e. no special handling is required. If + # previous versions require special handling, then massage the + # data or do whatever is required in the following + # elsif-clauses: } elsif ($version eq "1.0") { $nrcols = 3; } - else { - croak "Unsupported version found in $filename: $version" - } my $linesplitter = '^\s*'.join('\s+', ('(\S+)') x $nrcols).'\s*$'; my $l = 1; while (<$fh>) { -- cgit v1.2.3