Changeset View
Changeset View
Standalone View
Standalone View
externals/pear-figlet/Text/Figlet.php
Context not available. | |||||
$this->font_comment = ''; | $this->font_comment = ''; | ||||
// If Gzip compressed font | // If Gzip compressed font | ||||
if (substr($filename, -3, 3) == '.gz') { | if (@substr($filename, -3, 3) == '.gz') { | ||||
$filename = 'compress.zlib://' . $filename; | $filename = 'compress.zlib://' . $filename; | ||||
$compressed = true; | $compressed = true; | ||||
Context not available. | |||||
// Max_Length Old_Layout | // Max_Length Old_Layout | ||||
$header = explode(' ', fgets($fp, 2048)); | $header = @explode(' ', fgets($fp, 2048)); | ||||
if (substr($header[0], 0, 5) <> 'flf2a') { | if (@substr($header[0], 0, 5) <> 'flf2a') { | ||||
return self::raiseError('Unknown FIGlet font format.', 4); | return self::raiseError('Unknown FIGlet font format.', 4); | ||||
} | } | ||||
@list ($this->hardblank, $this->height,,, | @list ($this->hardblank, $this->height,,, | ||||
$this->oldlayout, $cmt_count, $this->rtol) = $header; | $this->oldlayout, $cmt_count, $this->rtol) = $header; | ||||
$this->hardblank = substr($this->hardblank, -1, 1); | $this->hardblank = @substr($this->hardblank, -1, 1); | ||||
for ($i = 0; $i < $cmt_count; $i++) { | for ($i = 0; $i < $cmt_count; $i++) { | ||||
$this->font_comment .= fgets($fp, 2048); | $this->font_comment .= fgets($fp, 2048); | ||||
Context not available. | |||||
// Extented characters | // Extented characters | ||||
for ($n = 0; !feof($fp); $n++) { | for ($n = 0; !feof($fp); $n++) { | ||||
list ($i) = explode(' ', rtrim(fgets($fp, 1024)), 2); | list ($i) = @explode(' ', rtrim(fgets($fp, 1024)), 2); | ||||
if ($i == '') { | if ($i == '') { | ||||
continue; | continue; | ||||
} | } | ||||
// If comment | // If comment | ||||
if (preg_match('/^\-0x/i', $i)) { | if (@preg_match('/^\-0x/i', $i)) { | ||||
$this->_skip($fp); | $this->_skip($fp); | ||||
} else { | } else { | ||||
// If Unicode | // If Unicode | ||||
if (preg_match('/^0x/i', $i)) { | if (@preg_match('/^0x/i', $i)) { | ||||
$i = hexdec(substr($i, 2)); | $i = hexdec(@substr($i, 2)); | ||||
} else { | } else { | ||||
// If octal | // If octal | ||||
if ($i{0} === '0' && $i !== '0' || substr($i, 0, 2) == '-0') { | if ($i{0} === '0' && $i !== '0' || @substr($i, 0, 2) == '-0') { | ||||
$i = octdec($i); | $i = octdec($i); | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
{ | { | ||||
$out = array(); | $out = array(); | ||||
for ($i = 0; $i<strlen($str); $i++) { | for ($i = 0; $i<@strlen($str); $i++) { | ||||
// Pseudo Unicode support | // Pseudo Unicode support | ||||
if (substr($str, $i, 2) == '%u') { | if (@substr($str, $i, 2) == '%u') { | ||||
$lt = hexdec(substr($str, $i+2, 4)); | $lt = hexdec(@substr($str, $i+2, 4)); | ||||
$i += 5; | $i += 5; | ||||
} else { | } else { | ||||
$lt = ord($str{$i}); | $lt = ord($str{$i}); | ||||
Context not available. | |||||
$mindiff = -1; | $mindiff = -1; | ||||
for ($j = 0; $j < $this->height; $j++) { | for ($j = 0; $j < $this->height; $j++) { | ||||
if (preg_match("/\S(\s*\\x00\s*)\S/", $out[$j], $r)) { | if (@preg_match("/\S(\s*\\x00\s*)\S/", $out[$j], $r)) { | ||||
if ($mindiff == -1) { | if ($mindiff == -1) { | ||||
$mindiff = strlen($r[1]); | $mindiff = @strlen($r[1]); | ||||
} else { | } else { | ||||
$mindiff = min($mindiff, strlen($r[1])); | $mindiff = min($mindiff, @strlen($r[1])); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
if (--$mindiff > 0) { | if (--$mindiff > 0) { | ||||
for ($j = 0; $j < $this->height; $j++) { | for ($j = 0; $j < $this->height; $j++) { | ||||
if (preg_match("/\\x00(\s{0,{$mindiff}})/", $out[$j], $r)) { | if (@preg_match("/\\x00(\s{0,{$mindiff}})/", $out[$j], $r)) { | ||||
$l = strlen($r[1]); | $l = @strlen($r[1]); | ||||
$b = $mindiff - $l; | $b = $mindiff - $l; | ||||
$out[$j] = preg_replace("/\s{0,$b}\\x00\s{{$l}}/", | $out[$j] = preg_replace("/\s{0,$b}\\x00\s{{$l}}/", | ||||
"\0", | "\0", | ||||
Context not available. | |||||
if ($this->oldlayout & 2) { | if ($this->oldlayout & 2) { | ||||
$symb = '|/\\[]{}()<>'; | $symb = '|/\\[]{}()<>'; | ||||
if ($r[1] == '_' && strpos($symb, $r[2]) !== false || | if ($r[1] == '_' && @strpos($symb, $r[2]) !== false || | ||||
$r[2] == '_' && strpos($symb, $r[1]) !== false) { | $r[2] == '_' && @strpos($symb, $r[1]) !== false) { | ||||
$this->smush_flag = 1; | $this->smush_flag = 1; | ||||
return $r[1]; | return $r[1]; | ||||
} | } | ||||
Context not available. | |||||
if ($this->oldlayout & 4) { | if ($this->oldlayout & 4) { | ||||
$classes = '|/\\[]{}()<>'; | $classes = '|/\\[]{}()<>'; | ||||
if (($left = strpos($classes, $r[1])) !== false) { | if (($left = @strpos($classes, $r[1])) !== false) { | ||||
if (($right = strpos($classes, $r[2])) !== false) { | if (($right = @strpos($classes, $r[2])) !== false) { | ||||
$this->smush_flag = 1; | $this->smush_flag = 1; | ||||
return $right > $left ? $r[2] : $r[1]; | return $right > $left ? $r[2] : $r[1]; | ||||
} | } | ||||
Context not available. | |||||
} | } | ||||
$line = rtrim(fgets($fp, 2048), "\r\n"); | $line = rtrim(fgets($fp, 2048), "\r\n"); | ||||
if (preg_match('/(.){1,2}$/', $line, $r)) { | if (@preg_match('/(.){1,2}$/', $line, $r)) { | ||||
$line = str_replace($r[1], '', $line); | $line = str_replace($r[1], '', $line); | ||||
} | } | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0