X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fdiagnostics.pm;h=1ba70c5b6c4502011209f01bcf40bb11ae2d3f79;hb=1ba7855cf16acea00cbf0cf8bbc7fbe37b8ac919;hp=b027b74dc308e5019fd5e88b3ac71ec8035ac8a4;hpb=5cd5c4227e98c1aba00f926c07010f476cdbbf55;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/diagnostics.pm b/lib/diagnostics.pm index b027b74..1ba70c5 100755 --- a/lib/diagnostics.pm +++ b/lib/diagnostics.pm @@ -4,7 +4,7 @@ package diagnostics; diagnostics - Perl compiler pragma to force verbose warning diagnostics -splain - standalone program to do the same thing +splain - filter to produce verbose descriptions of perl warning diagnostics =head1 SYNOPSIS @@ -16,7 +16,7 @@ As a pragma: enable diagnostics; disable diagnostics; -Aa a program: +As a program: perl program 2>diag.out splain [-v] [-p] diag.out @@ -168,10 +168,10 @@ Tom Christiansen >, 25 June 1995. =cut use strict; -use 5.005_64; +use 5.006; use Carp; -our $VERSION = 1.0; +our $VERSION = 1.1; our $DEBUG; our $VERBOSE; our $PRETTY; @@ -195,6 +195,12 @@ my @trypod = ( unshift @trypod, "./pod/perldiag.pod" if -e "pod/perldiag.pod"; (my $PODFILE) = ((grep { -e } @trypod), $trypod[$#trypod])[0]; +if ($^O eq 'MacOS') { + # just updir one from each lib dir, we'll find it ... + ($PODFILE) = grep { -e } map { "$_:pod:perldiag.pod" } @INC; +} + + $DEBUG ||= 0; my $WHOAMI = ref bless []; # nobody's business, prolly not even mine @@ -405,7 +411,7 @@ sub import { shift; $^W = 1; # yup, clobbered the global variable; # tough, if you want diags, you want diags. - return if $SIG{__WARN__} eq \&warn_trap; + return if defined $SIG{__WARN__} && ($SIG{__WARN__} eq \&warn_trap); for (@_) { @@ -470,11 +476,18 @@ sub death_trap { if (caller eq $WHOAMI) { print STDERR "INTERNAL EXCEPTION: $exception"; } &$olddie if defined $olddie and $olddie and $olddie ne \&death_trap; + return if $in_eval; + # We don't want to unset these if we're coming from an eval because - # then we've turned off diagnostics. (Actually what does this next - # line do? -PSeibel) - $SIG{__DIE__} = $SIG{__WARN__} = '' unless $in_eval; + # then we've turned off diagnostics. + + # Switch off our die/warn handlers so we don't wind up in our own + # traps. + $SIG{__DIE__} = $SIG{__WARN__} = ''; + + # Have carp skip over death_trap() when showing the stack trace. local($Carp::CarpLevel) = 1; + confess "Uncaught exception from user code:\n\t$exception"; # up we go; where we stop, nobody knows, but i think we die now # but i'm deeply afraid of the &$olddie guy reraising and us getting