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.