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) |
|---|
-
a/scripts/perl.prov
old new 81 81 82 82 my ($file) = @_; 83 83 chomp $file; 84 84 85 85 open(FILE, "<$file") || return; 86 86 87 87 my ($package, $version, $incomment, $inover) = (); 88 88 89 89 while (<FILE>) { 90 90 91 91 # skip the documentation 92 92 93 93 # we should not need to have item in this if statement (it … … 102 102 $incomment = 0; 103 103 $inover = 0; 104 104 } 105 105 106 106 if (m/^=(over)/) { 107 107 $inover = 1; 108 108 } … … 114 114 if ($incomment || $inover) { 115 115 next; 116 116 } 117 117 118 118 # skip the data section 119 119 if (m/^__(DATA|END)__$/) { 120 120 last; … … 125 125 # false positives as if they were provided packages (really ugly). 126 126 127 127 if (m/^\s*package\s+([_:a-zA-Z0-9]+)\s*;/) { 128 $package =$1;128 $package = $1; 129 129 undef $version; 130 130 if ($package eq 'main') { 131 131 undef $package; … … 134 134 # the package definition is broken up over multiple blocks. 135 135 # In that case, don't stomp a previous $VERSION we might have 136 136 # found. (See BZ#214496.) 137 $require{$package} =undef unless (exists $require{$package});137 $require{$package} = undef unless (exists $require{$package}); 138 138 } 139 139 } 140 140 … … 149 149 #CGI/Apache.pm:$VERSION = (qw$Revision: 1.9 $)[1]; 150 150 #DynaLoader.pm:$VERSION = $VERSION = "1.03"; # avoid typo warning 151 151 #General.pm:$Config::General::VERSION = 2.33; 152 # 152 # 153 153 # or with the new "our" pragma you could (read will) see: 154 154 # 155 155 # 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+/) { 157 157 158 158 # first see if the version string contains the string 159 159 # '$Revision' this often causes bizzare strings and is the most 160 160 # common method of non static numbering. 161 161 162 162 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 script167 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; 169 169 } 170 $require{$package} =$version;170 $require{$package} = $version; 171 171 } 172 172 173 173 # 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 # 177 177 # For instance: 178 # 178 # 179 179 # $RPM_Provides = "blah bleah" 180 # 180 # 181 181 # Will generate provides for "blah" and "bleah". 182 182 # 183 183 # Each keyword can appear multiple times. Don't 184 184 # bother with datastructures to store these strings, 185 185 # 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) { 188 188 foreach $_ (split(/\s+/, $2)) { 189 print "$_\n";189 print "$_\n"; 190 190 } 191 191 } 192 192 … … 195 195 close(FILE) || 196 196 die("$0: Could not close file: '$file' : $!\n"); 197 197 198 return ;198 return; 199 199 } -
a/scripts/perl.req
old new 1 1 #!/usr/bin/perl 2 2 3 # RPM (and its source code) is covered under two separate licenses. 3 # RPM (and its source code) is covered under two separate licenses. 4 4 5 5 # The entire code base may be distributed under the terms of the GNU 6 6 # General Public License (GPL), which appears immediately below. … … 18 18 # Erik Troan <ewt@redhat.com>. 19 19 20 20 # a simple makedepend like script for perl. 21 21 22 22 # To save development time I do not parse the perl grammmar but 23 23 # instead just lex it looking for what I want. I take special care to 24 24 # ignore comments and pod's. … … 44 44 process_file($_); 45 45 } 46 46 } else { 47 47 48 48 # notice we are passed a list of filenames NOT as common in unix the 49 49 # contents of the file. 50 50 51 51 foreach (<>) { 52 52 process_file($_); 53 53 } … … 72 72 73 73 74 74 sub process_file { 75 75 76 76 my ($file) = @_; 77 77 chomp $file; 78 78 79 79 open(FILE, "<$file") || return; 80 80 81 81 while (<FILE>) { 82 82 83 83 # skip the "= <<" block 84 84 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*;/) { 87 87 $tag = $2; 88 88 while (<FILE>) { 89 89 chomp; … … 95 95 # skip q{} quoted sections - just hope we don't have curly brackets 96 96 # within the quote, nor an escaped hash mark that isn't a comment 97 97 # 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/ ) { 99 99 $tag = $1; 100 100 $tag =~ tr/{\(\[\#|\//})]#|\//; 101 101 while (<FILE>) { … … 116 116 if ( (m/^=(over)/) .. (m/^=(back)/) ) { 117 117 next; 118 118 } 119 119 120 120 # skip the data section 121 121 if (m/^__(DATA|END)__$/) { 122 122 last; … … 126 126 # bother with datastructures to store these strings, 127 127 # if we need to print it print it now. 128 128 # 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) { 131 131 foreach $_ (split(/\s+/, $2)) { 132 print "$_\n";132 print "$_\n"; 133 133 } 134 134 } 135 135 136 if ( 136 if ( 137 137 138 138 # ouch could be in a eval, perhaps we do not want these since we catch 139 139 # an exception they must not be required … … 143 143 # eval { require Carp } if defined $^S; # If error/warning during compilation, 144 144 145 145 146 (m/^(\s*) # we hope the inclusion starts the line147 (require|use)\s+(?!\{) # do not want 'do {' loops148 # quotes around name are always legal149 [\'\"]?([^\;\ \'\"\t#]*)[\'\"]?[\t\;\]150 # the syntax for 'use' allows version requirements151 \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) 153 153 ) { 154 154 my ($whitespace, $statement, $module, $version) = ($1, $2, $3,$4); 155 155 … … 163 163 # if there is some interpolation of variables just skip this 164 164 # dependency, we do not want 165 165 # do "$ENV{LOGDIR}/$rcfile"; 166 166 167 167 ($module =~ m/\$/) && next; 168 168 169 169 # skip if the phrase was "use of" -- shows up in gimp-perl, et al. … … 195 195 196 196 $module =~ s/\.pm$//; 197 197 198 # some perl programmers write 'require URI/URL;' when 198 # some perl programmers write 'require URI/URL;' when 199 199 # they mean 'require URI::URL;' 200 200 201 201 $module =~ s/\//::/; … … 209 209 # if module is a number then both require and use interpret that 210 210 # to mean that a particular version of perl is specified 211 211 212 my $ver =$1;212 my $ver = $1; 213 213 if ($ver =~ /5.00/) { 214 214 print "perl >= 0:$ver\n"; 215 215 next; … … 223 223 224 224 # ph files do not use the package name inside the file. 225 225 # perlmodlib documentation says: 226 226 227 227 # the .ph files made by h2ph will probably end up as 228 228 # extension modules made by h2xs. 229 229 230 230 # so do not expend much effort on these. 231 231 232 232 … … 234 234 # will be included with the name sys/systeminfo.ph so only use the 235 235 # basename of *.ph files 236 236 237 ($module =~ m/\.ph$/) && next;237 ($module =~ m/\.ph$/) && next; 238 238 239 $require{$module} =$version;240 $line{$module} =$_;239 $require{$module} = $version; 240 $line{$module} = $_; 241 241 } 242 242 243 243 } 244 244 245 245 close(FILE) || 246 246 die("$0: Could not close file: '$file' : $!\n"); 247 248 return ;247 248 return; 249 249 }

