take care of php-warning on str_repeat (second param has to be greater or equal to 0)

This commit is contained in:
Klaus Leithoff 2012-07-31 11:03:17 +00:00
parent b140ea5093
commit 44d80c2476

View File

@ -412,7 +412,7 @@ $t = $t[0];
if($t == '< '){return '&lt; ';} if($t == '< '){return '&lt; ';}
if($t == '>'){return '&gt;';} if($t == '>'){return '&gt;';}
if(!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)){ if(!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)){
//error_log(__METHOD__.__LINE__.' Keep Bad:'.$C['keep_bad'].'->'.array2string($t)); error_log(__METHOD__.__LINE__.' Keep Bad:'.$C['keep_bad'].'->'.array2string($t));
//return str_replace(array('<', '>'), array('&lt;', '&gt;'), $t); //return str_replace(array('<', '>'), array('&lt;', '&gt;'), $t);
return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : ''); return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('&lt;', '&gt;'), $t) : '');
}elseif(!isset($C['elements'][($e = strtolower($m[2]))])){ }elseif(!isset($C['elements'][($e = strtolower($m[2]))])){
@ -664,11 +664,11 @@ for($i=-1, $j=count($t); ++$i<$j;){
$y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0); $y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0);
$e = "<$e>"; $e = "<$e>";
if(isset($d[$y])){ if(isset($d[$y])){
if(!$x){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);} if(!$x){echo "\n", str_repeat($s, (--$n>=0?$n:0)), "$e\n", str_repeat($s, ($n>=0?$n:0));}
else{echo "\n", str_repeat($s, $n), "$e\n", str_repeat($s, ($x != 1 ? ++$n : $n));} else{echo "\n", str_repeat($s, ($n>=0?$n:0)), "$e\n", str_repeat($s, ($x != 1 ? (++$n>=0?$n:0) : ($n>=0?$n:0)));}
echo ltrim($r); continue; echo ltrim($r); continue;
} }
$f = "\n". str_repeat($s, $n); $f = "\n". str_repeat($s, ($n>=0?$n:0));
if(isset($c[$y])){ if(isset($c[$y])){
if(!$x){echo $e, $f, ltrim($r);} if(!$x){echo $e, $f, ltrim($r);}
else{echo $f, $e, $r;} else{echo $f, $e, $r;}