Properly highlight hex and binary numeric literals
timw4mail/php-kilo/pipeline/head There was a failure building this commit Details

This commit is contained in:
Timothy Warren 2021-04-15 13:18:41 -04:00
parent c928be2d73
commit ad90dcc775
1 changed files with 5 additions and 5 deletions

View File

@ -306,7 +306,7 @@ class Row {
if ($i < strlen($this->render))
{
$nextChar = $this->render[$i];
if ($nextChar !== '.' && ! is_digit($nextChar))
if (stripos('abcdefx.1234567890', $nextChar) === FALSE)
{
return true;
}
@ -469,15 +469,15 @@ class Row {
*/
protected function highlightCharacter(int &$i, Syntax $opts): bool
{
if (($i + 1) >= $this->rsize)
$char = $this->render[$i];
if (($i + 1) >= $this->rsize || $char !== "'")
{
return false;
}
$char = $this->render[$i];
$nextChar = $this->render[$i + 1];
if ($opts->characters() && $char === "'")
if ($opts->characters())
{
$offset = ($nextChar === '\\') ? $i + 3 : $i + 1;
$closingIndex = strpos($this->render, "'", $offset);