clean up perlocal.pod output on VMS
[p5sagit/p5-mst-13.2.git] / lib / Carp.pm
index de58648..c0cfe08 100644 (file)
@@ -37,7 +37,7 @@ require Exporter;
 @EXPORT = qw(confess croak carp);
 
 sub longmess {
-    my $error = shift;
+    my $error = join '', @_;
     my $mess = "";
     my $i = 1 + $CarpLevel;
     my ($pack,$file,$line,$sub,$hargs,$eval,$require);
@@ -68,9 +68,16 @@ sub longmess {
              }
              for (@a) {
                $_ = "undef", next unless defined $_;
-               s/'/\\'/g;
-               substr($_,$MaxArgLen) = '...' if $MaxArgLen and $MaxArgLen < length;
-               s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
+               if (ref $_) {
+                 $_ .= '';
+                 s/'/\\'/g;
+               }
+               else {
+                 s/'/\\'/g;
+                 substr($_,$MaxArgLen) = '...'
+                   if $MaxArgLen and $MaxArgLen < length;
+               }
+               $_ = "'$_'" unless /^-?[\d.]+$/;
                s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
                s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
              }
@@ -81,11 +88,14 @@ sub longmess {
        }
        $error = "called";
     }
-    $mess || $error;
+    # this kludge circumvents die's incorrect handling of NUL
+    my $msg = \($mess || $error);
+    $$msg =~ tr/\0//d;
+    $$msg;
 }
 
 sub shortmess {        # Short-circuit &longmess if called via multiple packages
-    my $error = $_[0]; # Instead of "shift"
+    my $error = join '', @_;
     my ($prevpack) = caller(1);
     my $extra = $CarpLevel;
     my $i = 2;
@@ -113,7 +123,9 @@ sub shortmess {     # Short-circuit &longmess if called via multiple packages
                if(defined @{$pack . "::ISA"});
        }
        else {
-           return "$error at $file line $line\n";
+           # this kludge circumvents die's incorrect handling of NUL
+           (my $msg = "$error at $file line $line\n") =~ tr/\0//d;
+           return $msg;
        }
     }
     continue {