X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fdumpvar.pl;h=43e107ff5f6b55f53a2acfac2559ad032724befa;hb=9a66ea416324d5cd1459c59e545b38c9c889fdaa;hp=474818a657183ed51c9be4307d277c85ed2b71d7;hpb=f338af47923def4d535e1fd32a0aeee66b1f733b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/dumpvar.pl b/lib/dumpvar.pl index 474818a..43e107f 100644 --- a/lib/dumpvar.pl +++ b/lib/dumpvar.pl @@ -80,7 +80,7 @@ sub stringify { } elsif ($unctrl eq 'quote') { s/([\"\\\$\@])/\\$1/g if $tick eq '"'; s/\033/\\e/g; - s/([\000-\037\177])/'\\c'.chr(ord($1)^64)/eg; + s/([\000-\037\177])/'\\c'._escaped_ord($1)/eg; } $_ = uniescape($_); s/([\200-\377])/'\\'.sprintf('%3o',ord($1))/eg if $quoteHighBit; @@ -89,6 +89,14 @@ sub stringify { : $tick . $_ . $tick; } +# Ensure a resulting \ is escaped to be \\ +sub _escaped_ord { + my $chr = shift; + $chr = chr(ord($chr)^64); + $chr =~ s{\\}{\\\\}g; + return $chr; +} + sub ShortArray { my $tArrayDepth = $#{$_[0]} ; $tArrayDepth = $#{$_[0]} < $arrayDepth-1 ? $#{$_[0]} : $arrayDepth-1