Ticket #139: 0005-Extract-dependencies-from-some-usual-syntaxes-of-use.patch

File 0005-Extract-dependencies-from-some-usual-syntaxes-of-use.patch, 1.7 kB (added by scop, 2 years ago)
  • a/scripts/perl.req

    old new  
    136136      } 
    137137    } 
    138138 
     139    my $modver_re = qr/[.0-9]+/; 
     140 
    139141    if ( 
    140142 
    141143# ouch could be in a eval, perhaps we do not want these since we catch 
     
    151153         # quotes around name are always legal 
    152154         ['"]?([^; '"\t#]*)['"]?[\t; ] 
    153155         # the syntax for 'use' allows version requirements 
    154          \s*([.0-9]*) 
     156         # the latter part is for "use base qw(Foo)" and friends special case 
     157         \s*($modver_re|(qw\s*[(\/]\s*|['"])[^)\/"'\$]*?\s*[)\/"'])? 
    155158         /x) 
    156159       ) { 
    157160      my ($whitespace, $statement, $module, $version) = ($1, $2, $3, $4); 
     
    239242 
    240243      ($module =~ m/\.ph$/) && next; 
    241244 
     245      # use base qw(Foo) dependencies 
     246      if ($statement eq "use" && $module eq "base") { 
     247        $require{$module} = undef; 
     248        if ($version =~ /^qw\s*[(\/]\s*([^)\/]+?)\s*[)\/]/) { 
     249          $require{$_} = undef for split(' ', $1); 
     250        } 
     251        elsif ($version =~ /(["'])([^"']+)\1/) { 
     252          $require{$2} = undef; 
     253        } 
     254        next; 
     255      } 
     256      $version = undef unless $version =~ /^$modver_re$/o; 
     257 
    242258      $require{$module} = $version; 
    243259    } 
    244260