From: Jarkko Hietaniemi Date: Thu, 27 Sep 2001 12:05:36 +0000 (+0000) Subject: Dump Unicode hash keys also as Unicode, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=98c991d172ba25ca965007e58ce8e7c0f9910f56;p=p5sagit%2Fp5-mst-13.2.git Dump Unicode hash keys also as Unicode, not just as a byte string. p4raw-id: //depot/perl@12246 --- diff --git a/dump.c b/dump.c index 6d7c007..3d24ccb 100644 --- a/dump.c +++ b/dump.c @@ -1129,7 +1129,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo PerlIO_printf(file, "( %s . ) ", pv_display(d, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, pvlim)); PerlIO_printf(file, "%s", pv_display(d, SvPVX(sv), SvCUR(sv), SvLEN(sv), pvlim)); if (SvUTF8(sv)) /* the 8? \x{....} */ - PerlIO_printf(file, " %s", sv_uni_display(d, sv, 8 * sv_len_utf8(sv))); + PerlIO_printf(file, " [UTF8 %s]", sv_uni_display(d, sv, 8 * sv_len_utf8(sv))); PerlIO_printf(file, "\n"); Perl_dump_indent(aTHX_ level, file, " CUR = %"IVdf"\n", (IV)SvCUR(sv)); Perl_dump_indent(aTHX_ level, file, " LEN = %"IVdf"\n", (IV)SvLEN(sv)); @@ -1251,14 +1251,18 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo hv_iterinit(hv); while ((he = hv_iternext(hv)) && count--) { - SV *elt; - char *key; - I32 len; + SV *elt, *keysv; + char *keypv; + STRLEN len; U32 hash = HeHASH(he); - key = hv_iterkey(he, &len); + keysv = hv_iterkeysv(he); + keypv = SvPV(keysv, len); elt = hv_iterval(hv, he); - Perl_dump_indent(aTHX_ level+1, file, "Elt %s HASH = 0x%"UVxf"\n", pv_display(d, key, len, 0, pvlim), (UV)hash); + Perl_dump_indent(aTHX_ level+1, file, "Elt %s ", pv_display(d, keypv, len, 0, pvlim)); + if (SvUTF8(keysv)) + PerlIO_printf(file, "[UTF8 %s] ", sv_uni_display(d, keysv, 8 * sv_len_utf8(keysv))); + PerlIO_printf(file, "HASH = 0x%"UVxf"\n", (UV)hash); do_sv_dump(level+1, file, elt, nest+1, maxnest, dumpops, pvlim); } hv_iterinit(hv); /* Return to status quo */ diff --git a/ext/Devel/Peek/Peek.t b/ext/Devel/Peek/Peek.t index cd2dc6f..9e60bef 100644 --- a/ext/Devel/Peek/Peek.t +++ b/ext/Devel/Peek/Peek.t @@ -12,7 +12,7 @@ BEGIN { use Devel::Peek; -print "1..18\n"; +print "1..19\n"; our $DEBUG = 0; open(SAVERR, ">&STDERR") or die "Can't dup STDERR: $!"; @@ -322,10 +322,36 @@ do_test(18, 'SV = PV\\($ADDR\\) at $ADDR REFCNT = 1 FLAGS = \\(PADBUSY,PADTMP,POK,READONLY,pPOK,UTF8\\) - PV = $ADDR "\\\304\\\200\\\0\\\310\\\200"\\\0 "\\\x\{100\}\\\x\{0\}\\\x\{200\}" + PV = $ADDR "\\\304\\\200\\\0\\\310\\\200"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\] CUR = 5 LEN = 6'); +do_test(19, + {chr(256)=>chr(512)}, +'SV = RV\\($ADDR\\) at $ADDR + REFCNT = 1 + FLAGS = \\(ROK\\) + RV = $ADDR + SV = PVHV\\($ADDR\\) at $ADDR + REFCNT = 2 + FLAGS = \\(SHAREKEYS\\) + IV = 1 + NV = 0 + ARRAY = $ADDR \\(0:7, 1:1\\) + hash quality = 100.0% + KEYS = 1 + FILL = 1 + MAX = 7 + RITER = -1 + EITER = $ADDR + Elt "\\\304\\\200" \[UTF8 "\\\x\{100\}"\] HASH = $ADDR + SV = PV\\($ADDR\\) at $ADDR + REFCNT = 1 + FLAGS = \\(POK,pPOK,UTF8\\) + PV = $ADDR "\\\310\\\200"\\\0 \[UTF8 "\\\x\{200\}"\] + CUR = 2 + LEN = 3'); + END { 1 while unlink("peek$$"); }