Upgrade to Devel::PPPort 3.00_01.
[p5sagit/p5-mst-13.2.git] / ext / Devel / PPPort / parts / ppptools.pl
index 7ef1700..2953f3b 100644 (file)
@@ -4,9 +4,9 @@
 #
 ################################################################################
 #
-#  $Revision: 11 $
+#  $Revision: 12 $
 #  $Author: mhx $
-#  $Date: 2004/08/13 12:50:05 +0200 $
+#  $Date: 2004/08/17 14:00:34 +0200 $
 #
 ################################################################################
 #
@@ -45,6 +45,17 @@ sub parse_todo
   return \%todo;
 }
 
+sub expand_version
+{
+  my($op, $ver) = @_;
+  my($r, $v, $s) = parse_version($ver);
+  $r == 5 or die "only Perl revision 5 is supported\n";
+  $op eq '=='     and return "((PERL_VERSION == $v) && (PERL_SUBVERSION == $s))";
+  $op eq '!='     and return "((PERL_VERSION != $v) || (PERL_SUBVERSION != $s))";
+  $op =~ /([<>])/ and return "((PERL_VERSION $1 $v) || ((PERL_VERSION == $v) && (PERL_SUBVERSION $op $s)))";
+  die "cannot expand version expression ($op $ver)\n";
+}
+
 sub parse_partspec
 {
   my $file = shift;
@@ -139,6 +150,12 @@ sub parse_partspec
     }
   }
 
+  for $section (qw( implementation xsubs xsinit xsmisc xshead xsboot )) {
+    if (exists $data{$section}) {
+      $data{$section} =~ s/\{\s*version\s*(<|>|==|!=|>=|<=)\s*([\d._]+)\s*\}/expand_version($1, $2)/gei;
+    }
+  }
+
   $data{provides}   = \@prov;
   $data{prototypes} = \%proto;
   $data{OPTIONS}    = \%options;