8000 Add method on InputStream to get all chars to EOF (this will allow us… · Nimbleworks/html5lib-php@232fc09 · GitHub
[go: up one dir, main page]

Skip to content

Commit 232fc09

Browse files
committed
Add method on InputStream to get all chars to EOF (this will allow us to re-optimize PLAINTEXT). Also we want to check that iconv extension is loaded, not that there is a function of that name.
1 parent 8e6d677 commit 232fc09

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

library/HTML5/InputStream.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct($data) {
7171
// We previously had an mbstring implementation here, but that
7272
// implementation is heavily non-conforming, so it's been
7373
// omitted.
74-
if (function_exists('iconv')) {
74+
if (extension_loaded('iconv')) {
7575
// non-conforming
7676
$data = iconv('UTF-8', 'UTF-8//IGNORE', $data);
7777
} else {
@@ -220,18 +220,14 @@ public function char() {
220220
}
221221

222222
/**
223-
* Return some range of characters.
223+
* Get all characters until EOF.
224224
* @note This performs bounds checking
225-
* @param $l Length
226225
*/
227-
public function chars($l = 1) {
228-
if((int) $l > 0 && $this->char < $this->EOF) {
229-
$this->char += $l;
230-
if($l === 1) {
231-
return $this->data[$this->char];
232-
} else {
233-
return substr($this->data, $this->char, $l);
234-
}
226+
public function remainingChars() {
227+
if($this->char < $this->EOF) {
228+
$data = substr($this->data, $this->char);
229+
$this->char = $this->EOF;
230+
return $data;
235231
} else {
236232
return false;
237233
}

0 commit comments

Comments
 (0)
0