/usr/share/perl5/Method/Signatures/Utils.pm is in libmethod-signatures-perl 20170211-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | package Method::Signatures::Utils;
use strict;
use warnings;
use Carp;
use base qw(Exporter);
our @EXPORT = qw(new_ppi_doc sig_parsing_error carp_location_for DEBUG);
sub DEBUG {
return unless $Method::Signatures::DEBUG;
require Data::Dumper;
local $Data::Dumper::Sortkeys = 1;
print STDERR "DEBUG: ", map { ref $_ ? Data::Dumper::Dumper($_) : $_ } @_;
}
sub new_ppi_doc {
my $code = shift;
require PPI;
my $ppi = PPI::Document->new($code) or
sig_parsing_error(
"source '$$code' cannot be parsed by PPI: " . PPI::Document->errstr
);
return $ppi;
};
# Generate cleaner error messages...
sub carp_location_for {
my ($class, $target) = @_;
$target = qr{(?!)} if !$target;
# using @CARP_NOT here even though we're not using Carp
# who knows? maybe someday Carp will be capable of doing what we want
# until then, we're rolling our own, but @CARP_NOT is still serving roughly the same purpose
our @CARP_NOT;
local @CARP_NOT;
push @CARP_NOT, 'Method::Signatures';
push @CARP_NOT, $class unless $class =~ /^${\__PACKAGE__}(::|$)/;
push @CARP_NOT, qw< Class::MOP Moose Mouse Devel::Declare >;
# Skip any package in the @CARP_NOT list or their sub packages.
my $carp_not_list_re = join '|', @CARP_NOT;
my $skip = qr/^ $carp_not_list_re (?: :: | $ ) /x;
my $level = 0;
my ($pack, $file, $line, $method);
do {
($pack, $file, $line, $method) = caller(++$level);
} while $method !~ $target and $method =~ /$skip/ or $pack =~ /$skip/;
return ($file, $line, $method);
}
sub sig_parsing_error {
my ($file, $line) = carp_location_for(__PACKAGE__, 'Devel::Declare::linestr_callback');
my $msg = join('', @_, " in declaration at $file line $line.\n");
die($msg);
}
1;
|