From 654468ff5d085f8a74ef1bdb210d0518818c4970 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 10 May 2011 07:21:09 +0200 Subject: [PATCH] simplified code --- lib/Twig/Lexer.php | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Twig/Lexer.php b/lib/Twig/Lexer.php index e8fab6f..26aea29 100644 --- a/lib/Twig/Lexer.php +++ b/lib/Twig/Lexer.php @@ -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 = '') -- 1.7.2.5