… | |
… | |
156 | $re =~ s%\\[/\\]%[/\\\\]%g; # we support / and \ on all OSes, keep your fingers crossed |
156 | $re =~ s%\\[/\\]%[/\\\\]%g; # we support / and \ on all OSes, keep your fingers crossed |
157 | |
157 | |
158 | $case_tolerant |
158 | $case_tolerant |
159 | ? qr<$re>i |
159 | ? qr<$re>i |
160 | : qr<$re> |
160 | : qr<$re> |
|
|
161 | } |
|
|
162 | |
|
|
163 | sub _read_packlist { |
|
|
164 | my ($self, $root, $path) = @_; |
|
|
165 | |
|
|
166 | my $lib = $self->{lib}; |
|
|
167 | |
|
|
168 | my @packlist; |
|
|
169 | |
|
|
170 | open my $fh, "<:perlio", "$root/$path" |
|
|
171 | or die "$root/$path: $!"; |
|
|
172 | |
|
|
173 | $root = _path2match $root; |
|
|
174 | |
|
|
175 | while (<$fh>) { |
|
|
176 | chomp; |
|
|
177 | s/ .*$//; # newer-style .packlists might contain key=value pairs |
|
|
178 | |
|
|
179 | s/$root// and exists $lib->{$_} |
|
|
180 | or next; |
|
|
181 | |
|
|
182 | push @packlist, canonpath $_; |
|
|
183 | } |
|
|
184 | |
|
|
185 | \@packlist |
161 | } |
186 | } |
162 | |
187 | |
163 | sub _set_inc { |
188 | sub _set_inc { |
164 | my ($self) = @_; |
189 | my ($self) = @_; |
165 | |
190 | |
… | |
… | |
201 | |
226 | |
202 | my %packlist; |
227 | my %packlist; |
203 | |
228 | |
204 | # need to go forward here |
229 | # need to go forward here |
205 | for (@packlists) { |
230 | for (@packlists) { |
206 | my ($root, $auto) = @$_; |
231 | my $packlist = $self->_read_packlist ($_->[0], "$_->[1]/.packlist"); |
207 | |
232 | |
208 | my @packlist; |
|
|
209 | |
|
|
210 | open my $fh, "<:perlio", "$root/$auto/.packlist" |
|
|
211 | or die "$root/$auto/.packlist: $!"; |
|
|
212 | |
|
|
213 | $root = _path2match $root; |
|
|
214 | |
|
|
215 | while (<$fh>) { |
|
|
216 | chomp; |
|
|
217 | s/ .*$//; # newer-style .packlists might contain key=value pairs |
|
|
218 | |
|
|
219 | s/$root// or next; |
|
|
220 | $_ = canonpath $_; |
|
|
221 | exists $lib{$_} or next; |
|
|
222 | |
|
|
223 | push @packlist, $_; |
|
|
224 | $packlist{$_} = \@packlist; |
233 | $packlist{$_} = $packlist |
225 | } |
234 | for @$packlist; |
226 | } |
235 | } |
227 | |
236 | |
228 | $self->{lib} = \%lib; |
237 | $self->{lib} = \%lib; |
229 | $self->{packlist} = \%packlist; |
238 | $self->{packlist} = \%packlist; |
230 | $self->{matchprefix} = $matchprefix; |
239 | $self->{matchprefix} = $matchprefix; |
… | |
… | |
592 | $self->add_eval ('/\x{1234}(?<a>)\g{a}/') if $] >= 5.010; # usually covered by the regex above |
601 | $self->add_eval ('/\x{1234}(?<a>)\g{a}/') if $] >= 5.010; # usually covered by the regex above |
593 | } |
602 | } |
594 | |
603 | |
595 | =item $extractor->add_unicore |
604 | =item $extractor->add_unicore |
596 | |
605 | |
597 | Adds (hopefully) all files form the unicore database that will ever be |
606 | Adds (hopefully) all files from the unicore database that will ever be |
598 | needed. |
607 | needed. |
599 | |
608 | |
600 | If you are not sure which unicode character classes and similar unicore |
609 | If you are not sure which unicode character classes and similar unicore |
601 | databases you need, and you do not care about an extra one thousand(!) |
610 | databases you need, and you do not care about an extra one thousand(!) |
602 | files comprising 4MB of data, then you can just call this method, which |
611 | files comprising 4MB of data, then you can just call this method, which |
603 | adds basically all files from perl's unicode database. |
612 | adds basically all files from perl's unicode database. |
604 | |
613 | |
|
|
614 | Note that C<add_core_support> also adds some unicore files, but it's not a |
|
|
615 | subset of C<add_unicore> - the former adds all files neccessary to support |
|
|
616 | core builtins (which includes some unicore files and other things), while |
|
|
617 | the latter adds all unicore files (but nothing else). |
|
|
618 | |
|
|
619 | When in doubt, use both. |
|
|
620 | |
605 | =cut |
621 | =cut |
606 | |
622 | |
607 | sub add_unicore { |
623 | sub add_unicore { |
608 | my ($self) = @_; |
624 | my ($self) = @_; |
609 | |
625 | |
610 | $self->_add ([grep m%^unicore/.*\.pl$%, keys %{ $self->{lib} }]); |
626 | $self->_add ([grep m%^unicore/.*\.pl$%, keys %{ $self->{lib} }]); |
|
|
627 | } |
|
|
628 | |
|
|
629 | =item $extractor->add_core |
|
|
630 | |
|
|
631 | This adds all files from the perl core distribution, that is, all library |
|
|
632 | files that come with perl. |
|
|
633 | |
|
|
634 | This is a superset of C<add_core_support> and C<add_unicore>. |
|
|
635 | |
|
|
636 | This is quite a lot, but on the plus side, you can be sure nothing is |
|
|
637 | missing. |
|
|
638 | |
|
|
639 | This requires a full perl installation - many distributions (Debian |
|
|
640 | GNU/Linux for example) don't package all library files that perl installs. |
|
|
641 | |
|
|
642 | =cut |
|
|
643 | |
|
|
644 | sub add_core { |
|
|
645 | my ($self) = @_; |
|
|
646 | |
|
|
647 | my $lib = $self->{lib}; |
|
|
648 | |
|
|
649 | for (@{ |
|
|
650 | $self->_read_packlist ($Config{privlibexp}, ".packlist") |
|
|
651 | }) { |
|
|
652 | $self->{set}{$_} ||= [ |
|
|
653 | "$self->{libdir}/" |
|
|
654 | . ($lib->{$_} or croak "$_: unable to locate file in perl library") |
|
|
655 | ]; |
|
|
656 | } |
611 | } |
657 | } |
612 | |
658 | |
613 | =back |
659 | =back |
614 | |
660 | |
615 | =head2 GLOB-BASED ADDING AND FILTERING |
661 | =head2 GLOB-BASED ADDING AND FILTERING |
… | |
… | |
773 | # delete all extralibs.ld and extralibs.all (no clue what the latter is for) |
819 | # delete all extralibs.ld and extralibs.all (no clue what the latter is for) |
774 | delete @$set{ grep m%^\Q$self->{libdir}\E/auto/.*/extralibs\.(?:ld|all)$%s, keys %$set }; |
820 | delete @$set{ grep m%^\Q$self->{libdir}\E/auto/.*/extralibs\.(?:ld|all)$%s, keys %$set }; |
775 | |
821 | |
776 | # delete all .pod, .h, .html files (hopefully none of them are used at runtime) |
822 | # delete all .pod, .h, .html files (hopefully none of them are used at runtime) |
777 | delete @$set{ grep m%^\Q$self->{libdir}\E/.*\.(?:pod|h|html)$%s, keys %$set }; |
823 | delete @$set{ grep m%^\Q$self->{libdir}\E/.*\.(?:pod|h|html)$%s, keys %$set }; |
|
|
824 | |
|
|
825 | # delete unneeded unicore files |
|
|
826 | delete @$set{ grep m%^\Q$self->{libdir}\E/unicore/(?:mktables(?:\.lst)?|.*\.txt)$%s, keys %$set }; |
778 | } |
827 | } |
779 | |
828 | |
780 | =back |
829 | =back |
781 | |
830 | |
782 | =head2 RESULT SET |
831 | =head2 RESULT SET |