summaryrefslogtreecommitdiff
path: root/dump.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-07-29 18:57:11 +0100
committerDavid Mitchell <davem@iabyn.com>2010-07-29 18:57:11 +0100
commit002beaef76a1595af2e39ffd4cd55c595bd6c271 (patch)
treed1ea2bbfa1efce0dac3f1741c44a21244be451fc /dump.c
parentcdb996f424d39d435ae0f0a024fbf20c38221b9e (diff)
downloadperl-002beaef76a1595af2e39ffd4cd55c595bd6c271.tar.gz
Perl_do_sv_dump: alert when skipping elements
When dumping an HV, we skip dumping the elements if the iterator is already in use. Explain this in the dump output so people like me aren't left wondering why the elements have vanished.
Diffstat (limited to 'dump.c')
-rw-r--r--dump.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/dump.c b/dump.c
index 843eb88ec5..eeb43be961 100644
--- a/dump.c
+++ b/dump.c
@@ -1884,29 +1884,34 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
}
}
}
- if (nest < maxnest && !HvEITER_get(sv)) { /* Try to preserve iterator */
- HE *he;
- HV * const hv = MUTABLE_HV(sv);
- int count = maxnest - nest;
-
- hv_iterinit(hv);
- while ((he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS))
- && count--) {
- STRLEN len;
- const U32 hash = HeHASH(he);
- SV * const keysv = hv_iterkeysv(he);
- const char * const keypv = SvPV_const(keysv, len);
- SV * const elt = hv_iterval(hv, he);
-
- 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, 6 * SvCUR(keysv), UNI_DISPLAY_QQ));
- if (HeKREHASH(he))
- PerlIO_printf(file, "[REHASH] ");
- PerlIO_printf(file, "HASH = 0x%"UVxf"\n", (UV)hash);
- do_sv_dump(level+1, file, elt, nest+1, maxnest, dumpops, pvlim);
+ if (nest < maxnest) {
+ if (HvEITER_get(sv)) /* preserve iterator */
+ Perl_dump_indent(aTHX_ level, file,
+ " (*** Active iterator; skipping element dump ***)\n");
+ else {
+ HE *he;
+ HV * const hv = MUTABLE_HV(sv);
+ int count = maxnest - nest;
+
+ hv_iterinit(hv);
+ while ((he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS))
+ && count--) {
+ STRLEN len;
+ const U32 hash = HeHASH(he);
+ SV * const keysv = hv_iterkeysv(he);
+ const char * const keypv = SvPV_const(keysv, len);
+ SV * const elt = hv_iterval(hv, he);
+
+ 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, 6 * SvCUR(keysv), UNI_DISPLAY_QQ));
+ if (HeKREHASH(he))
+ PerlIO_printf(file, "[REHASH] ");
+ 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 */
}
- hv_iterinit(hv); /* Return to status quo */
}
break;
case SVt_PVCV: