Commit 1ddf657e authored by Nils Goroll's avatar Nils Goroll

parse multiple db files, include filenames and checksums in boilerplate

parent 9ffcf56a
...@@ -315,8 +315,8 @@ EOF ...@@ -315,8 +315,8 @@ EOF
$dbboilerplate =~ s/^\s*\*?/ */mog; $dbboilerplate =~ s/^\s*\*?/ */mog;
_VCL($out, VCL_TOP, <<'EOF'); _VCL($out, VCL_TOP, <<'EOF');
* the contents of this file have been generated from a database file which * the contents of this file have been generated from database files which
* included the following notice: * included the following notices:
* *
EOF EOF
_VCL($out, VCL_TOP, $dbboilerplate); _VCL($out, VCL_TOP, $dbboilerplate);
...@@ -605,11 +605,13 @@ GetOptions ('key=s' => \$opt{key}, ...@@ -605,11 +605,13 @@ GetOptions ('key=s' => \$opt{key},
# remaining arguments are db files # remaining arguments are db files
my @dbrefs; my @dbrefs;
my @dbnames;
my @dbchecksums; my @dbchecksums;
foreach my $f (@ARGV) { foreach my $f (@ARGV) {
my ($dbref, $dbchecksum) = load_classifier_db($f, $opt{key}); my ($dbref, $dbchecksum) = load_classifier_db($f, $opt{key});
push @dbrefs, ($dbref); push @dbrefs, ($dbref);
push @dbnames, ($f);
push @dbchecksums, ($dbchecksum); push @dbchecksums, ($dbchecksum);
} }
...@@ -703,48 +705,59 @@ my %special_entries; ...@@ -703,48 +705,59 @@ my %special_entries;
## build @entries, except that not all fields are filled ## build @entries, except that not all fields are filled
my %subkeys_count; my %subkeys_count;
my $dbchecksum = join(", ", @dbchecksums); my $dbchecksum = join(", ", @dbchecksums);
my $dbboilerplate = "checksum ".$dbchecksum."\n"; my $dbboilerplate = " ** checksums ".$dbchecksum."\n *\n";
foreach (split(/[\n\r\f]/, ${$dbrefs[0]})) {
if (/^\s*#/) {
$dbboilerplate .= $_."\n";
next;
}
my ($key, $type) = split(/\t/, $_); for (my $i = 0; $i <= $#dbrefs; $i++) {
my $dbref = $dbrefs[$i];
die "empty key on line ".$line $dbboilerplate .=
unless (defined($key) && ($key ne "")); " *\n".
die "empty type on line ".$line " ******\n".
unless (defined($type) && ($type ne "")); ' ** file '.$dbnames[$i].
' checksum '.$dbchecksums[$i]."\n";
$key = lc($key); foreach (split(/[\n\r\f]/, $$dbref)) {
if (/^\s*#/) {
$dbboilerplate .= $_."\n";
next;
}
# remove any subkey which is wholly contained in another subkey my ($key, $type) = split(/\t/, $_);
# sort reverse by length, only remove shorter ones
my @sks; die "empty key on line ".$line
{ unless (defined($key) && ($key ne ""));
my @skss = (sort { length($b) <=> length($a) } split(/\*/, $key)); die "empty type on line ".$line
skss: unless (defined($type) && ($type ne ""));
for (my $i = 0; $i <= $#skss; $i++) {
for (my $j = 0; $j <= $#sks; $j++) { $key = lc($key);
if (index($sks[$j], $skss[$i]) != -1) {
next skss; # remove any subkey which is wholly contained in another subkey
# sort reverse by length, only remove shorter ones
my @sks;
{
my @skss = (sort { length($b) <=> length($a) } 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;
}
} }
push @sks, ($skss[$i]);
$subkeys_count{$skss[$i]}++;
} }
push @sks, ($skss[$i]);
$subkeys_count{$skss[$i]}++;
} }
}
my @e; my @e;
$e[ENTRY_ID] = $line; $e[ENTRY_ID] = $line;
$e[ENTRY_ORDER] = $line; $e[ENTRY_ORDER] = $line;
$e[ENTRY_ACTIVE] = 0; $e[ENTRY_ACTIVE] = 0;
$e[ENTRY_TYPE] = type_enum($type); $e[ENTRY_TYPE] = type_enum($type);
$e[ENTRY_KEY] = \$key; $e[ENTRY_KEY] = \$key;
$e[ENTRY_SUBKEYS] = \@sks; $e[ENTRY_SUBKEYS] = \@sks;
$e[ENTRY_INITMASK] = 0; $e[ENTRY_INITMASK] = 0;
$entries[$line++] = \@e; $entries[$line++] = \@e;
}
} }
# value is bitmask # value is bitmask
......
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