You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2008/02/19 11:34:34 UTC

svn commit: r629057 - /spamassassin/branches/3.2/build/mkrules

Author: jm
Date: Tue Feb 19 02:34:32 2008
New Revision: 629057

URL: http://svn.apache.org/viewvc?rev=629057&view=rev
Log:
bug 5825: backport changes to support nested 'if' conditionals in rulesrc files

Modified:
    spamassassin/branches/3.2/build/mkrules

Modified: spamassassin/branches/3.2/build/mkrules
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.2/build/mkrules?rev=629057&r1=629056&r2=629057&view=diff
==============================================================================
--- spamassassin/branches/3.2/build/mkrules (original)
+++ spamassassin/branches/3.2/build/mkrules Tue Feb 19 02:34:32 2008
@@ -528,7 +528,11 @@
         \s+(.*?)$
       /x)
     {
-      $current_conditional = $orig;
+      if ($current_conditional) {
+        $current_conditional .= "#|#".$orig;
+      } else {
+        $current_conditional = $orig;
+      }
     }
     elsif (/^endif\b/x)
     {
@@ -605,7 +609,7 @@
 
       my $cond;
       if ($current_conditional) {
-        $name = $current_conditional; $name =~ s/\s+/ /gs;
+        $name = $current_conditional; $name =~ s/\#\|\#/ /gs; $name =~ s/\s+/ /gs;
         $cond = $current_conditional;
       }
 
@@ -744,7 +748,14 @@
         $rules->{$ifplugin_text_name}->{output_file} = $pubfile;
       }
 
-      $rules->{$name}->{output_text} = "\n".$cond.$text."endif\n";
+      # ensure we produce enough "endif"s to match however many
+      # nested conditions there are
+      my $endifs = "endif\n";
+      while ($cond =~ s/\#\|\#//) {
+        $endifs .= "endif\n";
+      }
+
+      $rules->{$name}->{output_text} = "\n".$cond.$text.$endifs;
 
     } else {
       $rules->{$name}->{output_text} = $text;