summaryrefslogtreecommitdiff
path: root/lib/diagnostics.pm
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-12-26 20:39:19 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-12-26 20:39:19 -0800
commit0a437bc972cff19c42a0efc0b585280e585f3058 (patch)
treed9e2cc57cf13be81e0dc7280a073a55fc721513f /lib/diagnostics.pm
parent33327ed8afe36c0226d45c7e93346669d395a14a (diff)
downloadperl-0a437bc972cff19c42a0efc0b585280e585f3058.tar.gz
Add support for multiline messages to splain
All the ‘Compilation failed’ messages are actually multiline mes- sages, like "Attempt to reload foo aborted.\nCompilation failed in require at ...". perldiag has separate entries for each line of the message, so it makes sense to have it look up each line. It can’t split it into lines by default, but must check for a possible description first, as sometimes syntax errors quote code with line breaks in it. I had to rip out the nasty file-wide lexical $_, as I couldn’t local- ise it, and I undid d923656e4 in the process.
Diffstat (limited to 'lib/diagnostics.pm')
-rw-r--r--lib/diagnostics.pm22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/diagnostics.pm b/lib/diagnostics.pm
index 2421c6ffdf..b8effa8079 100644
--- a/lib/diagnostics.pm
+++ b/lib/diagnostics.pm
@@ -216,7 +216,7 @@ $DEBUG ||= 0;
my $WHOAMI = ref bless []; # nobody's business, prolly not even mine
local $| = 1;
-my $_;
+local $_;
local $.;
my $standalone;
@@ -319,6 +319,7 @@ my %msg;
{
print STDERR "FINISHING COMPILATION for $_\n" if $DEBUG;
local $/ = '';
+ local $_;
my $header;
my @headers;
my $for_item;
@@ -587,8 +588,8 @@ my %old_diag;
my $count;
my $wantspace;
sub splainthis {
- return 0 if $TRACEONLY;
- $_ = shift;
+ return 0 if $TRACEONLY;
+ for (my $tmp = shift) {
local $\;
local $!;
### &finish_compilation unless %msg;
@@ -623,17 +624,25 @@ sub splainthis {
return 0 unless &transmo;
}
- $orig = shorten($orig);
+ my $short = shorten($orig);
if ($old_diag{$_}) {
autodescribe();
- print THITHER "$orig (#$old_diag{$_})\n";
+ print THITHER "$short (#$old_diag{$_})\n";
$wantspace = 1;
+ } elsif (!$msg{$_} && $orig =~ /\n./s) {
+ # A multiline message, like "Attempt to reload /
+ # Compilation failed"
+ my $found;
+ for (split /^/, $orig) {
+ splainthis($_) and $found = 1;
+ }
+ return $found;
} else {
autodescribe();
$old_diag{$_} = ++$count;
print THITHER "\n" if $wantspace;
$wantspace = 0;
- print THITHER "$orig (#$old_diag{$_})\n";
+ print THITHER "$short (#$old_diag{$_})\n";
if ($msg{$_}) {
print THITHER $msg{$_};
} else {
@@ -646,6 +655,7 @@ sub splainthis {
}
}
return 1;
+ }
}
sub autodescribe {