Very old debugger UTF-8 bug
[p5sagit/p5-mst-13.2.git] / lib / dumpvar.pl
index 51e9c88..34a9c59 100644 (file)
@@ -44,6 +44,12 @@ sub unctrl {
        $_;
 }
 
+sub uniescape {
+    join("",
+        map { $_ > 255 ? sprintf("\\x{%04X}", $_) : chr($_) }
+            unpack("U*", $_[0]));
+}
+
 sub stringify {
        local($_,$noticks) = @_;
        local($v) ; 
@@ -67,6 +73,7 @@ sub stringify {
        } elsif ($unctrl eq 'unctrl') {
          s/([\"\\])/\\$1/g ;
          s/([\000-\037\177])/'^'.pack('c',ord($1)^64)/eg;
+         # uniescape?
          s/([\200-\377])/'\\0x'.sprintf('%2X',ord($1))/eg 
            if $quoteHighBit;
        } elsif ($unctrl eq 'quote') {
@@ -74,6 +81,7 @@ sub stringify {
          s/\033/\\e/g;
          s/([\000-\037\177])/'\\c'.chr(ord($1)^64)/eg;
        }
+       $_ = uniescape($_);
        s/([\200-\377])/'\\'.sprintf('%3o',ord($1))/eg if $quoteHighBit;
        ($noticks || /^\d+(\.\d*)?\Z/) 
          ? $_ 
@@ -187,7 +195,7 @@ sub unwrap {
        $tArrayDepth = $#{$v} ; 
        undef $more ; 
        $tArrayDepth = $#{$v} < $arrayDepth-1 ? $#{$v} : $arrayDepth-1 
-         unless  $arrayDepth eq '' ; 
+         if defined $arrayDepth && $arrayDepth ne '';
        $more = "....\n" if $tArrayDepth < $#{$v} ; 
        $shortmore = "";
        $shortmore = " ..." if $tArrayDepth < $#{$v} ;