On Tue, Aug 12, 2003 at 10:34:58AM +0200, Roderich Schupp wrote:
> - What's the purpose of this line for %Preload
>     'Tk.pm'                         => [qw( Tk/FileSelect.pm )],

I don't really know.  I think it was from perl2exe's heuristics base.

>   The line in scan_chunk should probably only trigger if ScanDeps
>   has already encountered Tk.pm or any Tk/*.pm.

That sounds like a sane idea.  Can you test the patch below a bit,
and let me know if there's anything still missing?

Alternatively, a snapshot that contains the same patch is available at:

    http://aut.dyndns.org/tmp/Module-ScanDeps.tar.gz
    MD5 (Module-ScanDeps.tar.gz) = b78d916bff0d2dcee19d23fa350f4ec7

Thanks,
/Autrijus/

==== //member/autrijus/Module-ScanDeps/ScanDeps.pm#39 - 
/home/autrijus/member/autrijus/Module-ScanDeps/ScanDeps.pm ====
@@ -118,9 +118,11 @@
 =head2 B<scan_chunk>
 
     $module = scan_chunk($chunk);
+    @modules = scan_chunk($chunk);
 
-Apply various heuristics to C<$chunk> to find and return the module name
-it contains, or C<undef> if nothing were found.
+Apply various heuristics to C<$chunk> to find and return the module
+name(s) it contains.  In scalar context, returns only the first module
+or C<undef>.
 
 =head2 B<add_deps>
 
@@ -143,6 +145,8 @@
 
 =cut
 
+my $SeenTk;
+
 # Pre-loaded module dependencies {{{
 my %Preload = (
     'AnyDBM_File.pm'               => [qw( SDBM_File.pm )],
@@ -198,7 +202,10 @@
     )],
     'Template.pm'                  => 'sub',
     'Term/ReadLine.pm'             => 'sub',
-    'Tk.pm'                        => [qw( Tk/FileSelect.pm )],
+    'Tk.pm'                        => sub {
+       $SeenTk = 1;
+       'Tk/FileSelect.pm';
+    },
     'Tk/Balloon.pm'                => [qw( Tk/balArrow.xbm )],
     'Tk/BrowseEntry.pm'                    => [qw( Tk/cbxarrow.xbm )],
     'Tk/ColorEditor.pm'                    => [qw( Tk/ColorEdit.xpm )],
@@ -254,6 +261,7 @@
        local *FH;
        open FH, $file or die "Cannot open $file: $!";
 
+       $SeenTk = 0;
         # Line-by-line scanning {{{
        LINE: while (<FH>) {
            chomp;
@@ -326,8 +334,7 @@
            next;
        }
 
-       my $module = scan_chunk($_) or next;
-       $found{$module}++;
+       $found{$_}++ for scan_chunk($_);
     }
 
     return sort keys %found;
@@ -352,11 +359,24 @@
        return $1 if /(?:^|\s)(?:do|require)\s+[^']*'(.*?)'/;
        return $1 if /[^\$]\b([\w:]+)->\w/ and $1 ne 'Tk';
        return $1 if /([\w:]+)::\w/ and $1 ne 'Tk' and $1 ne 'PAR';
+
+       if ($SeenTk) {
+           my @modules;
+           while (/->\s*([A-Z]\w+)/g) {
+               push @modules, "Tk/$1.pm";
+           }
+           while (/->\s*Scrolled\s*\[^A-Z]*([A-Z]\w+)/g) {
+               push @modules, "Tk/$1.pm";
+               push @modules, "Tk/Scrollbar.pm";
+           }
+           return [EMAIL PROTECTED];
+       }
        return;
     };
     # }}}
 
     return unless defined($module);
+    return wantarray ? @$module : $module->[0] if ref($module);
 
     $module =~ s/^['"]//;
     return unless $module =~ /^\w/;

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to