diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-10-06 10:23:26 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-10-06 10:23:26 +0000 |
commit | 7fddd94457983d86b562b409f0a846c0a764f8d7 (patch) | |
tree | 58edf1082167bfbff71447af78ea3b954d188681 /dump.c | |
parent | a5849ce59200ae4eedc45d2d16a7d1a3b6fc0ee2 (diff) | |
download | perl-7fddd94457983d86b562b409f0a846c0a764f8d7.tar.gz |
Revert one hunk of change 32034 that had the possibility of being buggy
(the sprintf "%c" code will work correctly when the SV is UTF-8).
Audit all the rest for UTF-8 correctness, and force SvUTF-8_off() in
utf8.c to ensure correctness. (The string is reset to "", so this will
not be a behaviour change.)
p4raw-id: //depot/perl@32040
Diffstat (limited to 'dump.c')
-rw-r--r-- | dump.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -219,8 +219,10 @@ Perl_pv_escape( pTHX_ SV *dsv, char const * const str, const char * const end = pv + count; /* end of string */ octbuf[0] = esc; - if (!flags & PERL_PV_ESCAPE_NOCLEAR) + if (!flags & PERL_PV_ESCAPE_NOCLEAR) { + /* This won't alter the UTF-8 flag */ sv_setpvn(dsv, "", 0); + } if ((flags & PERL_PV_ESCAPE_UNI_DETECT) && is_utf8_string((U8*)pv, count)) isuni = 1; @@ -279,8 +281,13 @@ Perl_pv_escape( pTHX_ SV *dsv, char const * const str, sv_catpvn(dsv, octbuf, chsize); wrote += chsize; } else { - const char string = (char) c; - sv_catpvn(dsv, &string, 1); + /* If PERL_PV_ESCAPE_NOBACKSLASH is set then bytes in the range + 128-255 can be appended raw to the dsv. If dsv happens to be + UTF-8 then we need catpvf to upgrade them for us. + Or add a new API call sv_catpvc(). Think about that name, and + how to keep it clear that it's unlike the s of catpvs, which is + really an array octets, not a string. */ + Perl_sv_catpvf( aTHX_ dsv, "%c", c); wrote++; } if ( flags & PERL_PV_ESCAPE_FIRSTCHAR ) |