X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FRingBuf.pm;h=8a2a836182925c49cc7674517636fd81508bace6;hb=refs%2Fheads%2Fip_address;hp=e9b1052a92f8e42566b02b91aa608c6cd69c7116;hpb=34df1a6ec232291fbe6cb572e9b110795db7d45c;p=spider.git diff --git a/perl/RingBuf.pm b/perl/RingBuf.pm index e9b1052a..8a2a8361 100644 --- a/perl/RingBuf.pm +++ b/perl/RingBuf.pm @@ -3,19 +3,13 @@ # # Copyright (c) - 1998 Dirk Koopman G1TLH # -# $Id$ +# # use strict; package RingBuf; -use vars qw($VERSION $BRANCH); -$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); -$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0)); -$main::build += $VERSION; -$main::branch += $BRANCH; - sub new { @@ -28,7 +22,7 @@ sub new # 3 - start # 4 - pos # 5 - buffer [] - return bless [$size, 0, 0, 0, 0, []], (ref $pkg || $pkg); + return bless [$size+1, 0, 0, 0, 0, []], (ref $pkg || $pkg); } sub write @@ -37,10 +31,7 @@ sub write $self->[5]->[$self->[2]++] = shift; $self->[2] = 0 if $self->[2] >= $self->[0]; - if ($self->[1] < $self->[0]) { - $self->[1] = ++$self->[1]; - } - $self->[2] = $self->[2]; + $self->[1]++ if $self->[1] < $self->[0]; if ($self->[1] == $self->[0] && $self->[2] == $self->[3]) { $self->[3] = $self->[2]+1; $self->[3] = 0 if $self->[3] >= $self->[0];