1 #define PERL_NO_GET_CONTEXT
5 /* FIXME - we should go through the code and validate what we can remove.
6 Looks like we could elimiate much of our custom utf8_to_uvchr_buf games in
7 favour of ppport.h, and likewise if we replace my_sprintf with my_snprintf
8 some more complexity dies. */
10 # define NEED_my_snprintf
11 # define NEED_sv_2pv_flags
12 # define NEED_utf8_to_uvchr_buf
16 #if PERL_VERSION_LT(5,8,0)
17 # define DD_USE_OLD_ID_FORMAT
22 # define strlcpy(d,s,l) my_strlcpy(d,s,l)
24 # define strlcpy(d,s,l) strcpy(d,s)
28 /* These definitions are ASCII only. But the pure-perl .pm avoids
29 * calling this .xs file for releases where they aren't defined */
32 # define isASCII(c) (((UV) (c)) < 128)
35 #ifndef ESC_NATIVE /* \e */
36 # define ESC_NATIVE 27
40 # define isPRINT(c) (((UV) (c)) >= ' ' && ((UV) (c)) < 127)
44 # define isALPHA(c) ( (((UV) (c)) >= 'a' && ((UV) (c)) <= 'z') \
45 || (((UV) (c)) <= 'Z' && ((UV) (c)) >= 'A'))
49 # define isIDFIRST(c) (isALPHA(c) || (c) == '_')
53 # define isWORDCHAR(c) (isIDFIRST(c) \
54 || (((UV) (c)) >= '0' && ((UV) (c)) <= '9'))
57 /* SvPVCLEAR only from perl 5.25.6 */
59 # define SvPVCLEAR(sv) sv_setpvs((sv), "")
63 # define memBEGINs(s1, l, s2) \
64 ( (l) >= sizeof(s2) - 1 \
65 && memEQ(s1, "" s2 "", sizeof(s2)-1))
68 /* This struct contains almost all the user's desired configuration, and it
69 * is treated as mostly constant (except for maxrecursed) by the recursive
70 * function. This arrangement has the advantage of needing less memory
71 * than passing all of them on the stack all the time (as was the case in
72 * an earlier implementation). */
83 bool maxrecursed; /* at some point we exceeded the maximum recursion level */
90 int use_sparse_seen_hash;
95 static STRLEN num_q (const char *s, STRLEN slen);
96 static STRLEN esc_q (char *dest, const char *src, STRLEN slen);
97 static STRLEN esc_q_utf8 (pTHX_ SV *sv, const char *src, STRLEN slen, I32 do_utf8, I32 useqq);
98 static bool globname_needs_quote(const char *s, STRLEN len);
100 static bool globname_supra_ascii(const char *s, STRLEN len);
102 static bool key_needs_quote(const char *s, STRLEN len);
103 static bool safe_decimal_number(const char *p, STRLEN len);
104 static SV *sv_x (pTHX_ SV *sv, const char *str, STRLEN len, I32 n);
105 static I32 DD_dump (pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval,
106 HV *seenhv, AV *postav, const I32 level, SV *apad,
110 #define HvNAME_get HvNAME
113 /* Perls 7 through portions of 15 used utf8_to_uvchr() which didn't have a
114 * length parameter. This wrongly allowed reading beyond the end of buffer
115 * given malformed input */
117 #if PERL_VERSION_LE(5,6,'*') /* Perl 5.6 and earlier */
120 Perl_utf8_to_uvchr_buf(pTHX_ U8 *s, U8 *send, STRLEN *retlen)
122 const UV uv = utf8_to_uv(s, send - s, retlen,
123 ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY);
124 return UNI_TO_NATIVE(uv);
127 # if !defined(PERL_IMPLICIT_CONTEXT)
128 # define utf8_to_uvchr_buf Perl_utf8_to_uvchr_buf
130 # define utf8_to_uvchr_buf(a,b,c) Perl_utf8_to_uvchr_buf(aTHX_ a,b,c)
133 #endif /* PERL_VERSION_LE(5,6,'*') */
135 /* Perl 5.7 through part of 5.15 */
136 #if PERL_VERSION_GE(5,7,0) && PERL_VERSION_LE(5,15,'*') && ! defined(utf8_to_uvchr_buf)
139 Perl_utf8_to_uvchr_buf(pTHX_ U8 *s, U8 *send, STRLEN *retlen)
141 /* We have to discard <send> for these versions; hence can read off the
142 * end of the buffer if there is a malformation that indicates the
143 * character is longer than the space available */
145 return utf8_to_uvchr(s, retlen);
148 # if !defined(PERL_IMPLICIT_CONTEXT)
149 # define utf8_to_uvchr_buf Perl_utf8_to_uvchr_buf
151 # define utf8_to_uvchr_buf(a,b,c) Perl_utf8_to_uvchr_buf(aTHX_ a,b,c)
154 #endif /* Perl 5.7 through part of 5.15 */
156 /* Changes in 5.7 series mean that now IOK is only set if scalar is
157 precisely integer but in 5.6 and earlier we need to do a more
159 #if PERL_VERSION_LT(5,7,0)
160 #define DD_is_integer(sv) (SvIOK(sv) && (SvIsUV(val) ? SvUV(sv) == SvNV(sv) : SvIV(sv) == SvNV(sv)))
162 #define DD_is_integer(sv) SvIOK(sv)
165 /* does a glob name need to be protected? */
167 globname_needs_quote(const char *ss, STRLEN len)
169 const U8 *s = (const U8 *) ss;
170 const U8 *send = s+len;
182 if (!isWORDCHAR(*s)) {
196 /* does a glob name contain supra-ASCII characters? */
198 globname_supra_ascii(const char *ss, STRLEN len)
200 const U8 *s = (const U8 *) ss;
201 const U8 *send = s+len;
211 /* does a hash key need to be quoted (to the left of => ).
212 Previously this used (globname_)needs_quote() which accepted strings
213 like '::foo', but these aren't safe as unquoted keys under strict.
216 key_needs_quote(const char *s, STRLEN len) {
217 const char *send = s+len;
219 if (safe_decimal_number(s, len)) {
222 else if (isIDFIRST(*s)) {
233 /* Check that the SV can be represented as a simple decimal integer.
235 * The perl code does this by matching against /^(?:0|-?[1-9]\d{0,8})\z/
238 safe_decimal_number(const char *p, STRLEN len) {
239 if (len == 1 && *p == '0')
242 if (len && *p == '-') {
247 if (len == 0 || *p < '1' || *p > '9')
257 /* the perl code checks /\d/ but we don't want unicode digits here */
258 if (*p < '0' || *p > '9')
266 /* count the number of "'"s and "\"s in string */
268 num_q(const char *s, STRLEN slen)
273 if (*s == '\'' || *s == '\\')
282 /* returns number of chars added to escape "'"s and "\"s in s */
283 /* slen number of characters in s will be escaped */
284 /* destination must be long enough for additional chars */
286 esc_q(char *d, const char *s, STRLEN slen)
306 /* this function is also misused for implementing $Useqq */
308 esc_q_utf8(pTHX_ SV* sv, const char *src, STRLEN slen, I32 do_utf8, I32 useqq)
312 const char * const send = src + slen;
313 STRLEN j, cur = SvCUR(sv);
314 /* Could count 128-255 and 256+ in two variables, if we want to
315 be like &qquote and make a distinction. */
316 STRLEN grow = 0; /* bytes needed to represent chars 128+ */
317 /* STRLEN topbit_grow = 0; bytes needed to represent chars 128-255 */
318 STRLEN backslashes = 0;
319 STRLEN single_quotes = 0;
320 STRLEN qq_escapables = 0; /* " $ @ will need a \ in "" strings. */
324 for (s = src; s < send; s += increment) { /* Sizing pass */
327 increment = 1; /* Will override if necessary for utf-8 */
332 } else if (k == '\'') {
334 } else if (k == '"' || k == '$' || k == '@') {
340 else if (! isASCII(k) && k > ' ') {
341 /* High ordinal non-printable code point. (The test that k is
342 * above SPACE should be optimized out by the compiler on
343 * non-EBCDIC platforms; otherwise we could put an #ifdef around
344 * it, but it's better to have just a single code path when
345 * possible. All but one of the non-ASCII EBCDIC controls are low
346 * ordinal; that one is the only one above SPACE.)
348 * If UTF-8, output as hex, regardless of useqq. This means there
349 * is an overhead of 4 chars '\x{}'. Then count the number of hex
352 k = utf8_to_uvchr_buf((U8*)s, (U8*) send, NULL);
354 /* treat invalid utf8 byte by byte. This loop iteration gets the
356 increment = (k == 0 && *s != '\0') ? 1 : UTF8SKIP(s);
358 grow += 4 + (k <= 0xFF ? 2 : k <= 0xFFF ? 3 : k <= 0xFFFF ? 4 :
360 8 /* We may allocate a bit more than the minimum here. */
362 k <= 0xFFFFFFFF ? 8 : UVSIZE * 4
366 else if (useqq) { /* Not utf8, must be <= 0xFF, hence 2 hex
370 else { /* Non-qq generates 3 octal digits plus backslash */
373 } /* End of high-ordinal non-printable */
374 else if (! useqq) { /* Low ordinal, non-printable, non-qq just
375 * outputs the raw char */
378 else { /* Is qq, low ordinal, non-printable. Output escape
380 if ( k == '\a' || k == '\b' || k == '\t' || k == '\n' || k == '\r'
381 || k == '\f' || k == ESC_NATIVE)
383 grow += 2; /* 1 char plus backslash */
385 else /* The other low ordinals are output as an octal escape
387 if (s + 1 >= send || ( *(U8*)(s+1) >= '0'
388 && *(U8*)(s+1) <= '9'))
390 /* When the following character is a digit, use 3 octal digits
391 * plus backslash, as using fewer digits would concatenate the
392 * following char into this one */
396 grow += 2; /* 1 octal digit, plus backslash */
399 grow += 3; /* 2 octal digits plus backslash */
402 grow += 4; /* 3 octal digits plus backslash */
405 } /* End of size-calculating loop */
408 /* We have something needing hex. 3 is ""\0 */
409 sv_grow(sv, cur + 3 + grow + 2*backslashes + single_quotes
410 + 2*qq_escapables + normal);
411 rstart = r = SvPVX(sv) + cur;
415 for (s = src; s < send; s += increment) {
421 /* Exclude non-ASCII low ordinal controls. This should be
422 * optimized out by the compiler on ASCII platforms; if not
423 * could wrap it in a #ifdef EBCDIC, but better to avoid
424 * #if's if possible */
428 /* When in UTF-8, we output all non-ascii chars as \x{}
429 * reqardless of useqq, except for the low ordinal controls on
430 * EBCDIC platforms */
431 k = utf8_to_uvchr_buf((U8*)s, (U8*) send, NULL);
433 /* treat invalid utf8 byte by byte. This loop iteration gets the
435 increment = (k == 0 && *s != '\0') ? 1 : UTF8SKIP(s);
437 #if PERL_VERSION_LT(5,10,0)
438 sprintf(r, "\\x{%" UVxf "}", k);
440 /* my_sprintf is not supported by ppport.h */
442 r = r + my_sprintf(r, "\\x{%" UVxf "}", k);
447 /* Here 1) isn't UTF-8; or
448 * 2) the current character is ASCII; or
449 * 3) it is an EBCDIC platform and is a low ordinal
451 * In each case the character occupies just one byte */
456 /* These need a backslash escape */
457 if (k == '"' || k == '\\' || k == '$' || k == '@') {
463 else if (! useqq) { /* non-qq, non-printable, low-ordinal is
467 else { /* Is qq means use escape sequences */
472 case '\a': *r++ = 'a'; break;
473 case '\b': *r++ = 'b'; break;
474 case '\t': *r++ = 't'; break;
475 case '\n': *r++ = 'n'; break;
476 case '\f': *r++ = 'f'; break;
477 case '\r': *r++ = 'r'; break;
478 case ESC_NATIVE: *r++ = 'e'; break;
481 /* only ASCII digits matter here, which are invariant,
482 * since we only encode characters \377 and under, or
483 * \x177 and under for a unicode string
485 next_is_digit = (s + 1 >= send )
487 : (*(U8*)(s+1) >= '0' && *(U8*)(s+1) <= '9');
490 * r = r + my_sprintf(r, "%o", k);
492 if (k <= 7 && !next_is_digit) {
493 *r++ = (char)k + '0';
494 } else if (k <= 63 && !next_is_digit) {
495 *r++ = (char)(k>>3) + '0';
496 *r++ = (char)(k&7) + '0';
498 *r++ = (char)(k>>6) + '0';
499 *r++ = (char)((k&63)>>3) + '0';
500 *r++ = (char)(k&7) + '0';
508 sv_grow(sv, cur + 3 + 2*backslashes + 2*single_quotes
509 + qq_escapables + normal);
510 rstart = r = SvPVX(sv) + cur;
512 for (s = src; s < send; s ++) {
514 if (k == '\'' || k == '\\')
522 SvCUR_set(sv, cur + j);
527 /* append a repeated string to an SV */
529 sv_x(pTHX_ SV *sv, const char *str, STRLEN len, I32 n)
535 assert(SvTYPE(sv) >= SVt_PV);
539 SvGROW(sv, len*n + SvCUR(sv) + 1);
541 char * const start = SvPVX(sv) + SvCUR(sv);
542 SvCUR_set(sv, SvCUR(sv) + n);
549 sv_catpvn(sv, str, len);
557 deparsed_output(pTHX_ SV *val)
563 /* This is passed to load_module(), which decrements its ref count and
564 * modifies it (so we also can't reuse it below) */
565 SV *pkg = newSVpvs("B::Deparse");
567 /* Commit ebdc88085efa6fca8a1b0afaa388f0491bdccd5a (first released as part
568 * of 5.19.7) changed core S_process_special_blocks() to use a new stack
569 * for anything using a BEGIN block, on the grounds that doing so "avoids
570 * the stack moving underneath anything that directly or indirectly calls
571 * Perl_load_module()". If we're in an older Perl, we can't rely on that
572 * stack, and must create a fresh sacrificial stack of our own. */
573 #if PERL_VERSION_LT(5,20,0)
574 PUSHSTACKi(PERLSI_REQUIRE);
577 load_module(PERL_LOADMOD_NOIMPORT, pkg, 0);
579 #if PERL_VERSION_LT(5,20,0)
587 mXPUSHs(newSVpvs("B::Deparse"));
590 n = call_method("new", G_SCALAR);
594 croak("B::Deparse->new returned %d items, but expected exactly 1", n);
601 n = call_method("coderef2text", G_SCALAR);
605 croak("$b_deparse->coderef2text returned %d items, but expected exactly 1", n);
609 SvREFCNT_inc(text); /* the caller will mortalise this */
619 dump_regexp(pTHX_ SV *retval, SV *val)
622 SV *sv_pattern = NULL;
627 CV *re_pattern_cv = get_cv("re::regexp_pattern", 0);
629 if (!re_pattern_cv) {
640 count = call_sv((SV*)re_pattern_cv, G_ARRAY);
645 SvREFCNT_inc(sv_flags);
646 SvREFCNT_inc(sv_pattern);
652 sv_2mortal(sv_pattern);
653 sv_2mortal(sv_flags);
659 /* The strategy here is from commit 7894fbab1e479c2c (in June 1999) with a
660 * bug fix in Feb 2012 (commit de5ef703c7d8db65).
661 * We need to ensure that / is escaped as \/
662 * To be efficient, we want to avoid copying byte-for-byte, so we scan the
663 * string looking for "things we need to escape", and each time we find
664 * something, we copy over the verbatim section, before writing out the
665 * escaped part. At the end, if there's some verbatim section left, we copy
666 * that over to finish.
667 * The complication (perl #58608) is that we must not convert \/ to \\/
668 * (as that would be a syntax error), so we need to walk the string looking
670 * \ and the character immediately after (together)
672 * and only for the latter, do we need to escape /
675 rval = SvPV(sv_pattern, rlen);
678 sv_catpvs(retval, "qr/");
680 for ( ; slash < rend; slash++) {
681 if (*slash == '\\') {
686 sv_catpvn(retval, rval, slash-rval);
687 sv_catpvs(retval, "\\/");
688 rlen -= slash-rval+1;
693 sv_catpvn(retval, rval, rlen);
694 sv_catpvs(retval, "/");
697 sv_catsv(retval, sv_flags);
701 * This ought to be split into smaller functions. (it is one long function since
702 * it exactly parallels the perl version, which was one long thing for
703 * efficiency raisins.) Ugggh!
706 DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
707 AV *postav, const I32 level, SV *apad, Style *style)
711 char *c, *r, *realpack;
712 #ifdef DD_USE_OLD_ID_FORMAT
716 char *const id = (char *)&id_buffer;
719 SV *sv, *ipad, *ival;
720 SV *blesspad = Nullsv;
721 AV *seenentry = NULL;
723 STRLEN inamelen, idlen = 0;
725 bool no_bless = 0; /* when a qr// is blessed into Regexp we dont want to bless it.
726 in later perls we should actually check the classname of the
727 engine. this gets tricky as it involves lexical issues that arent so
729 bool is_regex = 0; /* we are dumping a regex, we need to know this before we bless */
734 if (style->maxrecursed)
737 /* If the output buffer has less than some arbitrary amount of space
738 remaining, then enlarge it. For the test case (25M of output),
739 *1.1 was slower, *2.0 was the same, so the first guess of 1.5 is
740 deemed to be good enough. */
741 if (SvTYPE(retval) >= SVt_PV && (SvLEN(retval) - SvCUR(retval)) < 42) {
742 sv_grow(retval, SvCUR(retval) * 3 / 2);
745 realtype = SvTYPE(val);
751 /* If a freeze method is provided and the object has it, call
752 it. Warn on errors. */
753 if (SvOBJECT(SvRV(val)) && style->freezer &&
754 SvPOK(style->freezer) && SvCUR(style->freezer) &&
755 gv_fetchmeth(SvSTASH(SvRV(val)), SvPVX_const(style->freezer),
756 SvCUR(style->freezer), -1) != NULL)
758 dSP; ENTER; SAVETMPS; PUSHMARK(sp);
759 XPUSHs(val); PUTBACK;
760 i = perl_call_method(SvPVX_const(style->freezer), G_EVAL|G_VOID|G_DISCARD);
763 warn("WARNING(Freezer method call failed): %" SVf, ERRSV);
764 PUTBACK; FREETMPS; LEAVE;
768 realtype = SvTYPE(ival);
769 #ifdef DD_USE_OLD_ID_FORMAT
770 idlen = my_snprintf(id, sizeof(id), "0x%" UVxf, PTR2UV(ival));
772 id_buffer = PTR2UV(ival);
773 idlen = sizeof(id_buffer);
776 realpack = HvNAME_get(SvSTASH(ival));
780 /* if it has a name, we need to either look it up, or keep a tab
781 * on it so we know when we hit it later
784 if ((svp = hv_fetch(seenhv, id, idlen, FALSE))
785 && (sv = *svp) && SvROK(sv) && (seenentry = (AV*)SvRV(sv)))
788 if ((svp = av_fetch(seenentry, 0, FALSE))
789 && (othername = *svp))
791 if (style->purity && level > 0) {
794 if (realtype == SVt_PVHV)
795 sv_catpvs(retval, "{}");
796 else if (realtype == SVt_PVAV)
797 sv_catpvs(retval, "[]");
799 sv_catpvs(retval, "do{my $o}");
800 postentry = newSVpvn(name, namelen);
801 sv_catpvs(postentry, " = ");
802 sv_catsv(postentry, othername);
803 av_push(postav, postentry);
806 if (name[0] == '@' || name[0] == '%') {
807 if ((SvPVX_const(othername))[0] == '\\' &&
808 (SvPVX_const(othername))[1] == name[0]) {
809 sv_catpvn(retval, SvPVX_const(othername)+1,
813 sv_catpvn(retval, name, 1);
814 sv_catpvs(retval, "{");
815 sv_catsv(retval, othername);
816 sv_catpvs(retval, "}");
820 sv_catsv(retval, othername);
825 #ifdef DD_USE_OLD_ID_FORMAT
826 warn("ref name not found for %s", id);
828 warn("ref name not found for 0x%" UVxf, PTR2UV(ival));
833 else { /* store our name and continue */
835 if (name[0] == '@' || name[0] == '%') {
836 namesv = newSVpvs("\\");
837 sv_catpvn(namesv, name, namelen);
839 else if (realtype == SVt_PVCV && name[0] == '*') {
840 namesv = newSVpvs("\\");
841 sv_catpvn(namesv, name, namelen);
842 (SvPVX(namesv))[1] = '&';
845 namesv = newSVpvn(name, namelen);
847 av_push(seenentry, namesv);
848 (void)SvREFCNT_inc(val);
849 av_push(seenentry, val);
850 (void)hv_store(seenhv, id, idlen,
851 newRV_inc((SV*)seenentry), 0);
852 SvREFCNT_dec(seenentry);
855 /* regexps dont have to be blessed into package "Regexp"
856 * they can be blessed into any package.
858 #if PERL_VERSION_LT(5,8,0)
859 if (realpack && *realpack == 'R' && strEQ(realpack, "Regexp"))
860 #elif PERL_VERSION_LT(5,11,0)
861 if (realpack && realtype == SVt_PVMG && mg_find(ival, PERL_MAGIC_qr))
863 if (realpack && realtype == SVt_REGEXP)
867 if (strEQ(realpack, "Regexp"))
873 /* If purity is not set and maxdepth is set, then check depth:
874 * if we have reached maximum depth, return the string
875 * representation of the thing we are currently examining
876 * at this depth (i.e., 'Foo=ARRAY(0xdeadbeef)').
878 if (!style->purity && style->maxdepth > 0 && level >= style->maxdepth) {
880 const char * const valstr = SvPV(val,vallen);
881 sv_catpvs(retval, "'");
882 sv_catpvn(retval, valstr, vallen);
883 sv_catpvs(retval, "'");
887 if (style->maxrecurse > 0 && level >= style->maxrecurse) {
888 style->maxrecursed = TRUE;
891 if (realpack && !no_bless) { /* we have a blessed ref */
893 const char * const blessstr = SvPV(style->bless, blesslen);
894 sv_catpvn(retval, blessstr, blesslen);
895 sv_catpvs(retval, "( ");
896 if (style->indent >= 2) {
898 apad = sv_2mortal(newSVsv(apad));
899 sv_x(aTHX_ apad, " ", 1, blesslen+2);
903 ipad = sv_x(aTHX_ Nullsv, SvPVX_const(style->xpad), SvCUR(style->xpad), level+1);
907 dump_regexp(aTHX_ retval, val);
910 #if PERL_VERSION_LT(5,9,0)
916 SV * const namesv = sv_2mortal(newSVpvs("${"));
917 sv_catpvn(namesv, name, namelen);
918 sv_catpvs(namesv, "}");
919 if (realpack) { /* blessed */
920 sv_catpvs(retval, "do{\\(my $o = ");
921 DD_dump(aTHX_ ival, SvPVX_const(namesv), SvCUR(namesv), retval, seenhv,
922 postav, level+1, apad, style);
923 sv_catpvs(retval, ")}");
926 sv_catpvs(retval, "\\");
927 DD_dump(aTHX_ ival, SvPVX_const(namesv), SvCUR(namesv), retval, seenhv,
928 postav, level+1, apad, style);
931 else if (realtype == SVt_PVGV) { /* glob ref */
932 SV * const namesv = newSVpvs("*{");
933 sv_catpvn(namesv, name, namelen);
934 sv_catpvs(namesv, "}");
935 sv_catpvs(retval, "\\");
936 DD_dump(aTHX_ ival, SvPVX_const(namesv), SvCUR(namesv), retval, seenhv,
937 postav, level+1, apad, style);
938 SvREFCNT_dec(namesv);
940 else if (realtype == SVt_PVAV) {
943 const SSize_t ixmax = av_len((AV *)ival);
945 SV * const ixsv = sv_2mortal(newSViv(0));
946 /* allowing for a 24 char wide array index */
947 New(0, iname, namelen+28, char);
949 (void) strlcpy(iname, name, namelen+28);
951 if (name[0] == '@') {
952 sv_catpvs(retval, "(");
956 sv_catpvs(retval, "[");
957 /* omit "->" in $foo{bar}->[0], but not in ${$foo}->[0] */
959 && name[namelen-1] != ']' && name[namelen-1] != '}'
960 && (namelen < 4 || (name[1] != '{' && name[2] != '{')))*/
962 && name[namelen-1] != ']' && name[namelen-1] != '}')
965 || (name[0] == '\\' && name[2] == '{'))))
967 iname[inamelen++] = '-'; iname[inamelen++] = '>';
968 iname[inamelen] = '\0';
971 if (iname[0] == '*' && iname[inamelen-1] == '}' && inamelen >= 8 &&
972 (instr(iname+inamelen-8, "{SCALAR}") ||
973 instr(iname+inamelen-7, "{ARRAY}") ||
974 instr(iname+inamelen-6, "{HASH}"))) {
975 iname[inamelen++] = '-'; iname[inamelen++] = '>';
977 iname[inamelen++] = '['; iname[inamelen] = '\0';
978 totpad = sv_2mortal(newSVsv(style->sep));
979 sv_catsv(totpad, style->pad);
980 sv_catsv(totpad, apad);
982 for (ix = 0; ix <= ixmax; ++ix) {
985 svp = av_fetch((AV*)ival, ix, FALSE);
993 #if PERL_VERSION_LT(5,10,0)
994 (void) sprintf(iname+ilen, "%" IVdf, (IV)ix);
995 ilen = strlen(iname);
997 ilen = ilen + my_sprintf(iname+ilen, "%" IVdf, (IV)ix);
999 iname[ilen++] = ']'; iname[ilen] = '\0';
1000 if (style->indent >= 3) {
1001 sv_catsv(retval, totpad);
1002 sv_catsv(retval, ipad);
1003 sv_catpvs(retval, "#");
1004 sv_catsv(retval, ixsv);
1006 sv_catsv(retval, totpad);
1007 sv_catsv(retval, ipad);
1010 DD_dump(aTHX_ elem, iname, ilen, retval, seenhv, postav,
1011 level+1, apad, style);
1014 if (ix < ixmax || (style->trailingcomma && style->indent >= 1))
1015 sv_catpvs(retval, ",");
1018 SV * const opad = sv_x(aTHX_ Nullsv, SvPVX_const(style->xpad), SvCUR(style->xpad), level);
1019 sv_catsv(retval, totpad);
1020 sv_catsv(retval, opad);
1024 sv_catpvs(retval, ")");
1026 sv_catpvs(retval, "]");
1028 else if (realtype == SVt_PVHV) {
1029 SV *totpad, *newapad;
1036 SV * const iname = newSVpvn_flags(name, namelen, SVs_TEMP);
1037 if (name[0] == '%') {
1038 sv_catpvs(retval, "(");
1039 (SvPVX(iname))[0] = '$';
1042 sv_catpvs(retval, "{");
1043 /* omit "->" in $foo[0]->{bar}, but not in ${$foo}->{bar} */
1045 && name[namelen-1] != ']' && name[namelen-1] != '}')
1048 || (name[0] == '\\' && name[2] == '{'))))
1050 sv_catpvs(iname, "->");
1053 if (name[0] == '*' && name[namelen-1] == '}' && namelen >= 8 &&
1054 (instr(name+namelen-8, "{SCALAR}") ||
1055 instr(name+namelen-7, "{ARRAY}") ||
1056 instr(name+namelen-6, "{HASH}"))) {
1057 sv_catpvs(iname, "->");
1059 sv_catpvs(iname, "{");
1060 totpad = sv_2mortal(newSVsv(style->sep));
1061 sv_catsv(totpad, style->pad);
1062 sv_catsv(totpad, apad);
1064 /* If requested, get a sorted/filtered array of hash keys */
1065 if (style->sortkeys) {
1066 #if PERL_VERSION_GE(5,8,0)
1067 if (style->sortkeys == &PL_sv_yes) {
1069 (void)hv_iterinit((HV*)ival);
1070 while ((entry = hv_iternext((HV*)ival))) {
1071 sv = hv_iterkeysv(entry);
1072 (void)SvREFCNT_inc(sv);
1075 # ifdef USE_LOCALE_COLLATE
1076 # ifdef IN_LC /* Use this if available */
1077 if (IN_LC(LC_COLLATE))
1082 sortsv(AvARRAY(keys),
1084 Perl_sv_cmp_locale);
1089 sortsv(AvARRAY(keys),
1097 dSP; ENTER; SAVETMPS; PUSHMARK(sp);
1098 XPUSHs(sv_2mortal(newRV_inc(ival))); PUTBACK;
1099 i = perl_call_sv(style->sortkeys, G_SCALAR | G_EVAL);
1103 if (SvROK(sv) && (SvTYPE(SvRV(sv)) == SVt_PVAV))
1104 keys = (AV*)SvREFCNT_inc(SvRV(sv));
1107 warn("Sortkeys subroutine did not return ARRAYREF\n");
1108 PUTBACK; FREETMPS; LEAVE;
1111 sv_2mortal((SV*)keys);
1114 (void)hv_iterinit((HV*)ival);
1116 /* foreach (keys %hash) */
1117 for (i = 0; 1; i++) {
1119 char *nkey_buffer = NULL;
1125 bool do_utf8 = FALSE;
1127 if (style->sortkeys) {
1128 if (!(keys && (SSize_t)i <= av_len(keys))) break;
1130 if (!(entry = hv_iternext((HV *)ival))) break;
1134 sv_catpvs(retval, ",");
1136 if (style->sortkeys) {
1138 svp = av_fetch(keys, i, FALSE);
1139 keysv = svp ? *svp : sv_newmortal();
1140 key = SvPV(keysv, keylen);
1141 svp = hv_fetch((HV*)ival, key,
1142 SvUTF8(keysv) ? -(I32)keylen : (I32)keylen, 0);
1143 hval = svp ? *svp : sv_newmortal();
1146 keysv = hv_iterkeysv(entry);
1147 hval = hv_iterval((HV*)ival, entry);
1150 key = SvPV(keysv, keylen);
1151 do_utf8 = DO_UTF8(keysv);
1154 sv_catsv(retval, totpad);
1155 sv_catsv(retval, ipad);
1161 old logic was first to check utf8 flag, and if utf8 always
1162 call esc_q_utf8. This caused test to break under -Mutf8,
1163 because there even strings like 'c' have utf8 flag on.
1164 Hence with quotekeys == 0 the XS code would still '' quote
1165 them based on flags, whereas the perl code would not,
1168 The old logic checked that the string was a valid
1169 perl glob name (foo::bar), which isn't safe under
1170 strict, and differs from the perl code which only
1171 accepts simple identifiers.
1173 With the fix for [perl #120384] I chose to make
1174 their handling of key quoting compatible between XS
1177 if (style->quotekeys || key_needs_quote(key,keylen)) {
1178 if (do_utf8 || style->useqq) {
1179 STRLEN ocur = SvCUR(retval);
1180 klen = nlen = esc_q_utf8(aTHX_ retval, key, klen, do_utf8, style->useqq);
1181 nkey = SvPVX(retval) + ocur;
1184 nticks = num_q(key, klen);
1185 New(0, nkey_buffer, klen+nticks+3, char);
1186 SAVEFREEPV(nkey_buffer);
1190 klen += esc_q(nkey+1, key, klen);
1192 (void)Copy(key, nkey+1, klen, char);
1193 nkey[++klen] = '\'';
1194 nkey[++klen] = '\0';
1196 sv_catpvn(retval, nkey, klen);
1202 sv_catpvn(retval, nkey, klen);
1205 sname = sv_2mortal(newSVsv(iname));
1206 sv_catpvn(sname, nkey, nlen);
1207 sv_catpvs(sname, "}");
1209 sv_catsv(retval, style->pair);
1210 if (style->indent >= 2) {
1213 newapad = sv_2mortal(newSVsv(apad));
1214 New(0, extra, klen+4+1, char);
1215 while (elen < (klen+4))
1216 extra[elen++] = ' ';
1218 sv_catpvn(newapad, extra, elen);
1224 DD_dump(aTHX_ hval, SvPVX_const(sname), SvCUR(sname), retval, seenhv,
1225 postav, level+1, newapad, style);
1231 SV *opad = sv_x(aTHX_ Nullsv, SvPVX_const(style->xpad),
1232 SvCUR(style->xpad), level);
1233 if (style->trailingcomma && style->indent >= 1)
1234 sv_catpvs(retval, ",");
1235 sv_catsv(retval, totpad);
1236 sv_catsv(retval, opad);
1240 sv_catpvs(retval, ")");
1242 sv_catpvs(retval, "}");
1244 else if (realtype == SVt_PVCV) {
1245 if (style->deparse) {
1246 SV *deparsed = sv_2mortal(deparsed_output(aTHX_ val));
1247 SV *fullpad = sv_2mortal(newSVsv(style->sep));
1252 sv_catsv(fullpad, style->pad);
1253 sv_catsv(fullpad, apad);
1254 for (i = 0; i < level; i++) {
1255 sv_catsv(fullpad, style->xpad);
1258 sv_catpvs(retval, "sub ");
1259 p = SvPV(deparsed, plen);
1261 const char *nl = (const char *) memchr(p, '\n', plen);
1263 sv_catpvn(retval, p, plen);
1268 sv_catpvn(retval, p, n);
1269 sv_catsv(retval, fullpad);
1276 sv_catpvs(retval, "sub { \"DUMMY\" }");
1278 warn("Encountered CODE ref, using dummy placeholder");
1282 warn("cannot handle ref type %d", (int)realtype);
1285 if (realpack && !no_bless) { /* free blessed allocs */
1286 STRLEN plen, pticks;
1288 if (style->indent >= 2) {
1291 sv_catpvs(retval, ", '");
1293 plen = strlen(realpack);
1294 pticks = num_q(realpack, plen);
1295 if (pticks) { /* needs escaping */
1297 char *npack_buffer = NULL;
1299 New(0, npack_buffer, plen+pticks+1, char);
1300 npack = npack_buffer;
1301 plen += esc_q(npack, realpack, plen);
1304 sv_catpvn(retval, npack, plen);
1305 Safefree(npack_buffer);
1308 sv_catpvn(retval, realpack, strlen(realpack));
1310 sv_catpvs(retval, "' )");
1311 if (style->toaster && SvPOK(style->toaster) && SvCUR(style->toaster)) {
1312 sv_catpvs(retval, "->");
1313 sv_catsv(retval, style->toaster);
1314 sv_catpvs(retval, "()");
1323 #ifdef DD_USE_OLD_ID_FORMAT
1324 idlen = my_snprintf(id, sizeof(id), "0x%" UVxf, PTR2UV(val));
1326 id_buffer = PTR2UV(val);
1327 idlen = sizeof(id_buffer);
1329 if ((svp = hv_fetch(seenhv, id, idlen, FALSE)) &&
1330 (sv = *svp) && SvROK(sv) &&
1331 (seenentry = (AV*)SvRV(sv)))
1334 if ((svp = av_fetch(seenentry, 0, FALSE)) && (othername = *svp)
1335 && (svp = av_fetch(seenentry, 2, FALSE)) && *svp && SvIV(*svp) > 0)
1337 sv_catpvs(retval, "${");
1338 sv_catsv(retval, othername);
1339 sv_catpvs(retval, "}");
1343 /* If we're allowed to keep only a sparse "seen" hash
1344 * (IOW, the user does not expect it to contain everything
1345 * after the dump, then only store in seen hash if the SV
1346 * ref count is larger than 1. If it's 1, then we know that
1347 * there is no other reference, duh. This is an optimization.
1348 * Note that we'd have to check for weak-refs, too, but this is
1349 * already the branch for non-refs only. */
1350 else if (val != &PL_sv_undef && (!style->use_sparse_seen_hash || SvREFCNT(val) > 1)) {
1351 SV * const namesv = newSVpvs("\\");
1352 sv_catpvn(namesv, name, namelen);
1353 seenentry = newAV();
1354 av_push(seenentry, namesv);
1355 av_push(seenentry, newRV_inc(val));
1356 (void)hv_store(seenhv, id, idlen, newRV_inc((SV*)seenentry), 0);
1357 SvREFCNT_dec(seenentry);
1361 if (DD_is_integer(val)) {
1364 len = my_snprintf(tmpbuf, sizeof(tmpbuf), "%" UVuf, SvUV(val));
1366 len = my_snprintf(tmpbuf, sizeof(tmpbuf), "%" IVdf, SvIV(val));
1368 /* Need to check to see if this is a string such as " 0".
1369 I'm assuming from sprintf isn't going to clash with utf8. */
1371 const char * const pv = SvPV(val, pvlen);
1372 if (pvlen != len || memNE(pv, tmpbuf, len))
1373 goto integer_came_from_string;
1376 /* Looks like we're on a 64 bit system. Make it a string so that
1377 if a 32 bit system reads the number it will cope better. */
1378 sv_catpvf(retval, "'%s'", tmpbuf);
1380 sv_catpvn(retval, tmpbuf, len);
1382 else if (realtype == SVt_PVGV) {/* GLOBs can end up with scribbly names */
1384 if(i) ++c, --i; /* just get the name */
1385 if (memBEGINs(c, i, "main::")) {
1387 #if PERL_VERSION_LT(5,7,0)
1388 if (i == 6 || (i == 7 && c[6] == '\0'))
1394 if (globname_needs_quote(c,i)) {
1395 sv_grow(retval, SvCUR(retval)+3);
1396 r = SvPVX(retval)+SvCUR(retval);
1397 r[0] = '*'; r[1] = '{'; r[2] = 0;
1398 SvCUR_set(retval, SvCUR(retval)+2);
1399 i = 3 + esc_q_utf8(aTHX_ retval, c, i,
1401 !!GvNAMEUTF8(val), style->useqq
1403 0, style->useqq || globname_supra_ascii(c, i)
1406 sv_grow(retval, SvCUR(retval)+2);
1407 r = SvPVX(retval)+SvCUR(retval);
1408 r[0] = '}'; r[1] = '\0';
1409 SvCUR_set(retval, SvCUR(retval)+1);
1413 sv_grow(retval, SvCUR(retval)+i+2);
1414 r = SvPVX(retval)+SvCUR(retval);
1415 r[0] = '*'; strlcpy(r+1, c, SvLEN(retval));
1417 SvCUR_set(retval, SvCUR(retval)+i);
1420 if (style->purity) {
1421 static const char* const entries[] = { "{SCALAR}", "{ARRAY}", "{HASH}" };
1422 static const STRLEN sizes[] = { 8, 7, 6 };
1424 SV * const nname = newSVpvs("");
1425 SV * const newapad = newSVpvs("");
1426 GV * const gv = (GV*)val;
1429 for (j=0; j<3; j++) {
1430 e = ((j == 0) ? GvSV(gv) : (j == 1) ? (SV*)GvAV(gv) : (SV*)GvHV(gv));
1433 if (j == 0 && !SvOK(e))
1437 SV *postentry = newSVpvn(r,i);
1439 sv_setsv(nname, postentry);
1440 sv_catpvn(nname, entries[j], sizes[j]);
1441 sv_catpvs(postentry, " = ");
1442 av_push(postav, postentry);
1445 SvCUR_set(newapad, 0);
1446 if (style->indent >= 2)
1447 (void)sv_x(aTHX_ newapad, " ", 1, SvCUR(postentry));
1449 DD_dump(aTHX_ e, SvPVX_const(nname), SvCUR(nname), postentry,
1450 seenhv, postav, 0, newapad, style);
1455 SvREFCNT_dec(newapad);
1456 SvREFCNT_dec(nname);
1459 else if (val == &PL_sv_undef || !SvOK(val)) {
1460 sv_catpvs(retval, "undef");
1463 else if (SvMAGICAL(val) && (mg = mg_find(val, 'V'))) {
1464 # if !defined(PL_vtbl_vstring) && PERL_VERSION_LT(5,17,0)
1465 SV * const vecsv = sv_newmortal();
1466 # if PERL_VERSION_LT(5,10,0)
1467 scan_vstring(mg->mg_ptr, vecsv);
1469 scan_vstring(mg->mg_ptr, mg->mg_ptr + mg->mg_len, vecsv);
1471 if (!sv_eq(vecsv, val)) goto integer_came_from_string;
1473 sv_catpvn(retval, (const char *)mg->mg_ptr, mg->mg_len);
1478 integer_came_from_string:
1480 /* the pure perl and XS non-qq outputs have historically been
1481 * different in this case, but for useqq, let's try to match
1482 * the pure perl code.
1485 if (style->useqq && safe_decimal_number(c, i)) {
1486 sv_catsv(retval, val);
1488 else if (DO_UTF8(val) || style->useqq)
1489 i += esc_q_utf8(aTHX_ retval, c, i, DO_UTF8(val), style->useqq);
1491 sv_grow(retval, SvCUR(retval)+3+2*i); /* 3: ""\0 */
1492 r = SvPVX(retval) + SvCUR(retval);
1494 i += esc_q(r+1, c, i);
1498 SvCUR_set(retval, SvCUR(retval)+i);
1504 if (style->deepcopy)
1505 (void)hv_delete(seenhv, id, idlen, G_DISCARD);
1506 else if (namelen && seenentry) {
1507 SV *mark = *av_fetch(seenentry, 2, TRUE);
1515 MODULE = Data::Dumper PACKAGE = Data::Dumper PREFIX = Data_Dumper_
1518 # This is the exact equivalent of Dump. Well, almost. The things that are
1519 # different as of now (due to Laziness):
1520 # * doesn't do deparse yet.'
1524 Data_Dumper_Dumpxs(href, ...)
1530 SV *retval, *valstr;
1532 AV *postav, *todumpav, *namesav;
1534 SSize_t i, imax, postlen;
1536 SV *apad = &PL_sv_undef;
1539 SV *name, *val = &PL_sv_undef, *varname = &PL_sv_undef;
1541 I32 gimme = GIMME_V;
1543 if (!SvROK(href)) { /* call new to get an object first */
1545 croak("Usage: Data::Dumper::Dumpxs(PACKAGE, VAL_ARY_REF, [NAME_ARY_REF])");
1551 EXTEND(SP, 3); /* 3 == max of all branches below */
1553 PUSHs(sv_2mortal(newSVsv(ST(1))));
1555 PUSHs(sv_2mortal(newSVsv(ST(2))));
1557 i = perl_call_method("new", G_SCALAR);
1560 href = newSVsv(POPs);
1566 (void)sv_2mortal(href);
1569 todumpav = namesav = NULL;
1571 style.quotekeys = 1;
1572 style.maxrecurse = 1000;
1573 style.maxrecursed = FALSE;
1574 style.purity = style.deepcopy = style.useqq = style.maxdepth
1575 = style.use_sparse_seen_hash = style.trailingcomma = 0;
1576 style.pad = style.xpad = style.sep = style.pair = style.sortkeys
1577 = style.freezer = style.toaster = style.bless = &PL_sv_undef;
1579 name = sv_newmortal();
1581 retval = newSVpvs_flags("", SVs_TEMP);
1583 && (hv = (HV*)SvRV((SV*)href))
1584 && SvTYPE(hv) == SVt_PVHV) {
1586 if ((svp = hv_fetchs(hv, "seen", FALSE)) && SvROK(*svp))
1587 seenhv = (HV*)SvRV(*svp);
1589 style.use_sparse_seen_hash = 1;
1590 if ((svp = hv_fetchs(hv, "noseen", FALSE)))
1591 style.use_sparse_seen_hash = (SvOK(*svp) && SvIV(*svp) != 0);
1592 if ((svp = hv_fetchs(hv, "todump", FALSE)) && SvROK(*svp))
1593 todumpav = (AV*)SvRV(*svp);
1594 if ((svp = hv_fetchs(hv, "names", FALSE)) && SvROK(*svp))
1595 namesav = (AV*)SvRV(*svp);
1596 if ((svp = hv_fetchs(hv, "indent", FALSE)))
1597 style.indent = SvIV(*svp);
1598 if ((svp = hv_fetchs(hv, "purity", FALSE)))
1599 style.purity = SvIV(*svp);
1600 if ((svp = hv_fetchs(hv, "terse", FALSE)))
1601 terse = SvTRUE(*svp);
1602 if ((svp = hv_fetchs(hv, "useqq", FALSE)))
1603 style.useqq = SvTRUE(*svp);
1604 if ((svp = hv_fetchs(hv, "pad", FALSE)))
1606 if ((svp = hv_fetchs(hv, "xpad", FALSE)))
1608 if ((svp = hv_fetchs(hv, "apad", FALSE)))
1610 if ((svp = hv_fetchs(hv, "sep", FALSE)))
1612 if ((svp = hv_fetchs(hv, "pair", FALSE)))
1614 if ((svp = hv_fetchs(hv, "varname", FALSE)))
1616 if ((svp = hv_fetchs(hv, "freezer", FALSE)))
1617 style.freezer = *svp;
1618 if ((svp = hv_fetchs(hv, "toaster", FALSE)))
1619 style.toaster = *svp;
1620 if ((svp = hv_fetchs(hv, "deepcopy", FALSE)))
1621 style.deepcopy = SvTRUE(*svp);
1622 if ((svp = hv_fetchs(hv, "quotekeys", FALSE)))
1623 style.quotekeys = SvTRUE(*svp);
1624 if ((svp = hv_fetchs(hv, "trailingcomma", FALSE)))
1625 style.trailingcomma = SvTRUE(*svp);
1626 if ((svp = hv_fetchs(hv, "deparse", FALSE)))
1627 style.deparse = SvTRUE(*svp);
1628 if ((svp = hv_fetchs(hv, "bless", FALSE)))
1630 if ((svp = hv_fetchs(hv, "maxdepth", FALSE)))
1631 style.maxdepth = SvIV(*svp);
1632 if ((svp = hv_fetchs(hv, "maxrecurse", FALSE)))
1633 style.maxrecurse = SvIV(*svp);
1634 if ((svp = hv_fetchs(hv, "sortkeys", FALSE))) {
1637 style.sortkeys = NULL;
1638 else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVCV)
1639 style.sortkeys = sv;
1641 #if PERL_VERSION_LT(5,8,0)
1642 /* 5.6 doesn't make sortsv() available to XS code,
1643 * so we must use this helper instead. Note that we
1644 * always allocate this mortal SV, but it will be
1645 * used only if at least one hash is encountered
1646 * while dumping recursively; an older version
1647 * allocated it lazily as needed. */
1648 style.sortkeys = sv_2mortal(newSVpvs("Data::Dumper::_sortkeys"));
1650 /* flag to use sortsv() for sorting hash keys */
1651 style.sortkeys = &PL_sv_yes;
1655 sv_2mortal((SV*)postav);
1658 imax = av_len(todumpav);
1661 valstr = newSVpvs_flags("", SVs_TEMP);
1662 for (i = 0; i <= imax; ++i) {
1666 if ((svp = av_fetch(todumpav, i, FALSE)))
1670 if ((svp = av_fetch(namesav, i, TRUE))) {
1671 sv_setsv(name, *svp);
1672 if (SvOK(*svp) && !SvPOK(*svp))
1673 (void)SvPV_nolen_const(name);
1676 (void)SvOK_off(name);
1679 if ((SvPVX_const(name))[0] == '*') {
1681 switch (SvTYPE(SvRV(val))) {
1683 (SvPVX(name))[0] = '@';
1686 (SvPVX(name))[0] = '%';
1689 (SvPVX(name))[0] = '*';
1692 (SvPVX(name))[0] = '$';
1697 (SvPVX(name))[0] = '$';
1699 else if ((SvPVX_const(name))[0] != '$')
1700 sv_insert(name, 0, 0, "$", 1);
1704 sv_setpvs(name, "$");
1705 sv_catsv(name, varname);
1706 nchars = my_snprintf(tmpbuf, sizeof(tmpbuf), "%" IVdf,
1708 sv_catpvn(name, tmpbuf, nchars);
1711 if (style.indent >= 2 && !terse) {
1712 SV * const tmpsv = sv_x(aTHX_ NULL, " ", 1, SvCUR(name)+3);
1713 newapad = sv_2mortal(newSVsv(apad));
1714 sv_catsv(newapad, tmpsv);
1715 SvREFCNT_dec(tmpsv);
1723 DD_dump(aTHX_ val, SvPVX_const(name), SvCUR(name), valstr, seenhv,
1724 postav, 0, newapad, &style);
1729 postlen = av_len(postav);
1730 if (postlen >= 0 || !terse) {
1731 sv_insert(valstr, 0, 0, " = ", 3);
1732 sv_insert(valstr, 0, 0, SvPVX_const(name), SvCUR(name));
1733 sv_catpvs(valstr, ";");
1735 sv_catsv(retval, style.pad);
1736 sv_catsv(retval, valstr);
1737 sv_catsv(retval, style.sep);
1740 sv_catsv(retval, style.pad);
1741 for (i = 0; i <= postlen; ++i) {
1743 svp = av_fetch(postav, i, FALSE);
1744 if (svp && (elem = *svp)) {
1745 sv_catsv(retval, elem);
1747 sv_catpvs(retval, ";");
1748 sv_catsv(retval, style.sep);
1749 sv_catsv(retval, style.pad);
1753 sv_catpvs(retval, ";");
1754 sv_catsv(retval, style.sep);
1757 if (gimme == G_ARRAY) {
1759 if (i < imax) /* not the last time thro ? */
1760 retval = newSVpvs_flags("", SVs_TEMP);
1764 /* we defer croaking until here so that temporary SVs and
1765 * buffers won't be leaked */
1766 if (style.maxrecursed)
1767 croak("Recursion limit of %" IVdf " exceeded",
1772 croak("Call to new() method failed to return HASH ref");
1773 if (gimme != G_ARRAY)
1778 Data_Dumper__vstring(sv)
1786 SvMAGICAL(sv) && (mg = mg_find(sv, 'V'))
1787 ? newSVpvn((const char *)mg->mg_ptr, mg->mg_len)
1790 RETVAL = &PL_sv_undef;