FileLog bug + CUR send

git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@312 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig
2009-01-02 09:32:08 +00:00
parent 578effa978
commit d92967224e
8 changed files with 110 additions and 24 deletions

View File

@@ -228,6 +228,7 @@ FileLog_Get($@)
my %lastdate;
my $d; # Used by eval functions
while(my $l = <$ifh>) {
next if($l lt $from);
last if($l gt $to);
my @fld = split("[ \r\n]+", $l); # 40%
@@ -341,16 +342,28 @@ seekTo($$$$)
my $upper = $fh->tell;
my ($lower, $next, $last) = (0, $upper/2, 0);
my $div = 2;
while() { # Binary search
$fh->seek($next, 0);
my $data = <$fh>;
if($data !~ m/^20\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /) {
if(!$data) {
$last = $next;
last;
}
if($data !~ m/^\d\d\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /) {
$next = $fh->tell;
$data = <$fh>;
if(!$data) {
$last = $next;
last;
}
# If the second line is longer then the first,
# binary search will never get it:
if($next eq $last && $data ge $ts && $div < 8192) {
$last = 0;
$div *= 2;
}
}
if($next eq $last) {
$fh->seek($next, 0);
@@ -359,9 +372,9 @@ seekTo($$$$)
$last = $next;
if(!$data || $data lt $ts) {
($lower, $next) = ($next, ($next+$upper)/2);
($lower, $next) = ($next, int(($next+$upper)/$div));
} else {
($upper, $next) = ($next, ($lower+$next)/2);
($upper, $next) = ($next, int(($lower+$next)/$div));
}
}
$hash->{pos}{"$fname:$ts"} = $last;