diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2001-07-24 22:58:36 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2001-07-24 22:58:36 +0000 |
commit | 72e28b71c097e4f2b17b031416790090cefb8263 (patch) | |
tree | 7d76b1106d53506122086b57a1cfda99af714fa0 /perl_checker | |
parent | 5bef71a0c86613f95e154d08b5f8f0cc23226e27 (diff) | |
download | perl-MDK-Common-72e28b71c097e4f2b17b031416790090cefb8263.tar perl-MDK-Common-72e28b71c097e4f2b17b031416790090cefb8263.tar.gz perl-MDK-Common-72e28b71c097e4f2b17b031416790090cefb8263.tar.bz2 perl-MDK-Common-72e28b71c097e4f2b17b031416790090cefb8263.tar.xz perl-MDK-Common-72e28b71c097e4f2b17b031416790090cefb8263.zip |
everything should work now
Diffstat (limited to 'perl_checker')
-rwxr-xr-x | perl_checker | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/perl_checker b/perl_checker index 822726b..ce3980d 100755 --- a/perl_checker +++ b/perl_checker @@ -1,26 +1,38 @@ #!/usr/bin/perl -n BEGIN { + while ($ARGV[0] =~ /-I(.*)/) { + unshift @INC, $1; + shift; + } + $NO_CW = $ARGV[0] eq "-no_cw" and shift; $USES = $ARGV[0] eq "-uses" and shift; @exclude_calls = qw(chomp chop chr crypt hex index lc lcfirst length oct ord pack reverse rindex sprintf substr uc ucfirst pos quotemeta split study abs atan2 cos exp hex int log oct rand sin sqrt srand pop push shift splice unshift grep join map reverse sort unpack delete each exists keys values binmode close closedir dbmclose dbmopen die eof fileno flock format getc print printf read readdir rewinddir seek seekdir select syscall sysread sysseek syswrite tell telldir truncate warn write pack read syscall sysread syswrite unpack vec chdir chmod chown chroot fcntl glob ioctl link lstat mkdir open opendir readlink rename rmdir stat symlink umask unlink utime caller continue die do dump eval exit goto last next redo return sub wantarray caller import local my package use defined dump eval formline local my reset scalar undef wantarray alarm exec fork getpgrp getppid getpriority kill pipe setpgrp setpriority sleep system times wait waitpid do import no package require use bless dbmclose dbmopen package ref tie tied untie use accept bind connect getpeername getsockname getsockopt listen recv send setsockopt shutdown socket socketpair msgctl msgget msgrcv msgsnd semctl semget semop shmctl shmget shmread shmwrite endgrent endhostent endnetent endpwent getgrent getgrgid getgrnam getlogin getpwent getpwnam getpwuid setgrent setpwent endprotoent endservent gethostbyaddr gethostbyname gethostent getnetbyaddr getnetbyname getnetent getprotobyname getprotobynumber getprotoent getservbyname getservbyport getservent sethostent setnetent setprotoent setservent gmtime localtime time times abs bless chomp chr exists formline glob import lc lcfirst map my no prototype qx qw readline readpipe ref sysopen tie tied uc ucfirst untie use qq Dumper packdrake Eth); @exclude_calls{@exclude_calls} = undef; - @exclude_uses = qw(globals diagnostics strict vars lib Config Socket Locale::GetText CORE POSIX Gtk Data::Dumper Net::FTP Gtk::XmHTML Gtk::Gdk Gtk::Gdk::ImlibImage Newt Newt::Component Newt::Grid DynaLoader IO::Socket packdrake); + @exclude_uses = qw(globals diagnostics strict vars lib Carp Config Exporter Socket Locale::GetText CORE POSIX Gtk Data::Dumper Net::FTP Gtk::XmHTML Gtk::Gdk Gtk::Gdk::ImlibImage Newt Newt::Component Newt::Grid DynaLoader IO::Socket packdrake); while ($ARGV[0] =~ /-exclude(.*)/) { push @exclude_uses, $1; shift; } @exclude_uses{@exclude_uses} = undef; - foreach (@ARGV) { - system("perl", "-cw", $_); - $? == 0 or die "perl -cw $_ failed\n"; + if (!$NO_CW) { + foreach (@ARGV) { + system("perl", "-cw", $_); + $? == 0 or die "perl -cw $_ failed\n"; + } } $package = 'main'; } chop; + +if (/^# perl_checker: RE-EXPORT-ALL/) { + push @re_exported, $package; +} + /^\s*#/ and next; if (/^\s*require\s+([\w:]+);/) { @@ -38,7 +50,6 @@ s/\bm\b(.)(.*?)\1//g; # m// operator s|\(/.*?/|(|g; # m// operator s{([!=]~|\bif\b)\s*/.*?/}{}g; - s/#.*//; if (/^\s*package ([\w:]+)/) { @@ -49,10 +60,15 @@ if (/^\s*package ([\w:]+)/) { if (/\@EXPORT = qw\((.*)\)/) { @{$export{$package}}{split ' ', $1} = undef; - #$export_info{$package} = info(); } - -if (/%EXPORT_TAGS = \(/ .. /^\);$/) { +if (/\@EXPORT_OK = qw\((.*)\)/) { + @{$export_ok{$package}}{split ' ', $1} = undef; + $export_info{$package} = info(); +} +if (/%EXPORT_TAGS = \((\w+) => \[ \@EXPORT_OK \]\)/) { + $export_tags{$package}->{$1} = $export_ok{$package}; +} +if (/%EXPORT_TAGS = \(\s*$/ .. /^\);$/) { /\s+(\w+)\s+.*?qw\((.*)\)/; @{$export_tags{$package}->{$1}}{split ' ', $2} = undef; $export_tags_info{$package}->{$1} = info(); @@ -74,7 +90,7 @@ while (/&([\w:]+)/g) { add_call($1); } #} /^use\s+([\w:]+);/ and add_use($1); -if (my ($p, $v) = /^use\s(\w+)\s+(.*)/) { +if (my ($p, $v) = /^use\s([\w:]+)\s+(.*)/) { $v =~ /^qw\((.*?)\)/ ? add_use($p, $1) : err("<<$_>> should be written <<use $p qw(:A :B ...)>>", info()) if !exists $exclude_uses{$p}; } @@ -83,10 +99,10 @@ if (my ($p, $v) = /^\s*(\S+)->import\((.*)\)/) { } /^\s*sub\s+(\w+)/ and $sub{$package}->{$1} = 1; - -$. = 0 if eof; -$package = 'main' if eof; - +if (eof) { + $. = 0; +# $package = "_ano_$ARGV[0]"; +} sub add_call { $_[0] =~ /^\d/ and return; @@ -111,13 +127,17 @@ sub add_use { my ($path, $f) = "$p.pm" =~ /(.*::)?(.*)/; $path =~ s|::|/|g; - $path{$p} = updirs($path{$package}, (($package =~ tr/://) / 2)) . $path || "./"; - if (-e "$path{$p}$f") { - push @ARGV, "$path{$p}$f"; -# err("added package $p", info()); - } else { - err("can't find package $p", info()); + $path{$p} = updirs($path{$package}, (($package =~ tr/://) / 2)); + foreach ($path{$p}, @INC) { + $_ .= "/" if !m|/$|; + my $file = "$_$path$f"; + if (-e $file) { + push @ARGV, $file; + $file2package{$file} = $p; + return; + } } + err("can't find package $p", info()); } #sub add_usevar { @@ -151,13 +171,19 @@ sub warn_ { } END { - $export_tags{common}->{common}->{'_'} = 1; # hack!!! + foreach my $package (reverse @re_exported) { + my $h = $export{$package} ||= {}; + foreach (keys %{$use{$package}}) { + %$h = (%$h, %{$export{$_}}, map { %$_ } values %{$export_tags{$_}}); + } + } + while (my ($package, $v) = each %use) { while (my ($k, $s) = each %$v) { @$s and defined($export_tags{$k}) || err("package $k does not export tags"); foreach (@$s) { s/\"//g; - s/^:// or err("<<use $k qw($s ...)>> should be <<use $k qw(:$s ...)>>", $use_info{$package}->{$k}); + s/^:// or err("<<use $k qw(@$s ...)>> should be <<use $k qw(:@$s ...)>>", $use_info{$package}->{$k}); exists $export_tags{$k}->{$_} or err("package $k does not export tag $_", $use_info{$package}->{$k}); } |