tweaked previous merge (refs #894)

This commit is contained in:
Fabien Potencier
2012-11-08 10:24:49 +01:00
parent 818f9c7e02
commit 1a10ea2fbb
2 changed files with 6 additions and 3 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.11.1 (2012-XX-XX)
* fixed debug info line numbering (was off by 2)
* fixed escaping when calling a macro inside another one (regression introduced in 1.9.1)
* optimized variable access on PHP 5.4
* fixed a crash of the C extension when an exception was thrown from a macro called without being imported (using _self.XXX)
+5 -3
View File
@@ -76,7 +76,8 @@ class Twig_Compiler implements Twig_CompilerInterface
$this->lastLine = null;
$this->source = '';
$this->sourceOffset = 0;
$this->sourceLine = 0;
// source code starts at 1 (as we then increment it when we encounter new lines)
$this->sourceLine = 1;
$this->indentation = $indentation;
if ($node instanceof Twig_Node_Module) {
@@ -207,6 +208,8 @@ class Twig_Compiler implements Twig_CompilerInterface
public function addDebugInfo(Twig_NodeInterface $node)
{
if ($node->getLine() != $this->lastLine) {
$this->write("// line {$node->getLine()}\n");
// when mbstring.func_overload is set to 2
// mb_substr_count() replaces substr_count()
// but they have different signatures!
@@ -217,10 +220,9 @@ class Twig_Compiler implements Twig_CompilerInterface
$this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset);
}
$this->sourceOffset = strlen($this->source);
$this->debugInfo[$this->sourceLine + 2] = $node->getLine();
$this->debugInfo[$this->sourceLine] = $node->getLine();
$this->lastLine = $node->getLine();
$this->write("// line {$node->getLine()}\n");
}
return $this;