From 9ef80f10ddbb379591ba8403da211fc10faeb954 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 10 Aug 2007 11:41:24 +0300 Subject: [PATCH] Cut down on false perl requires (rhbz#198033...) Patch from John Owens. --- scripts/perl.req | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/scripts/perl.req b/scripts/perl.req index 31bbb8b..fda79ba 100755 --- a/scripts/perl.req +++ b/scripts/perl.req @@ -1,6 +1,6 @@ #!/usr/bin/perl -# RPM (and it's source code) is covered under two separate licenses. +# RPM (and its source code) is covered under two separate licenses. # The entire code base may be distributed under the terms of the GNU # General Public License (GPL), which appears immediately below. @@ -17,7 +17,7 @@ # Any questions regarding the licensing of RPM should be addressed to # Erik Troan . -# a simple makedepends like script for perl. +# a simple makedepend like script for perl. # To save development time I do not parse the perl grammmar but # instead just lex it looking for what I want. I take special care to @@ -59,9 +59,9 @@ foreach $module (sort keys %require) { print "perl($module)\n"; } else { - # I am not using rpm3.0 so I do not want spaces arround my + # I am not using rpm3.0 so I do not want spaces around my # operators. Also I will need to change the processing of the - # $RPM_* vairable when I upgrage. + # $RPM_* variable when I upgrade. print "perl($module) >= $require{$module}\n"; } @@ -82,14 +82,25 @@ sub process_file { # skip the "= <<" block - if ( ( m/^\s*\$(.*)\s*=\s*<<\s*["'](.*)['"]/i) || - ( m/^\s*\$(.*)\s*=\s*<<\s*(.*);/i) ) { + if ( ( m/^\s*\$(.*)\s*=\s*<<\s*["'](.*)['"]/) || + ( m/^\s*\$(.*)\s*=\s*<<\s*(.*);/) ) { $tag = $2; while () { ( $_ =~ /^$tag/) && last; } } + # skip q{} quoted sections - just hope we don't have curly brackets + # within the quote, nor an escaped hash mark that isn't a comment + # marker, such as occurs right here. Draw the line somewhere. + if ( m/^.*\Wq[qxwr]?\s*([\{\(\[#|\/])[^})\]#|\/]*$/ && ! m/^\s*(require|use)\s/ ) { + $tag = $1; + $tag =~ tr/{\(\[\#|\//})]#|\//; + while () { + ( $_ =~ m/\}/ ) && last; + } + } + # skip the documentation # we should not need to have item in this if statement (it @@ -153,7 +164,7 @@ sub process_file { ($module =~ m/\$/) && next; - # skip if the phrase was "use of" -- shows up in gimp-perl, et al + # skip if the phrase was "use of" -- shows up in gimp-perl, et al. next if $module eq 'of'; # if the module ends in a comma we probaly caught some @@ -175,7 +186,7 @@ sub process_file { next; } - # sometimes people do use POSIX qw(foo), or use POSIX(qw(foo)) etc + # sometimes people do use POSIX qw(foo), or use POSIX(qw(foo)) etc. # we can strip qw.*$, as well as (.*$: $module =~ s/qw.*$//; $module =~ s/\(.*$//; @@ -187,7 +198,7 @@ sub process_file { $module =~ s/\//::/; - # trim off trailing parenthesis if any. Sometimes people pass + # trim off trailing parentheses if any. Sometimes people pass # the module an empty list. $module =~ s/\(\s*\)$//; @@ -208,7 +219,7 @@ sub process_file { }; # ph files do not use the package name inside the file. - # perlmodlib documentation says: + # perlmodlib documentation says: # the .ph files made by h2ph will probably end up as # extension modules made by h2xs. -- 2.7.4