Commit 048d14a9 by Nils Goroll

fix subkey substring elemination logic for negative subkeys

This fixes compilation for key

	sogou*!sogoumobilebrowser
parent 15473c01
......@@ -653,6 +653,13 @@ use constant {
MAX_COMMON_SUBKEYS => 32,
};
use constant {
SKSS_KEY => 0,
SKSS_STR => 1, # key without optional !
SKSS_LEN => 2,
SKSS_NEG => 3
};
my %manual_fixup_remove = (
'android 4.0' => 1,
);
......@@ -731,20 +738,60 @@ for (my $i = 0; $i <= $#dbrefs; $i++) {
$key = lc($key);
# remove any subkey which is wholly contained in another subkey
# sort reverse by length, only remove shorter ones
# remove any subkey which is wholly contained in another
# subkey. Depending on which key is positive / negative,
# we remove the redundant one
#
# long | short
# ------------
# pos pos remove short
# pos neg remove long
# neg pos keep
# neg neg remove long
my @sks;
{
my @skss = (sort { length($b) <=> length($a) } split(/\*/, $key));
my @skss = sort {
$b->[SKSS_LEN] <=> $a->[SKSS_LEN]
} map {
my @ee;
$ee[SKSS_KEY] = $_;
if (substr($_, 0, 1) eq "!") {
$ee[SKSS_STR] = substr($ee[SKSS_KEY], 1);
$ee[SKSS_NEG] = 1;
} else {
$ee[SKSS_STR] = $ee[SKSS_KEY];
$ee[SKSS_NEG] = 0;
}
$ee[SKSS_LEN] = length($ee[SKSS_STR]);
\@ee;
} split(/\*/, $key);
skss:
for (my $i = 0; $i <= $#skss; $i++) {
for (my $j = 0; $j <= $#sks; $j++) {
if (index($sks[$j], $skss[$i]) != -1) {
next skss;
next skss unless (defined($skss[$i]));
for (my $j = $i + 1; $j <= $#skss; $j++) {
next unless (defined($skss[$j]));
if (index($skss[$i]->[SKSS_STR],
$skss[$j]->[SKSS_STR]) != -1) {
# j contained in i
if ($skss[$j]->[SKSS_NEG]) {
# remove long == skip adding i
next skss;
}
if ($skss[$i]->[SKSS_NEG]) {
# long neg short pos - keep
} else {
# long pos short pos - remove short
undef($skss[$j]);
}
}
}
push @sks, ($skss[$i]);
$subkeys_count{$skss[$i]}++;
push @sks, ($skss[$i]->[SKSS_KEY]);
$subkeys_count{$skss[$i]->[SKSS_KEY]}++;
}
}
......@@ -855,8 +902,8 @@ sub process_entry($) {
if (scalar(keys %sks_positive) == 0) {
my @common = keys %sks_common;
die 'neither positive nor common subkeys for key '.${$entry->[ENTRY_KEY]}
unless (scalar(@common) > 0);
die 'neither positive nor common subkeys for key '.
${$entry->[ENTRY_KEY]} unless (scalar(@common) > 0);
# choose the common subkey with the lowest count
# (which is the one with the highest value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment