This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deparse inverted for(;;) cond more correctly
[perl5.git] / lib / diagnostics.pm
index d6a5caf..40c6748 100644 (file)
@@ -194,6 +194,7 @@ our $TRACEONLY = 0;
 our $WARNTRACE = 0;
 
 use Config;
+use Text::Tabs 'expand';
 my $privlib = $Config{privlibexp};
 if ($^O eq 'VMS') {
     require VMS::Filespec;
@@ -208,7 +209,6 @@ unshift @trypod, "./pod/perldiag.pod" if -e "pod/perldiag.pod";
 (my $PODFILE) = ((grep { -e } @trypod), $trypod[$#trypod])[0];
 
 $DEBUG ||= 0;
-my $WHOAMI = ref bless [];  # nobody's business, prolly not even mine
 
 local $| = 1;
 local $_;
@@ -238,7 +238,7 @@ CONFIG: {
 
     if (caller) {
        INCPATH: {
-           for my $file ( (map { "$_/$WHOAMI.pm" } @INC), $0) {
+           for my $file ( (map { "$_/".__PACKAGE__.".pm" } @INC), $0) {
                warn "Checking $file\n" if $DEBUG;
                if (open(POD_DIAG, $file)) {
                    while (<POD_DIAG>) {
@@ -367,6 +367,7 @@ my %msg;
                {
                    next;
                }
+               $_ = expand $_;
                s/^/    /gm;
                $msg{$header} .= $_;
                for my $h(@headers) { $msg{$h} .= $_ }
@@ -450,7 +451,7 @@ my %msg;
             $transfmt{$header}{len} = length( $header );
        } 
 
-       print STDERR "$WHOAMI: Duplicate entry: \"$header\"\n"
+       print STDERR __PACKAGE__.": Duplicate entry: \"$header\"\n"
            if $msg{$header};
 
        $msg{$header} = '';
@@ -538,7 +539,7 @@ sub disable {
 
 sub warn_trap {
     my $warning = $_[0];
-    if (caller eq $WHOAMI or !splainthis($warning)) {
+    if (caller eq __PACKAGE__ or !splainthis($warning)) {
        if ($WARNTRACE) {
            print STDERR Carp::longmess($warning);
        } else {
@@ -563,7 +564,9 @@ sub death_trap {
     }
 
     splainthis($exception) unless $in_eval;
-    if (caller eq $WHOAMI) { print STDERR "INTERNAL EXCEPTION: $exception"; } 
+    if (caller eq __PACKAGE__) {
+       print STDERR "INTERNAL EXCEPTION: $exception";
+    } 
     &$olddie if defined $olddie and $olddie and $olddie ne \&death_trap;
 
     return if $in_eval;