mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-07 16:59:18 +00:00
Fixing bug, when the logfile consists of one line only. Reported by Schuggi
git-svn-id: https://svn.fhem.de/fhem/trunk@3241 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
782494fbb4
commit
c31bf880ac
@ -619,6 +619,25 @@ RESCAN:
|
|||||||
return ($outf eq "-") ? $ret : join(" ", @fname);
|
return ($outf eq "-") ? $ret : join(" ", @fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###############
|
||||||
|
# this is not elegant
|
||||||
|
sub
|
||||||
|
seekBackOneLine($$)
|
||||||
|
{
|
||||||
|
my ($fh, $pos) = @_;
|
||||||
|
my $buf;
|
||||||
|
$pos -= 2; # skip current CR/NL
|
||||||
|
$fh->seek($pos, 0);
|
||||||
|
while($pos > 0 && $fh->read($buf, 1)) {
|
||||||
|
if($buf eq "\n" || $buf eq "\r") {
|
||||||
|
$fh->seek(++$pos, 0);
|
||||||
|
return $pos;
|
||||||
|
}
|
||||||
|
$fh->seek(--$pos, 0);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
sub
|
sub
|
||||||
seekTo($$$$)
|
seekTo($$$$)
|
||||||
@ -647,7 +666,7 @@ seekTo($$$$)
|
|||||||
$next = $fh->tell;
|
$next = $fh->tell;
|
||||||
$data = <$fh>;
|
$data = <$fh>;
|
||||||
if(!$data) {
|
if(!$data) {
|
||||||
$last = $next;
|
$last = seekBackOneLine($fh, $next);
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,11 +256,13 @@ wl_getRegFromFile($)
|
|||||||
$fh->seek(0, 2); # Go to the end
|
$fh->seek(0, 2); # Go to the end
|
||||||
my $sz = $fh->tell;
|
my $sz = $fh->tell;
|
||||||
$fh->seek($sz > 65536 ? $sz-65536 : 0, 0);
|
$fh->seek($sz > 65536 ? $sz-65536 : 0, 0);
|
||||||
my $data = <$fh>;
|
my $data;
|
||||||
|
$data = <$fh> if($sz > 65536); # discard the first/partial line
|
||||||
my $maxcols = 0;
|
my $maxcols = 0;
|
||||||
my %h;
|
my %h;
|
||||||
while($data = <$fh>) {
|
while($data = <$fh>) {
|
||||||
my @cols = split(" ", $data);
|
my @cols = split(" ", $data);
|
||||||
|
next if(@cols < 3);
|
||||||
$maxcols = @cols if(@cols > $maxcols);
|
$maxcols = @cols if(@cols > $maxcols);
|
||||||
$cols[2] = "*" if($cols[2] =~ m/^[-\.\d]+$/);
|
$cols[2] = "*" if($cols[2] =~ m/^[-\.\d]+$/);
|
||||||
$h{"$cols[1].$cols[2]"} = $data;
|
$h{"$cols[1].$cols[2]"} = $data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user