X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FPrefix.pm;h=e1dd5e5adc48b83965e6c9dfe84077b79c7f3af2;hb=fa4e6b2355688929d347ef6e46fa6483709e5fda;hp=ed1bd25f43a8585ded143b070fdf674659938379;hpb=6ca8d8f4ec9adb560d0df1e386b98f74c9ba9cb0;p=spider.git diff --git a/perl/Prefix.pm b/perl/Prefix.pm index ed1bd25f..e1dd5e5a 100644 --- a/perl/Prefix.pm +++ b/perl/Prefix.pm @@ -163,9 +163,9 @@ sub extract $p = $parts[0]; shift @parts if $p =~ /^(WEB|NET)$/o; $p = $parts[$#parts]; - pop @parts if $p =~ /^(\d+|[JPABM]|AM|MM|BCN|JOTA|SIX|WEB|NET|Q\w+)$/o; + pop @parts if $p =~ /^(\d+|[PABM]|AM|MM|BCN|JOTA|SIX|WEB|NET|Q\w+)$/o; $p = $parts[$#parts]; - pop @parts if $p =~ /^(\d+|[JPABM]|AM|MM|BCN|JOTA|SIX|WEB|NET|Q\w+)$/o; + pop @parts if $p =~ /^(\d+|[PABM]|AM|MM|BCN|JOTA|SIX|WEB|NET|Q\w+)$/o; # can we resolve them by direct lookup foreach $p (@parts) { @@ -179,24 +179,75 @@ sub extract } # which is the shortest part (first if equal)? - dbg("Parts: $call = " . join('|', @parts)) if isdbg('prefix'); - $sp = $parts[0]; - foreach $p (@parts) { - $sp = $p if length $p < length $sp; - } - $sp =~ s/-\d+$//; # remove any SSID + dbg("Parts: $call = " . join(' ', @parts)) if isdbg('prefix'); -# # now start to resolve it from the left hand end -# for ($i = 1; $i <= length $sp; ++$i) { - # now start to resolve it from the right hand end - for ($i = length $sp; $i >= 1; --$i) { - my $ssp = substr($sp, 0, $i); - my @wout = get($ssp); - dbg("Partial prefix: $sp $ssp $wout[0]" ) if isdbg('prefix') && $wout[0]; - next if @wout > 0 && $wout[0] gt $ssp; -# last if @wout == 0; - push @out, @wout; - last if @wout; + # try ALL the parts + my @checked; + my $n; +L1: for ($n = 0; $n < @parts; $n++) { + my $sp = ''; + my ($k, $i); + for ($i = $k = 0; $i < @parts; $i++) { + next if $checked[$i]; + my $p = $parts[$i]; + if (!$sp || length $p < length $sp) { + dbg("try part: $p") if isdbg('prefix'); + $k = $i; + $sp = $p; + } + } + $checked[$k] = 1; + $sp =~ s/-\d+$//; # remove any SSID + + # # now start to resolve it from the left hand end + # for ($i = 1; $i <= length $sp; ++$i) { + # now start to resolve it from the right hand end + for ($i = length $sp; $i >= 1; --$i) { + my $ssp = substr($sp, 0, $i); + my @wout = get($ssp); + if (isdbg('prefix')) { + my $part = $wout[0] || "*"; + $part .= '*' unless $part eq '*' || $part eq $ssp; + dbg("Partial prefix: $sp $ssp $part" ); + } + next if @wout > 0 && $wout[0] gt $ssp; + + # try and search for it in the descriptions as + # a whole callsign if it has multiple parts and the output + # is more two long, this should catch things like + # FR5DX/T without having to explicitly stick it into + # the prefix table. + + if (@wout) { + if (@parts > 1) { + $parts[$k] = $ssp; + my $try = join('/', @parts); + my @try = get($try); + if (isdbg('prefix')) { + my $part = $try[0] || "*"; + $part .= '*' unless $part eq '*' || $part eq $try; + dbg("Compound prefix: $try $part" ); + } +# if (@try == 0) { +# $try = join('/', reverse @parts); +# @try = get($try); +# if (isdbg('prefix')) { +# my $part = $try[0] || "*"; +# $part .= '*' unless $part eq '*' || $part eq $try; +# dbg("Compound prefix: $try $part" ); +# } +# } + if (@try && $try eq $try[0]) { + push @out, @try; + } else { + push @out, @wout; + } + } else { + push @out, @wout; + } + last L1; + } + } } } if (isdbg('prefix')) {