+my %_versionobj;
+sub buggyversion {
+ my ($bug, $ver, $status) = @_;
+ return '' unless defined $gVersionPackagesDir;
+ my $src = getpkgsrc()->{$status->{package}};
+ $src = $status->{package} unless defined $src;
+
+ my $tree;
+ if (exists $_versionobj{$src}) {
+ $tree = $_versionobj{$src};
+ } else {
+ $tree = Debbugs::Versions->new(\&DpkgVer::vercmp);
+ if (open VERFILE, "< $gVersionPackagesDir/$src") {
+ $tree->load(\*VERFILE);
+ close VERFILE;
+ }
+ $_versionobj{$src} = $tree;
+ }
+
+ return $tree->buggy($ver, $status->{found_versions},
+ $status->{fixed_versions});
+}
+
+my %_versions;
+sub getversion {
+ my ($pkg, $dist, $arch) = @_;
+ return undef unless defined $gVersionIndex;
+ $dist = 'unstable' unless defined $dist;
+ $arch = 'i386' unless defined $arch;
+
+ unless (tied %_versions) {
+ tie %_versions, 'MLDBM', $gVersionIndex, O_RDONLY
+ or die "can't open versions index: $!";
+ }
+
+ return $_versions{$pkg}{$dist}{$arch};
+}
+