consistently escape args in Carp stack trace
authorZefram <zefram@fysh.org>
Sat, 24 Aug 2013 17:00:36 +0000 (18:00 +0100)
committerZefram <zefram@fysh.org>
Sat, 24 Aug 2013 17:30:26 +0000 (18:30 +0100)
commit6ffbec2cd29e785d261db81981f995698c1e187c
tree52a087810c26dc7d8101368574e0e22e0c31cd91
parent4d106cc5d8fd328d39b1db3c57572dd3dec915b5
consistently escape args in Carp stack trace

Previously, an upgraded string argument would be wrapped in quote
characters but have all of its characters represented literally in
the stack trace, including control characters.  Also, the escaping of
unprintable characters for downgraded string arguments wasn't consistent
with Perl syntax: it used \x{} escapes inside single quotes.

The new way is that string arguments (except those that look numeric)
are represented as double-quoted strings, using correct Perl syntax.
Characters outside the ASCII printable range always get \x{} escaping,
whether the string is upgraded or downgraded.  ASCII printables that
require backslash escaping get it.  Where an argument is truncated
due to length, the added ellipsis appears outside the double quotes,
to avoid ambiguity with a string that contains actual dots.

Implementing this is complicated by problems with applying regexps to
upgraded strings, which are particularly a problem in the constrained
environment in which Carp must run.  This has previously inhibited us
from implementing correct handling of upgraded strings.  The problems
were all resolved in Perl 5.13.11, so from there on we can just use the
simple regexp implementation.  On older Perls upgraded strings now get
the same treatment, but implemented in a less efficient manner that does
not use regexps.

Non-string arguments, most notably references, are now are not represented
as quoted strings.  The overload::StrVal() representation is safely
distinct from other argument representations.  This in particular allows
distinguishing between an argument that is a reference and an argument
that is the result of stringifying a reference.
MANIFEST
dist/Carp/lib/Carp.pm
dist/Carp/t/Carp.t
dist/Carp/t/Carp_overload.t
dist/Carp/t/arg_string.t [new file with mode: 0644]
dist/Carp/t/vivify_gv.t
dist/Carp/t/vivify_stash.t
pod/perldelta.pod