From: M.J.T. Guy Date: Fri, 21 Mar 1997 09:58:17 +0000 (+0000) Subject: Re: NUL in die and other messages X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=52a267c574cb66c4bc35601dcf148a1d7a3bc557;p=p5sagit%2Fp5-mst-13.2.git Re: NUL in die and other messages There has been no response to this on p5p, Chip hasn't included it in his "More seeds of _94" and I can't find it on the archive. So I suppose it got lost. I note that the patch needs to be merged with a more recently posted one handling references. p5p-msgid: E0w815V-0005xs-00@ursa.cus.cam.ac.uk --- diff --git a/lib/Carp.pm b/lib/Carp.pm index ec08d30..7c8932c 100644 --- a/lib/Carp.pm +++ b/lib/Carp.pm @@ -70,7 +70,7 @@ sub longmess { $_ = "undef", next unless defined $_; s/'/\\'/g; substr($_,$MaxArgLen) = '...' if $MaxArgLen and $MaxArgLen < length; - s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/; + $_ = "'$_'" unless /^-?[\d.]+$/; s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg; s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg; } @@ -81,7 +81,10 @@ sub longmess { } $error = "called"; } - $mess || $error; + # this kludge circumvents die's incorrect handling of NUL + my $msg = $mess ||= $error; + $msg =~ s/\0//g; + return $msg; } sub shortmess { # Short-circuit &longmess if called via multiple packages @@ -113,7 +116,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") =~ s/\0//g; + return $msg; } } continue {