Ticket #128: 0004-perl.-req-prov-whitespace-backslash-and-paren-clea.patch

File 0004-perl.-req-prov-whitespace-backslash-and-paren-clea.patch, 9.0 kB (added by scop, 2 years ago)

perl.{req,prov} cleanups

  • a/scripts/perl.prov

    old new  
    8181 
    8282  my ($file) = @_; 
    8383  chomp $file; 
    84    
     84 
    8585  open(FILE, "<$file") || return; 
    8686 
    8787  my ($package, $version, $incomment, $inover) = (); 
    8888 
    8989  while (<FILE>) { 
    90      
     90 
    9191    # skip the documentation 
    9292 
    9393    # we should not need to have item in this if statement (it 
     
    102102      $incomment = 0; 
    103103      $inover = 0; 
    104104    } 
    105      
     105 
    106106    if (m/^=(over)/) { 
    107107      $inover = 1; 
    108108    } 
     
    114114    if ($incomment || $inover) { 
    115115       next; 
    116116    } 
    117      
     117 
    118118    # skip the data section 
    119119    if (m/^__(DATA|END)__$/) { 
    120120      last; 
     
    125125    # false positives as if they were provided packages (really ugly). 
    126126 
    127127    if (m/^\s*package\s+([_:a-zA-Z0-9]+)\s*;/) { 
    128       $package=$1; 
     128      $package = $1; 
    129129      undef $version; 
    130130      if ($package eq 'main') { 
    131131        undef $package; 
     
    134134        # the package definition is broken up over multiple blocks. 
    135135        # In that case, don't stomp a previous $VERSION we might have 
    136136        # found.  (See BZ#214496.) 
    137         $require{$package}=undef unless (exists $require{$package}); 
     137        $require{$package} = undef unless (exists $require{$package}); 
    138138      } 
    139139    } 
    140140 
     
    149149    #CGI/Apache.pm:$VERSION = (qw$Revision: 1.9 $)[1]; 
    150150    #DynaLoader.pm:$VERSION = $VERSION = "1.03";     # avoid typo warning 
    151151    #General.pm:$Config::General::VERSION = 2.33; 
    152     #  
     152    # 
    153153    # or with the new "our" pragma you could (read will) see: 
    154154    # 
    155155    #    our $VERSION = '1.00' 
    156     if (($package) && (m/^\s*(our\s+)?\$(\Q$package\E::)?VERSION\s*=\s+/)) { 
     156    if ($package && m/^\s*(our\s+)?\$(\Q$package\E::)?VERSION\s*=\s+/) { 
    157157 
    158158      # first see if the version string contains the string 
    159159      # '$Revision' this often causes bizzare strings and is the most 
    160160      # common method of non static numbering. 
    161161 
    162162      if (m/(\$Revision: (\d+[.0-9]+))/) { 
    163         $version= $2;  
    164       } elsif (m/[\'\"]?(\d+[.0-9]+)[\'\"]?/) { 
    165          
    166        # look for a static number hard coded in the script 
    167          
    168         $version= $1;  
     163        $version = $2; 
     164      } elsif (m/['"]?(\d+[.0-9]+)['"]?/) { 
     165 
     166        # look for a static number hard coded in the script 
     167 
     168        $version = $1; 
    169169      } 
    170       $require{$package}=$version; 
     170      $require{$package} = $version; 
    171171    } 
    172    
     172 
    173173    # Allow someone to have a variable that defines virtual packages 
    174     # The variable is called $RPM_Provides.  It must be scoped with  
    175     # "our", but not "local" or "my" (just would not make sense).  
    176     #  
     174    # The variable is called $RPM_Provides.  It must be scoped with 
     175    # "our", but not "local" or "my" (just would not make sense). 
     176    # 
    177177    # For instance: 
    178     #   
     178    # 
    179179    #     $RPM_Provides = "blah bleah" 
    180     #  
     180    # 
    181181    # Will generate provides for "blah" and "bleah". 
    182182    # 
    183183    # Each keyword can appear multiple times.  Don't 
    184184    #  bother with datastructures to store these strings, 
    185185    #  if we need to print it print it now. 
    186          
    187     if ( m/^\s*(our\s+)?\$RPM_Provides\s*=\s*["'](.*)['"]/i) { 
     186 
     187    if (m/^\s*(our\s+)?\$RPM_Provides\s*=\s*["'](.*)['"]/i) { 
    188188      foreach $_ (split(/\s+/, $2)) { 
    189        print "$_\n"; 
     189        print "$_\n"; 
    190190      } 
    191191    } 
    192192 
     
    195195  close(FILE) || 
    196196    die("$0: Could not close file: '$file' : $!\n"); 
    197197 
    198   return 
     198  return
    199199} 
  • a/scripts/perl.req

    old new  
    11#!/usr/bin/perl 
    22 
    3 # RPM (and its source code) is covered under two separate licenses.  
     3# RPM (and its source code) is covered under two separate licenses. 
    44 
    55# The entire code base may be distributed under the terms of the GNU 
    66# General Public License (GPL), which appears immediately below. 
     
    1818# Erik Troan <ewt@redhat.com>. 
    1919 
    2020# a simple makedepend like script for perl. 
    21   
     21 
    2222# To save development time I do not parse the perl grammmar but 
    2323# instead just lex it looking for what I want.  I take special care to 
    2424# ignore comments and pod's. 
     
    4444    process_file($_); 
    4545  } 
    4646} else { 
    47    
     47 
    4848  # notice we are passed a list of filenames NOT as common in unix the 
    4949  # contents of the file. 
    50    
     50 
    5151  foreach (<>) { 
    5252    process_file($_); 
    5353  } 
     
    7272 
    7373 
    7474sub process_file { 
    75    
     75 
    7676  my ($file) = @_; 
    7777  chomp $file; 
    78    
     78 
    7979  open(FILE, "<$file") || return; 
    80    
     80 
    8181  while (<FILE>) { 
    82      
     82 
    8383    # skip the "= <<" block 
    8484 
    85     if ( ( m/^\s*\$(?:.*)\s*=\s*<<\s*(["'`])(.*)\1/) || 
    86          ( m/^\s*\$(.*)\s*=\s*<<(\w*)\s*;/) ) { 
     85    if (m/^\s*\$(?:.*)\s*=\s*<<\s*(["'`])(.*)\1/ || 
     86        m/^\s*\$(.*)\s*=\s*<<(\w*)\s*;/) { 
    8787      $tag = $2; 
    8888      while (<FILE>) { 
    8989        chomp; 
     
    9595    # skip q{} quoted sections - just hope we don't have curly brackets 
    9696    # within the quote, nor an escaped hash mark that isn't a comment 
    9797    # marker, such as occurs right here. Draw the line somewhere. 
    98     if ( m/^.*\Wq[qxwr]?\s*([\{\(\[#|\/])[^})\]#|\/]*$/ && ! m/^\s*(require|use)\s/ ) { 
     98    if ( m/^.*\Wq[qxwr]?\s*([{([#|\/])[^})\]#|\/]*$/ && ! m/^\s*(require|use)\s/ ) { 
    9999      $tag = $1; 
    100100      $tag =~ tr/{\(\[\#|\//})]#|\//; 
    101101      while (<FILE>) { 
     
    116116    if ( (m/^=(over)/) .. (m/^=(back)/) ) { 
    117117      next; 
    118118    } 
    119      
     119 
    120120    # skip the data section 
    121121    if (m/^__(DATA|END)__$/) { 
    122122      last; 
     
    126126    #  bother with datastructures to store these strings, 
    127127    #  if we need to print it print it now. 
    128128    # 
    129        # Again allow for "our". 
    130     if ( m/^\s*(our\s+)?\$RPM_Requires\s*=\s*["'](.*)['"]/i) { 
     129        # Again allow for "our". 
     130    if (m/^\s*(our\s+)?\$RPM_Requires\s*=\s*["'](.*)['"]/i) { 
    131131      foreach $_ (split(/\s+/, $2)) { 
    132        print "$_\n"; 
     132        print "$_\n"; 
    133133      } 
    134134    } 
    135135 
    136     if (  
     136    if ( 
    137137 
    138138# ouch could be in a eval, perhaps we do not want these since we catch 
    139139# an exception they must not be required 
     
    143143#   eval { require Carp } if defined $^S; # If error/warning during compilation, 
    144144 
    145145 
    146        (m/^(\s*)         # we hope the inclusion starts the line 
    147         (require|use)\s+(?!\{)     # do not want 'do {' loops 
    148         # quotes around name are always legal 
    149         [\'\"]?([^\;\ \'\"\t#]*)[\'\"]?[\t\;\
    150         # the syntax for 'use' allows version requirements 
    151         \s*([.0-9]*) 
    152         /x) 
     146        (m/^(\s*)         # we hope the inclusion starts the line 
     147        (require|use)\s+(?!\{)     # do not want 'do {' loops 
     148        # quotes around name are always legal 
     149         ['"]?([^; '"\t#]*)['"]?[\t;
     150        # the syntax for 'use' allows version requirements 
     151        \s*([.0-9]*) 
     152        /x) 
    153153       ) { 
    154154      my ($whitespace, $statement, $module, $version) = ($1, $2, $3,$4); 
    155155 
     
    163163      # if there is some interpolation of variables just skip this 
    164164      # dependency, we do not want 
    165165      #        do "$ENV{LOGDIR}/$rcfile"; 
    166     
     166 
    167167      ($module =~ m/\$/) && next; 
    168168 
    169169      # skip if the phrase was "use of" -- shows up in gimp-perl, et al. 
     
    195195 
    196196      $module =~ s/\.pm$//; 
    197197 
    198       # some perl programmers write 'require URI/URL;' when  
     198      # some perl programmers write 'require URI/URL;' when 
    199199      # they mean 'require URI::URL;' 
    200200 
    201201      $module =~ s/\//::/; 
     
    209209      # if module is a number then both require and use interpret that 
    210210      # to mean that a particular version of perl is specified 
    211211 
    212       my $ver=$1; 
     212      my $ver = $1; 
    213213      if ($ver =~ /5.00/) { 
    214214        print "perl >= 0:$ver\n"; 
    215215        next; 
     
    223223 
    224224      # ph files do not use the package name inside the file. 
    225225      # perlmodlib documentation says: 
    226        
     226 
    227227      #       the .ph files made by h2ph will probably end up as 
    228228      #       extension modules made by h2xs. 
    229        
     229 
    230230      # so do not expend much effort on these. 
    231231 
    232232 
     
    234234      # will be included with the name sys/systeminfo.ph so only use the 
    235235      # basename of *.ph files 
    236236 
    237       ($module  =~ m/\.ph$/) && next; 
     237      ($module =~ m/\.ph$/) && next; 
    238238 
    239       $require{$module}=$version; 
    240       $line{$module}=$_; 
     239      $require{$module} = $version; 
     240      $line{$module} = $_; 
    241241    } 
    242      
     242 
    243243  } 
    244244 
    245245  close(FILE) || 
    246246    die("$0: Could not close file: '$file' : $!\n"); 
    247    
    248   return ;  
     247 
     248  return; 
    249249}