Skip to content

Commit 1aa58cf

Browse files
committed
Merge pull request #4 from sasezaki/master
Remove PHP 4.3 namespaced StateParser
2 parents c6d3c0a + dc20436 commit 1aa58cf

3 files changed

Lines changed: 24 additions & 79 deletions

File tree

src/Diggin/HTMLSax/HTMLSax.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
namespace Diggin\HTMLSax;
55

6-
use Diggin\HTMLSax\StateParser\Gtet430;
76

87
/* vim: set expandtab tabstop=4 shiftwidth=4: */
98
//
@@ -69,7 +68,7 @@ class HTMLSax {
6968
* @access public
7069
*/
7170
function __construct() {
72-
$this->state_parser = new Gtet430($this);
71+
$this->state_parser = new StateParser($this);
7372

7473
$nullhandler = new NullHandler();
7574
$this->set_object($nullhandler);

src/Diggin/HTMLSax/StateParser.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ function __construct ($htmlsax) {
139139
$this->State[StateInterface::STATE_PI] = new PiState();
140140
$this->State[StateInterface::STATE_JASP] = new JaspState();
141141
$this->State[StateInterface::STATE_ESCAPE] = new EscapeState();
142+
143+
$this->parser_options['XML_OPTION_TRIM_DATA_NODES'] = 0;
144+
$this->parser_options['XML_OPTION_CASE_FOLDING'] = 0;
145+
$this->parser_options['XML_OPTION_LINEFEED_BREAK'] = 0;
146+
$this->parser_options['XML_OPTION_TAB_BREAK'] = 0;
147+
$this->parser_options['XML_OPTION_ENTITIES_PARSED'] = 0;
148+
$this->parser_options['XML_OPTION_ENTITIES_UNPARSED'] = 0;
149+
$this->parser_options['XML_OPTION_STRIP_ESCAPES'] = 0;
142150
}
143151

144152
/**
@@ -187,22 +195,28 @@ function scanUntilString($string) {
187195
}
188196

189197
/**
190-
* Returns a string from the current position until the first instance of
191-
* one of the characters in the supplied string argument
192-
* @param string string to search until
193-
* @access protected
194-
* @return string
195-
* @abstract
196-
*/
197-
function scanUntilCharacters($string) {}
198+
* Returns a string from the current position until the first instance of
199+
* one of the characters in the supplied string argument.
200+
* @param string string to search until
201+
* @access protected
202+
* @return string
203+
*/
204+
function scanUntilCharacters($string) {
205+
$startpos = $this->position;
206+
$length = strcspn($this->rawtext, $string, $startpos);
207+
$this->position += $length;
208+
return substr($this->rawtext, $startpos, $length);
209+
}
198210

199211
/**
200212
* Moves the position forward past any whitespace characters
201213
* @access protected
202214
* @return void
203215
* @abstract
204216
*/
205-
function ignoreWhitespace() {}
217+
function ignoreWhitespace() {
218+
$this->position += strspn($this->rawtext, " \n\r\t", $this->position);
219+
}
206220

207221
/**
208222
* Begins the parsing operation, setting up any decorators, depending on

src/Diggin/HTMLSax/StateParser/Gtet430.php

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)