On 7/17/05, Tony Bowden <tony-LhsUWLkCAQ8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> wrote:
> On Sat, Jul 16, 2005 at 11:55:36PM +0100, Minty wrote:
> > Attached is a tarball with seperate diffs for each file.
>
> - $prox->write_vint($pos - $last_pos);
> + my $val = $pos - $last_pos;
> + if ($val < 0) { $val = 0; } # pack will barf on negative numbers.
> + push(@proxs, $val);
>
> This scares me a little. Was that 'if' added because something was
> falling over, or is it purely defensive? Can $pos be less than $last_pos
> here? If so this looks like a symptom of a bug that I'd rather fix than
> paper over...
Heehee! A sunday afternoon classic.
DocumentWriter.pm : sub _write_postings
my $f = $posting->freq; # 0....n
my $positions = $posting->positions; # where $positions is an array ref
for my $j (0 .. $f) {
# arrays are indexed 0 through n-1
BEGIN PATCH
--- DocumentWriter.pm 2005-07-17 14:33:37.000000000 +0100
+++ patched.DocumentWriter.pm 2005-07-17 14:33:34.000000000 +0100
@@ -145,7 +145,7 @@
}
my $last_pos = 0;
my $positions = $posting->positions;
- for my $j (0 .. $f) {
+ for my $j (0 .. $f - 1) {
my $pos = $positions->[$j] || 0;
$prox->write_vint($pos - $last_pos);
$last_pos = $pos;
END PATCH
|