From 684122d2efce495b16b7b80107c73d74de195d24 Mon Sep 17 00:00:00 2001 From: vitalif Date: Sun, 21 Apr 2013 21:25:07 +0000 Subject: [PATCH] Skip to directive beginning also if just exited --- template.parser.php | 12 ++++++++---- template.php | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/template.parser.php b/template.parser.php index 10a2936..2fe47e7 100644 --- a/template.parser.php +++ b/template.parser.php @@ -554,13 +554,17 @@ class VMXTemplateLexer try { $parser->reset(); + $in = false; while ($t = $this->read_token()) { $success = $parser->eat($t[0], $t[1]); if (!$success) { - $this->skip_error(end($parser->parser->errors)); + // Pass $in from last step so we skip to the beginning + // of directive even if it just ended and $this->in_* == 0 + $this->skip_error(end($parser->parser->errors), $in); } + $in = $this->in_code || $this->in_subst; } $parser->eat_eof(); } @@ -595,12 +599,12 @@ class VMXTemplateLexer /** * Skip a directive */ - function skip_error($e) + function skip_error($e, $force = false) { if (substr($e, 0, 18) !== 'error not expected') { $this->warn($e); - if ($this->in_code || $this->in_subst) + if ($this->in_code || $this->in_subst || $force) { $this->in_code = $this->in_subst = 0; $this->pos = $this->last_start; @@ -745,7 +749,7 @@ class VMXTemplateLexer } } } - if ($this->in_subst) + elseif ($this->in_subst) { $this->in_subst += ($t === $this->options->begin_subst); $this->in_subst -= ($t === $this->options->end_subst); diff --git a/template.php b/template.php index 31f687e..0458322 100644 --- a/template.php +++ b/template.php @@ -770,7 +770,7 @@ class VMXTemplateOptions implode('
  • ', array_map('html_pbr', $this->errors)). '
  • '; $fp = fopen("php://stderr", 'a'); - fprintf($fp, "VMXTemplate errors:\n".implode("\n", $this->errors)); + fputs($fp, "VMXTemplate errors:\n".implode("\n", $this->errors)); fclose($fp); } }