diff options
author | Kevin Chabowski <kevin@kch42.de> | 2012-02-21 01:08:38 +0100 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2012-02-21 01:08:38 +0100 |
commit | 4bf14ccb74174e319fb370e656018a6b8bad0e0e (patch) | |
tree | e39461948d8b82e4a4096c6a6e847bd7b832ca43 /stupid_template_engine.php | |
parent | 8e35fad33de1fbecea7c29776f7afab6a4b88a48 (diff) | |
download | ste-4bf14ccb74174e319fb370e656018a6b8bad0e0e.tar.gz ste-4bf14ccb74174e319fb370e656018a6b8bad0e0e.tar.bz2 ste-4bf14ccb74174e319fb370e656018a6b8bad0e0e.zip |
Fixed some error message bugs.
* Very often the error offsets of parsing errors were too high.
* The offset to line translation now works cleaner and should no longer
throw PHP errors.
Diffstat (limited to 'stupid_template_engine.php')
-rw-r--r-- | stupid_template_engine.php | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/stupid_template_engine.php b/stupid_template_engine.php index 48164c1..d6fe98c 100644 --- a/stupid_template_engine.php +++ b/stupid_template_engine.php @@ -82,7 +82,7 @@ class ParseCompileError extends \Exception public function rewrite($code) { - $line = substr_count(str_replace("\r\n", "\n", $code), "\n", 0, $this->off + 1) + 1; + $line = substr_count(str_replace("\r\n", "\n", substr($code, 0, $this->off)), "\n") + 1; $this->message = "{$this->msg} (Template {$this->tpl}, Line $line)"; $this->is_rewritten = True; } @@ -270,7 +270,7 @@ function mk_ast($code, $tpl, $err_off) $off = 0; $last_tag_start = 0; - $tagstack = array(array($tag->name, $tag->offset)); + $tagstack = array(array($tag->name, $tag->offset - $err_off)); while(preg_match("/\\<((?:\\s*)|(?:\\s*\\/\\s*))ste:([a-zA-Z0-9_]*)(?:\\s+(?:[a-zA-Z0-9_]+)=(?:(?:\"(?:.*?)(?<!\\\\)\")|(?:'(?:.*?)(?<!\\\\)')))*((?:\\s*)|(?:\\s*\\/\\s*))\\>/s", $code, $matches, PREG_OFFSET_CAPTURE, $off) > 0) /* RegEx from hell! Matches all <ste:> Tags. Opening, closing and self-closing ones. */ { if(trim($matches[3][0]) != "/") @@ -1317,4 +1317,4 @@ class STEStandardLibrary } } -?> +?>
\ No newline at end of file |