Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1583787
 поиск   регистрация   авторизация 
 
Группа :: Разработка/Perl
Пакет: perl-HTML-Template-Expr

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: perl-HTML-Template-Expr-alt-regexp.patch


diff -ur HTML-Template-Expr-0.04.orig/Expr.pm HTML-Template-Expr-0.04/Expr.pm
--- HTML-Template-Expr-0.04.orig/Expr.pm	2002-08-29 06:51:56 +0300
+++ HTML-Template-Expr-0.04/Expr.pm	2005-03-23 12:57:10 +0200
@@ -33,6 +33,7 @@
               | /le|ge|eq|ne|lt|gt/  { [ ${\BIN_OP},  \$item[1] ] }
               | /\\|\\||or|&&|and/   { [ ${\BIN_OP},  \$item[1] ] }
               | /[-+*\\/\%]/         { [ ${\BIN_OP},  \$item[1] ] }
+	      | /=~|!~/              { [ ${\BIN_OP},  \$item[1] ] }
 
 function_call : function_name '(' args ')'  
                 { [ ${\FUNCTION_CALL}, \$item[1], \$item[3] ] }
@@ -281,6 +282,9 @@
     $op eq '/' and return $lhs / $rhs;
     $op eq '*' and return $lhs * $rhs;
     $op eq '%' and return $lhs %  $rhs;
+    
+    $op eq '=~' and return $lhs =~ $rhs;
+    $op eq '!~' and return $lhs !~ $rhs;
 
     if ($op eq 'or' or $op eq '||') {
       # short circuit or
@@ -427,6 +431,10 @@
 If you don't like this rule please feel free to contribute a patch
 to improve the parser's grammar.
 
+Pattern in regular expression must be enclosed with "/":
+
+   <TMPL_VAR EXPR="foo =~ /bar/">
+
 =head1 COMPARISON
 
 Here's a list of supported comparison operators:
@@ -507,6 +515,18 @@
 
 =back 4
 
+=head1 REGULAR EXPRESSION SUPPORT
+
+Standart regexp syntax:
+
+=over 4
+
+=item * =~
+
+=item * !~
+
+=back 4
+
 =head1 FUNCTIONS
 
 The following functions are available to be used in expressions.  See
@@ -654,9 +674,9 @@
 
 Thanks!
 
-=head1 AUTHOR
+=head1 AUTHORS
 
-Sam Tregar <sam@tregar.com>
+Sam Tregar <sam@tregar.com>, Stanislav Yadykin <tosick at altlinux.ru> (regexp support)
 
 =head1 LICENSE
 
diff -ur HTML-Template-Expr-0.04.orig/t/01parse.t HTML-Template-Expr-0.04/t/01parse.t
--- HTML-Template-Expr-0.04.orig/t/01parse.t	2001-11-05 21:46:34 +0200
+++ HTML-Template-Expr-0.04/t/01parse.t	2005-03-23 12:47:14 +0200
@@ -1,4 +1,4 @@
-use Test::More tests => 14;
+use Test::More tests => 16;
 use HTML::Template::Expr;
 use Parse::RecDescent;
 use Data::Dumper;
@@ -21,7 +21,9 @@
              "(((call(foo, 10) + 100) > 10) || (foo eq \"barf\"))",
              "((foo > bar))",
 	     "call(call2(call3()))",
-	     "call(foo > bar)"
+	     "call(foo > bar)",
+	     "(foo =~ /bar/)",
+	     "(foo !~ /bar/)"
 	    );
 
 foreach my $test (@tests) {
 
design & coding: Vladimir Lettiev aka crux © 2004-2005