perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tors...@apache.org
Subject svn commit: r1151816 - /perl/modperl/branches/httpd24/lib/ModPerl/MapUtil.pm
Date Thu, 28 Jul 2011 12:25:53 GMT
Author: torsten
Date: Thu Jul 28 12:25:53 2011
New Revision: 1151816

URL: http://svn.apache.org/viewvc?rev=1151816&view=rev
Log:
Allow for multiline Perl statements in the "#_if_" minilanguage in
map files like xs/maps/apache2_functions.map

Before this change one would have to write

#_if_ do { long perl expression; another perl expression }

After it can span over multiple lines:

#_if_ do {                     \
  long perl expression;        \
  another perl expression;     \
}

Modified:
    perl/modperl/branches/httpd24/lib/ModPerl/MapUtil.pm

Modified: perl/modperl/branches/httpd24/lib/ModPerl/MapUtil.pm
URL: http://svn.apache.org/viewvc/perl/modperl/branches/httpd24/lib/ModPerl/MapUtil.pm?rev=1151816&r1=1151815&r2=1151816&view=diff
==============================================================================
--- perl/modperl/branches/httpd24/lib/ModPerl/MapUtil.pm (original)
+++ perl/modperl/branches/httpd24/lib/ModPerl/MapUtil.pm Thu Jul 28 12:25:53 2011
@@ -103,15 +103,28 @@ sub readline {
         # #_end_
         if (/^\s*#\s*_(if|unless|els(?:e|if)|end)_(?:\s(.+))?/) {
             my ($cmd, $param) = ($1, $2);
+            if (defined $param) {
+                while ($param=~s!\\$!!) {
+                    my $l=<$fh>;
+                    die "$ModPerl::MapUtil::MapFile($.): unexpected EOF\n"
+                        unless defined $l;
+                    chomp $l;
+                    $param.=$l;
+                }
+            }
             if ($cmd eq 'if') {
-                unshift @condition, 0+!!eval $param;
+                unshift @condition,
+                    0+!!eval "#line $. $ModPerl::MapUtil::MapFile\n".$param;
+                die $@ if $@;
             }
             elsif ($cmd eq 'elsif') {
                 die "parse error ($ModPerl::MapUtil::MapFile line $.)".
                     " #_elsif_ without #_if_"
                     unless @condition;
                 if ($condition[0] == 0) {
-                    $condition[0]+=!!eval $param;
+                    $condition[0]+=
+                        !!eval "#line $. $ModPerl::MapUtil::MapFile\n".$param;
+                    die $@ if $@;
                 } else {
                     $condition[0]++;
                 }
@@ -123,7 +136,9 @@ sub readline {
                 $condition[0]+=1;
             }
             elsif ($cmd eq 'unless') {
-                unshift @condition, 0+!eval $param;
+                unshift @condition,
+                    0+!eval "#line $. $ModPerl::MapUtil::MapFile\n".$param;
+                die $@ if $@;
             }
             elsif ($cmd eq 'end') {
                 shift @condition;
@@ -133,6 +148,15 @@ sub readline {
 
         if (/^\s*#\s*_(eval)_(?:\s(.+))?/) {
             my ($cmd, $param) = ($1, $2);
+            if (defined $param) {
+                while ($param=~s!\\$!!) {
+                    my $l=<$fh>;
+                    die "$ModPerl::MapUtil::MapFile($.): unexpected EOF\n"
+                        unless defined $l;
+                    chomp $l;
+                    $param.=$l;
+                }
+            }
             if ($cmd eq 'eval') {
                 eval "#line $. $ModPerl::MapUtil::MapFile\n".$param;
                 die $@ if $@;



Mime
View raw message