Commit 1ddf657e by Nils Goroll

parse multiple db files, include filenames and checksums in boilerplate

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