simplified code
authorFabien Potencier <fabien.potencier@gmail.com>
Tue, 10 May 2011 05:21:09 +0000 (07:21 +0200)
committerFabien Potencier <fabien.potencier@gmail.com>
Tue, 10 May 2011 05:21:09 +0000 (07:21 +0200)
lib/Twig/Lexer.php

index e8fab6f..26aea29 100644 (file)
@@ -263,13 +263,12 @@ class Twig_Lexer implements Twig_LexerInterface
 
     protected function lexRawData()
     {
-        if (!preg_match('/'.preg_quote($this->options['tag_block'][0], '/').'\s*endraw\s*'.preg_quote($this->options['tag_block'][1], '/').'/s', $this->code, $match, null, $this->cursor)) {
+        if (!preg_match('/'.preg_quote($this->options['tag_block'][0], '/').'\s*endraw\s*'.preg_quote($this->options['tag_block'][1], '/').'/s', $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
             throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "block"'));
         }
-        $pos = strpos($this->code, $match[0], $this->cursor);
-        $text = substr($this->code, $this->cursor, $pos - $this->cursor);
+        $text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
         $this->pushToken(Twig_Token::TEXT_TYPE, $text);
-        $this->moveCursor($text.$match[0]);
+        $this->moveCursor($text.$match[0][0]);
     }
 
     protected function pushToken($type, $value = '')