line |
true |
false |
branch |
33
|
0 |
20 |
unless (eval {
do {
require Digest::SHA;
'Digest::SHA'->import('sha1');
1
}
})
|
100
|
79 |
56 |
if (exists $self->{'has_dbm_module'})
|
139
|
133 |
14 |
unless ($self->HAS_DBM_MODULE)
|
146
|
2 |
12 |
if $self->{'already_tied'} and $self->{'is_locked'} == 0
|
149
|
0 |
12 |
unless (defined $main->{'conf'}{'bayes_path'})
|
160
|
4 |
16 |
if (-f $path . '_toks' . $ext)
|
166
|
8 |
4 |
unless ($found)
|
180
|
1 |
7 |
unless (tie %{$$self{$db_var};}, $self->DBM_MODULE, $name, 0, oct $main->{'conf'}{'bayes_file_mode'} & 438)
|
188
|
1 |
0 |
if ($dbname eq 'seen') { }
|
192
|
0 |
1 |
unless tie %{$$self{$db_var};}, $self->DBM_MODULE, $name, 66, oct $main->{'conf'}{'bayes_file_mode'} & 438
|
205
|
0 |
4 |
if ($self->_check_db_version != 0)
|
218
|
0 |
0 |
unless exists $self->{$db_var}
|
232
|
2 |
28 |
unless ($self->HAS_DBM_MODULE)
|
242
|
2 |
26 |
if ($self->{'already_tied'} and $self->{'is_locked'} == 1)
|
247
|
0 |
26 |
unless (defined $main->{'conf'}{'bayes_path'})
|
258
|
22 |
8 |
if (-f $path . '_toks' . $ext)
|
265
|
0 |
26 |
unless (-d $parentdir)
|
273
|
0 |
26 |
if ($main->{'learn_wait_for_lock'}) { }
|
278
|
26 |
0 |
if ($main->{'locker'}->safe_lock($path, $tout, $main->{'conf'}{'bayes_file_mode'})) { }
|
293
|
0 |
52 |
if $self->DBM_MODULE eq 'DB_File'
|
299
|
0 |
52 |
unless tie %{$$self{$db_var};}, $self->DBM_MODULE, $name, 66, oct $main->{'conf'}{'bayes_file_mode'} & 438
|
307
|
22 |
4 |
if $found
|
313
|
0 |
26 |
if ($found and not $self->_upgrade_db) { }
|
|
4 |
22 |
elsif (not $found) { }
|
332
|
0 |
0 |
unless exists $self->{$db_var}
|
337
|
0 |
0 |
if ($self->{'is_locked'})
|
362
|
22 |
0 |
if $verschk == 0
|
365
|
0 |
0 |
if ($verschk == 1)
|
384
|
0 |
0 |
if (-f $jpath)
|
386
|
0 |
0 |
unless unlink $jpath
|
389
|
0 |
0 |
if ($self->{'db_version'} < 2)
|
397
|
0 |
0 |
if ($self->{'db_version'} == 0) { }
|
429
|
0 |
0 |
unless $res
|
448
|
0 |
0 |
if $tok =~ /^(?:\*\*[A-Z]+$|\015\001\007\011\003)/
|
454
|
0 |
0 |
if ($count++ % 1000 == 0)
|
468
|
0 |
0 |
unless am_running_on_windows()
|
472
|
0 |
0 |
if (-f $msgc)
|
474
|
0 |
0 |
unless (unlink $msgc)
|
483
|
0 |
0 |
unless -f $newf
|
484
|
0 |
0 |
unless (rename $newf, $oldf)
|
497
|
0 |
0 |
unless $res
|
506
|
0 |
0 |
if ($self->{'db_version'} == 2)
|
530
|
0 |
0 |
unless $res
|
548
|
0 |
0 |
if $tok =~ /^\015\001\007\011\003/
|
553
|
0 |
0 |
if ($count++ % 1000 == 0)
|
566
|
0 |
0 |
unless am_running_on_windows()
|
572
|
0 |
0 |
unless -f $newf
|
573
|
0 |
0 |
unless (rename $newf, $oldf)
|
586
|
0 |
0 |
unless $res
|
609
|
39 |
30 |
unless $self->{'already_tied'}
|
616
|
56 |
4 |
if (exists $self->{$db_var})
|
623
|
26 |
4 |
if ($self->{'is_locked'})
|
643
|
0 |
0 |
if $tok =~ /^\015\001\007\011\003/
|
651
|
0 |
0 |
if ($token_age >= $start * $i) { }
|
697
|
0 |
0 |
if ($showdots)
|
709
|
0 |
0 |
if $tok =~ /^\015\001\007\011\003/
|
713
|
0 |
0 |
if ($atime < $too_old) { }
|
718
|
0 |
0 |
if ($atime > $vars[10])
|
723
|
0 |
0 |
if (not defined $oldest or $atime < $oldest)
|
724
|
0 |
0 |
if ($ts + $th == 1) { }
|
|
0 |
0 |
elsif ($ts < 8 and $th < 8) { }
|
731
|
0 |
0 |
if (($kept + $deleted) % 1000 == 0)
|
732
|
0 |
0 |
if ($showdots)
|
754
|
0 |
0 |
if ($kept < 100000) { }
|
782
|
0 |
0 |
unless am_running_on_windows()
|
788
|
0 |
0 |
unless -f $newf
|
789
|
0 |
0 |
unless (rename $newf, $oldf)
|
809
|
0 |
10 |
if $self->{'db_version'} < $self->DB_VERSION
|
812
|
0 |
10 |
if $conf->{'bayes_journal_max_size'} == 0
|
821
|
6 |
4 |
unless stat $self->_get_journal_filename and -f _
|
824
|
0 |
4 |
if -s _ > $conf->{'bayes_journal_max_size'}
|
828
|
0 |
4 |
if $vars[7] > 0 and time - $vars[7] > 86400
|
845
|
2 |
4 |
if ($self->{'bayes'}{'main'}{'learn_to_journal'}) { }
|
860
|
0 |
4 |
if ($self->{'bayes'}{'main'}{'learn_to_journal'}) { }
|
910
|
4 |
60 |
if (not $db_ver or $db_ver =~ /\D/)
|
912
|
60 |
4 |
if ($db_ver >= 2) { }
|
|
4 |
0 |
elsif ($db_ver == 0) { }
|
|
0 |
0 |
elsif ($db_ver == 1) { }
|
984
|
414 |
290 |
if (not $_ or $_ =~ /\D/)
|
996
|
0 |
0 |
if $tok =~ /^\015\001\007\011\003/
|
997
|
0 |
0 |
if defined $regex and not $tok =~ /$regex/o
|
1021
|
10 |
0 |
if (not $running or $running =~ /\D/)
|
1046
|
0 |
0 |
unless defined $atime
|
1048
|
0 |
0 |
if ($self->{'bayes'}{'main'}{'learn_to_journal'}) { }
|
1061
|
4 |
6 |
unless defined $atime
|
1064
|
554 |
2216 |
if ($self->{'bayes'}{'main'}{'learn_to_journal'}) { }
|
1084
|
2 |
8 |
if ($self->{'bayes'}{'main'}{'learn_to_journal'}) { }
|
1121
|
8 |
6 |
if $nbytes == 0
|
1132
|
0 |
6 |
unless (open OUT, '>>' . $path)
|
1144
|
0 |
6 |
unless $original_point >= 0
|
1150
|
0 |
6 |
if (not defined $len or $len < 0)
|
1152
|
0 |
0 |
unless (defined $len)
|
1161
|
0 |
6 |
if ($len != $nbytes)
|
1167
|
0 |
0 |
if (not truncate(OUT, $original_point) or $write_failure++ > 4)
|
1177
|
0 |
6 |
unless (close OUT)
|
1188
|
532 |
0 |
if (not defined $self->{'db_version'} or $self->{'db_version'} >= 1)
|
1215
|
0 |
2 |
if (not stat $path && -f _ or -z _)
|
1222
|
2 |
0 |
if ($self->tie_db_writable)
|
1226
|
0 |
2 |
unless (eval {
do {
local $SIG{'__DIE__'};
if ($self->tie_db_writable) {
$ret = $self->_sync_journal_trapped($opts, $path);
};
1
}
})
|
1227
|
0 |
0 |
$@ ne '' ? :
|
1231
|
2 |
0 |
unless ($self->{'bayes'}{'main'}{'learn_caller_will_untie'})
|
1236
|
0 |
2 |
if (defined $eval_stat)
|
1260
|
0 |
2 |
if (not stat $path && -f _ or -z _)
|
1264
|
0 |
2 |
unless (-r $path)
|
1274
|
2 |
0 |
unless am_running_on_windows()
|
1278
|
0 |
2 |
unless (rename $path, $retirepath)
|
1285
|
0 |
2 |
unless (open JOURNAL, "<$retirepath")
|
1295
|
0 |
558 |
if (/^t (\d+) (.+)$/) { }
|
|
554 |
4 |
elsif (/^c (-?\d+) (-?\d+) (\d+) (.+)$/) { }
|
|
2 |
2 |
elsif (/^n (-?\d+) (-?\d+)$/) { }
|
|
2 |
0 |
elsif (/^m ([hsf]) (.+)$/) { }
|
1297
|
0 |
0 |
if not exists $tokens{$tok} or $1 + 0 > $tokens{$tok}
|
1306
|
0 |
2 |
if ($1 eq 'f') { }
|
1317
|
0 |
0 |
$! == 9 ? :
|
|
0 |
2 |
unless defined $_ or $! == 0
|
1320
|
0 |
2 |
unless close JOURNAL
|
1328
|
0 |
0 |
if (++$count % 1000 == 0)
|
1329
|
0 |
0 |
if ($showdots)
|
1334
|
0 |
2 |
if ($showdots)
|
1337
|
0 |
2 |
unless unlink $retirepath
|
1346
|
0 |
2 |
if ($opts->{'verbose'}) { }
|
1364
|
0 |
0 |
if $oldatime >= $atime
|
1372
|
0 |
2770 |
if ($ts < 0)
|
1373
|
0 |
2770 |
if ($th < 0)
|
1376
|
1108 |
1662 |
if $oldatime > $atime
|
1387
|
0 |
2770 |
if $tok =~ /^\015\001\007\011\003/
|
1394
|
1108 |
1662 |
if ($ts == 0 and $th == 0) { }
|
1395
|
0 |
1108 |
unless $exists_already
|
1399
|
1662 |
0 |
unless ($exists_already)
|
1406
|
4 |
1658 |
if (not defined $newmagic or $atime > $newmagic)
|
1413
|
4 |
1658 |
if (not defined $oldmagic or $oldmagic eq '' or $atime < $oldmagic)
|
1422
|
6 |
4 |
if ($ds)
|
|
0 |
10 |
if ($ns < 0)
|
1423
|
4 |
6 |
if ($dh)
|
|
0 |
10 |
if ($nh < 0)
|
1459
|
0 |
0 |
unless opendir DIR, $dir
|
1461
|
0 |
0 |
unless closedir DIR
|
1462
|
0 |
0 |
if (@files < 2 or not grep(/bayes_seen/, @files) or not grep(/bayes_toks/, @files))
|
1472
|
0 |
0 |
unless eval "\n use File::Copy;\n copy(\$src, \$dst);\n "
|
1482
|
0 |
0 |
if ($self->tie_db_writable)
|
1489
|
0 |
0 |
if ($ret == 2) { }
|
1496
|
0 |
0 |
unless (eval {
do {
local $SIG{'__DIE__'};
my $main = $self->{'bayes'}{'main'};
my $path = $main->sed_path($main->{'conf'}{'bayes_path'});
local($1, $2, $3);
my $dir = dirname($path);
die "bayes: can't opendir ${dir}: $!" unless opendir DIR, $dir;
my(@files) = grep({/^bayes_(?:seen|toks)(?:\.\w+)?$/;} readdir DIR);
die "bayes: can't close directory ${dir}: $!" unless closedir DIR;
if (@files < 2 or not grep(/bayes_seen/, @files) or not grep(/bayes_toks/, @files)) {
die "bayes: unable to find bayes_toks and bayes_seen, stopping\n";
};
untaint_var(\@files);
foreach $_ (@files) {
my $src = "$dir/$_";
my $dst = "$dir/old_$_";
die "bayes: can't copy $src to ${dst}: $!\n" unless eval "\n use File::Copy;\n copy(\$src, \$dst);\n ";
};
foreach $_ (@files) {
unlink "$dir/$_";
};
if ($self->tie_db_writable) {
$ret += $self->upgrade_old_dbm_files_trapped("$dir/old_bayes_seen", $self->{'db_seen'});
$ret += $self->upgrade_old_dbm_files_trapped("$dir/old_bayes_toks", $self->{'db_toks'});
};
if ($ret == 2) {
print qq[import successful, original files saved with "old" prefix\n];
}
else {
print qq[import failed, original files saved with "old" prefix\n];
};
1
}
})
|
1497
|
0 |
0 |
$@ ne '' ? :
|
1503
|
0 |
0 |
if (defined $eval_stat)
|
1532
|
0 |
0 |
unless (eval 'use ' . $dbm . qq[;\n tie %in, "] . $dbm . qq[", \$filename, O_RDONLY, 0600;\n %{ \$output } = %in;\n \$count = scalar keys %{ \$output };\n untie %in;\n 1;\n ])
|
1533
|
0 |
0 |
$@ ne '' ? :
|
1535
|
0 |
0 |
if (defined $eval_stat) { }
|
|
0 |
0 |
elsif ($count == 0) { }
|
1554
|
0 |
2 |
unless $self->tie_db_writable
|
1561
|
4 |
0 |
if (exists $self->{$db_var})
|
1574
|
8 |
4 |
$ret ? :
|
1583
|
2 |
0 |
$ret ? :
|
1596
|
0 |
0 |
unless $self->tie_db_writable
|
1605
|
0 |
0 |
if $tok =~ /^\015\001\007\011\003/
|
1625
|
0 |
0 |
unless (open DUMPFILE, '<', $filename)
|
1630
|
0 |
0 |
unless ($self->tie_db_writable)
|
1649
|
0 |
0 |
unless (tie %new_toks, $self->DBM_MODULE, $tmptoksdbname, 194, oct $main->{'conf'}{'bayes_file_mode'} & 438)
|
1656
|
0 |
0 |
unless (tie %new_seen, $self->DBM_MODULE, $tmpseendbname, 194, oct $main->{'conf'}{'bayes_file_mode'} & 438)
|
1680
|
0 |
0 |
unless defined $line
|
1686
|
0 |
0 |
if ($line =~ /^v\s+(\d+)\s+db_version/) { }
|
1699
|
0 |
0 |
unless ($db_version == 2 or $db_version == 3)
|
1713
|
0 |
0 |
if ($line_count % 1000 == 0)
|
1714
|
0 |
0 |
if $showdots
|
1717
|
0 |
0 |
if ($line =~ /^v\s+/) { }
|
|
0 |
0 |
elsif ($line =~ /^t\s+/) { }
|
|
0 |
0 |
elsif ($line =~ /^s\s+/) { }
|
1720
|
0 |
0 |
if ($parsed_line[2] eq 'num_spam') { }
|
|
0 |
0 |
elsif ($parsed_line[2] eq 'num_nonspam') { }
|
1740
|
0 |
0 |
if ($spam_count < 0)
|
1745
|
0 |
0 |
if ($ham_count < 0)
|
1751
|
0 |
0 |
if ($spam_count == 0 and $ham_count == 0)
|
1756
|
0 |
0 |
if ($atime > time)
|
1762
|
0 |
0 |
if ($token_warn_p)
|
1768
|
0 |
0 |
if ($db_version < 3) { }
|
1777
|
0 |
0 |
if ($atime < $oldest_token_age)
|
1780
|
0 |
0 |
if ($atime > $newest_token_age)
|
1790
|
0 |
0 |
unless ($flag eq 'h' or $flag eq 's')
|
1795
|
0 |
0 |
unless ($msgid)
|
1807
|
0 |
0 |
unless defined $line or $! == 0
|
1808
|
0 |
0 |
unless close DUMPFILE
|
1810
|
0 |
0 |
if $showdots
|
1812
|
0 |
0 |
unless (defined $num_spam)
|
1817
|
0 |
0 |
unless (defined $num_ham)
|
1822
|
0 |
0 |
if ($error_p)
|
1849
|
0 |
0 |
unless am_running_on_windows()
|
1859
|
0 |
0 |
unless ($self->_rename_file($tmptoksdbname, $toksdbname))
|
1863
|
0 |
0 |
unless ($self->_rename_file($tmpseendbname, $seendbname))
|
1905
|
5536 |
0 |
if ($self->{'db_version'} >= 1) { }
|
|
0 |
0 |
elsif ($self->{'db_version'} == 0) { }
|
1912
|
3134 |
2402 |
if (($packed & 192) == 192) { }
|
|
2402 |
0 |
elsif (($packed & 192) == 0) { }
|
1919
|
2402 |
0 |
if ($self->{'db_version'} >= 1) { }
|
|
0 |
0 |
elsif ($self->{'db_version'} == 0) { }
|
1937
|
1662 |
0 |
if ($ts < 8 and $th < 8) { }
|
1967
|
0 |
0 |
unless rename $sourcefilename, $targetfilename
|