testsuite nits
[p5sagit/p5-mst-13.2.git] / dump.c
diff --git a/dump.c b/dump.c
index 44a9142..8f90e60 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -1,6 +1,6 @@
 /*    dump.c
  *
- *    Copyright (c) 1991-1997, Larry Wall
+ *    Copyright (c) 1991-1999, Larry Wall
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -267,7 +267,7 @@ sv_peek(SV *sv)
        if (!SvPVX(sv))
            sv_catpv(t, "(null)");
        else {
-           SV *tmp = newSVpv("", 0);
+           SV *tmp = newSVpvn("", 0);
            sv_catpv(t, "(");
            if (SvOOK(sv))
                sv_catpvf(t, "[%s]", pv_display(tmp, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, 127));
@@ -318,7 +318,7 @@ do_pmop_dump(I32 level, PerlIO *file, PMOP *pm)
        op_dump(pm->op_pmreplroot);
     }
     if (pm->op_pmflags || (pm->op_pmregexp && pm->op_pmregexp->check_substr)) {
-       SV *tmpsv = newSVpv("", 0);
+       SV *tmpsv = newSVpvn("", 0);
        if (pm->op_pmdynflags & PMdf_USED)
            sv_catpv(tmpsv, ",USED");
        if (pm->op_pmdynflags & PMdf_TAINTED)
@@ -388,7 +388,7 @@ do_op_dump(I32 level, PerlIO *file, OP *o)
     dump_indent(level, file, "ADDR = 0x%lx => 0x%lx\n",o, o->op_next);
 #endif
     if (o->op_flags) {
-       SV *tmpsv = newSVpv("", 0);
+       SV *tmpsv = newSVpvn("", 0);
        switch (o->op_flags & OPf_WANT) {
        case OPf_WANT_VOID:
            sv_catpv(tmpsv, ",VOID");
@@ -419,7 +419,7 @@ do_op_dump(I32 level, PerlIO *file, OP *o)
        SvREFCNT_dec(tmpsv);
     }
     if (o->op_private) {
-       SV *tmpsv = newSVpv("", 0);
+       SV *tmpsv = newSVpvn("", 0);
        if (o->op_type == OP_AASSIGN) {
            if (o->op_private & OPpASSIGN_COMMON)
                sv_catpv(tmpsv, ",COMMON");
@@ -632,10 +632,8 @@ do_magic_dump(I32 level, PerlIO *file, MAGIC *mg, I32 nest, I32 maxnest, bool du
 #ifdef USE_LOCALE_COLLATE
            else if (v == &PL_vtbl_collxfrm)   s = "collxfrm";
 #endif
-#ifdef OVERLOAD
            else if (v == &PL_vtbl_amagic)     s = "amagic";
            else if (v == &PL_vtbl_amagicelem) s = "amagicelem";
-#endif
            if (s)
                dump_indent(level, file, "    MG_VIRTUAL = &PL_vtbl_%s\n", s);
            else
@@ -673,7 +671,7 @@ do_magic_dump(I32 level, PerlIO *file, MAGIC *mg, I32 nest, I32 maxnest, bool du
         if (mg->mg_ptr) {
            dump_indent(level, file, "    MG_PTR = 0x%lx", (long)mg->mg_ptr);
            if (mg->mg_len >= 0) {
-               SV *sv = newSVpv("", 0);
+               SV *sv = newSVpvn("", 0);
                 PerlIO_printf(file, " %s", pv_display(sv, mg->mg_ptr, mg->mg_len, 0, pvlim));
                SvREFCNT_dec(sv);
             }
@@ -769,9 +767,7 @@ do_sv_dump(I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops,
     if (flags & SVf_FAKE)      sv_catpv(d, "FAKE,");
     if (flags & SVf_READONLY)  sv_catpv(d, "READONLY,");
 
-#ifdef OVERLOAD
     if (flags & SVf_AMAGIC)    sv_catpv(d, "OVERLOAD,");
-#endif /* OVERLOAD */
     if (flags & SVp_IOK)       sv_catpv(d, "pIOK,");
     if (flags & SVp_NOK)       sv_catpv(d, "pNOK,");
     if (flags & SVp_POK)       sv_catpv(d, "pPOK,");
@@ -896,8 +892,8 @@ do_sv_dump(I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops,
            if (SvOOK(sv))
                PerlIO_printf(file, "( %s . ) ", pv_display(d, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, pvlim));
            PerlIO_printf(file, "%s\n", pv_display(d, SvPVX(sv), SvCUR(sv), SvLEN(sv), pvlim));
-           dump_indent(level, file, "  CUR = 0\n", (long)SvCUR(sv));
-           dump_indent(level, file, "  LEN = 0\n", (long)SvLEN(sv));
+           dump_indent(level, file, "  CUR = %ld\n", (long)SvCUR(sv));
+           dump_indent(level, file, "  LEN = %ld\n", (long)SvLEN(sv));
        }
        else
            dump_indent(level, file, "  PV = 0\n");
@@ -1104,14 +1100,20 @@ do_sv_dump(I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops,
        dump_indent(level, file, "  PAGE = %ld\n", (long)IoPAGE(sv));
        dump_indent(level, file, "  PAGE_LEN = %ld\n", (long)IoPAGE_LEN(sv));
        dump_indent(level, file, "  LINES_LEFT = %ld\n", (long)IoLINES_LEFT(sv));
-       dump_indent(level, file, "  TOP_NAME = \"%s\"\n", IoTOP_NAME(sv));
+        if (IoTOP_NAME(sv))
+            dump_indent(level, file, "  TOP_NAME = \"%s\"\n", IoTOP_NAME(sv));
        do_gv_dump (level, file, "  TOP_GV", IoTOP_GV(sv));
-       dump_indent(level, file, "  FMT_NAME = \"%s\"\n", IoFMT_NAME(sv));
+        if (IoFMT_NAME(sv))
+            dump_indent(level, file, "  FMT_NAME = \"%s\"\n", IoFMT_NAME(sv));
        do_gv_dump (level, file, "  FMT_GV", IoFMT_GV(sv));
-       dump_indent(level, file, "  BOTTOM_NAME = \"%s\"\n", IoBOTTOM_NAME(sv));
+        if (IoBOTTOM_NAME(sv))
+            dump_indent(level, file, "  BOTTOM_NAME = \"%s\"\n", IoBOTTOM_NAME(sv));
        do_gv_dump (level, file, "  BOTTOM_GV", IoBOTTOM_GV(sv));
        dump_indent(level, file, "  SUBPROCESS = %ld\n", (long)IoSUBPROCESS(sv));
-       dump_indent(level, file, "  TYPE = %c\n", IoTYPE(sv));
+       if (isPRINT(IoTYPE(sv)))
+            dump_indent(level, file, "  TYPE = '%c'\n", IoTYPE(sv));
+       else
+            dump_indent(level, file, "  TYPE = '\\%o'\n", IoTYPE(sv));
        dump_indent(level, file, "  FLAGS = 0x%lx\n", (long)IoFLAGS(sv));
        break;
     }