From 112baf5b4c3dd1f4897a15f2414befab7d83b309 Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Tue, 10 Sep 2019 17:02:53 +0100 Subject: [PATCH] improve DXQsl handling and fix crashes? --- Changes | 3 +++ cmd/load/dxqsl.pl | 7 +++++++ cmd/load/qsl.pl | 8 +------- perl/DXUtil.pm | 3 ++- perl/QSL.pm | 15 ++++++++++++--- 5 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 cmd/load/dxqsl.pl mode change 100644 => 120000 cmd/load/qsl.pl diff --git a/Changes b/Changes index a8d71b44..3473184f 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ +10Sep19======================================================================= +1. Improve DXSql database filtering to exclude most via type + reports. 14Jul18======================================================================= 1. Add CTY-2808 prefixes + wpxloc.raw 23Jan18======================================================================= diff --git a/cmd/load/dxqsl.pl b/cmd/load/dxqsl.pl new file mode 100644 index 00000000..ddf51d34 --- /dev/null +++ b/cmd/load/dxqsl.pl @@ -0,0 +1,7 @@ +# +# load the QSL file after changing it +# +my $self = shift; +return (1, $self->msg('e5')) if $self->priv < 9; +my $r = QSL::init(1); +return (1, $r ? $self->msg('ok') : $self->msg('e2', "$!")); diff --git a/cmd/load/qsl.pl b/cmd/load/qsl.pl deleted file mode 100644 index ddf51d34..00000000 --- a/cmd/load/qsl.pl +++ /dev/null @@ -1,7 +0,0 @@ -# -# load the QSL file after changing it -# -my $self = shift; -return (1, $self->msg('e5')) if $self->priv < 9; -my $r = QSL::init(1); -return (1, $r ? $self->msg('ok') : $self->msg('e2', "$!")); diff --git a/cmd/load/qsl.pl b/cmd/load/qsl.pl new file mode 120000 index 00000000..1adfae50 --- /dev/null +++ b/cmd/load/qsl.pl @@ -0,0 +1 @@ +dxqsl.pl \ No newline at end of file diff --git a/perl/DXUtil.pm b/perl/DXUtil.pm index 4e442140..abb20a96 100644 --- a/perl/DXUtil.pm +++ b/perl/DXUtil.pm @@ -435,7 +435,8 @@ sub is_digits # does it look like a qra locator? sub is_qra { - return $_[0] =~ /^[A-Ra-r][A-Ra-r]\d\d[A-Xa-x][A-Xa-x]$/; + return unless length $_[0] == 4 || length $_[0] == 6; + return $_[0] =~ /^[A-Ra-r][A-Ra-r]\d\d(?:[A-Xa-x][A-Xa-x])?$/; } # does it look like a valid lat/long diff --git a/perl/QSL.pm b/perl/QSL.pm index 20d5c614..1031c953 100644 --- a/perl/QSL.pm +++ b/perl/QSL.pm @@ -14,9 +14,10 @@ use DB_File; use DXDebug; use Prefix; -use vars qw($qslfn $dbm); +use vars qw($qslfn $dbm $maxentries); $qslfn = 'qsl'; $dbm = undef; +$maxentries = 50; sub init { @@ -37,6 +38,7 @@ sub init } import Storable qw(nfreeze freeze thaw); my %u; + undef $dbm; if ($mode) { $dbm = tie (%u, 'DB_File', $ufn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)"; } else { @@ -65,19 +67,24 @@ sub update my $t = shift; my $by = shift; my $changed; - + + return unless length $line && $line =~ /\b(?:QSL|VIA)\b/i; foreach my $man (split /\b/, uc $line) { my $tok; - if (is_callsign($man)) { + if (is_callsign($man) && !is_qra($man)) { my @pre = Prefix::extract($man); $tok = $man if @pre && $pre[0] ne 'Q'; } elsif ($man =~ /^BUR/) { $tok = 'BUREAU'; + } elsif ($man =~ /^LOTW/) { + $tok = 'LOTW'; } elsif ($man eq 'HC' || $man =~ /^HOM/ || $man =~ /^DIR/) { $tok = 'HOME CALL'; } elsif ($man =~ /^QRZ/) { $tok = 'QRZ.com'; + } else { + next; } if ($tok) { my ($r) = grep {$_->[0] eq $tok} @{$self->[1]}; @@ -93,6 +100,8 @@ sub update unshift @{$self->[1]}, $r; $changed++; } + # prune the number of entries + pop @{$self->[1]} while (@{$self->[1]} > $maxentries); } } $self->put if $changed; -- 2.43.0