Making error place routines more robust
This commit is contained in:
parent
8979ac0cc8
commit
c96a08808f
21
bhl.inc.php
21
bhl.inc.php
|
@ -359,21 +359,10 @@ function bhl_clean_cache()
|
|||
|
||||
function bhl_show_position($line, $row, array $lines)
|
||||
{
|
||||
if($line > 0 && $line < count($lines))
|
||||
{
|
||||
$txt = $lines[$line-1];
|
||||
$c = str_repeat('-', $row);
|
||||
return "{$txt}{$c}^";
|
||||
}
|
||||
//weird special case
|
||||
else if($line-1 == count($lines))
|
||||
{
|
||||
$txt = $lines[count($lines)-1];
|
||||
$c = str_repeat('-', $row);
|
||||
return "{$txt}{$c}^";
|
||||
}
|
||||
if($line > 0 && $line <= count($lines))
|
||||
return $lines[$line-1].str_repeat('-', $row)."^";
|
||||
else
|
||||
return "???";
|
||||
return "??? @($line:$row)";
|
||||
}
|
||||
|
||||
function bhl_line_row_to_pos($file, $line, $row)
|
||||
|
@ -381,8 +370,8 @@ function bhl_line_row_to_pos($file, $line, $row)
|
|||
$pos = 0;
|
||||
$lines = file($file);
|
||||
//something went wrong
|
||||
if(count($lines) < $line)
|
||||
return null;
|
||||
if($line <= 0 || $line > count($lines))
|
||||
return null;
|
||||
for($i=0;$i<($line-1);++$i)
|
||||
$pos += strlen($lines[$i]);
|
||||
$pos += $row;
|
||||
|
|
Loading…
Reference in New Issue