sub violates_dynamic {
my ($self, undef, $doc) = @_;
- my $src;
-
+ my ($src, $file);
if ($doc->isa('PPI::Document::File')) {
- my $file = $doc->filename;
+ $file = $doc->filename;
open my $fh, '<', $file
or do { require Carp; Carp::confess("Can't open $file for reading: $!") };
$src = do { local $/; <$fh> };
} else {
- $src = $doc->serialize;
+ $file = '(eval 0)';
+ $src = $doc->serialize;
}
+ $file =~ s/(?<!\\)((\\\\)*)"/$1\\"/g;
+
my @errs;
- my $offset = 6;
my $wrapper = <<" WRAPPER";
{
return;
no indirect hook => sub { push \@errs, [ \@_ ] };
{
;
+#line 1 "$file"
$src
}
}
my %errs_tags;
for (@errs) {
my ($obj, $meth, $line) = @$_[0, 1, 3];
- $line -= $offset;
my $tag = join "\0", $line, $meth, $tag_obj->($obj);
push @{$errs_tags{$tag}}, [ $obj, $meth ];
}