1 #define PERL_NO_GET_CONTEXT
7 #include "patchlevel.h"
8 #define PERL_VERSION PATCHLEVEL
13 # define PL_sv_undef sv_undef
16 # define ERRSV GvSV(errgv)
19 # define newSVpvn newSVpv
23 static I32 num_q (char *s, STRLEN slen);
24 static I32 esc_q (char *dest, char *src, STRLEN slen);
25 static I32 esc_q_utf8 (pTHX_ SV *sv, char *src, STRLEN slen);
26 static SV *sv_x (pTHX_ SV *sv, char *str, STRLEN len, I32 n);
27 static I32 DD_dump (pTHX_ SV *val, char *name, STRLEN namelen, SV *retval,
28 HV *seenhv, AV *postav, I32 *levelp, I32 indent,
29 SV *pad, SV *xpad, SV *apad, SV *sep,
30 SV *freezer, SV *toaster,
31 I32 purity, I32 deepcopy, I32 quotekeys, SV *bless,
34 /* does a string need to be protected? */
36 needs_quote(register char *s)
61 /* count the number of "'"s and "\"s in string */
63 num_q(register char *s, register STRLEN slen)
68 if (*s == '\'' || *s == '\\')
77 /* returns number of chars added to escape "'"s and "\"s in s */
78 /* slen number of characters in s will be escaped */
79 /* destination must be long enough for additional chars */
81 esc_q(register char *d, register char *s, register STRLEN slen)
101 esc_q_utf8(pTHX_ SV* sv, register char *src, register STRLEN slen)
104 STRLEN grow = 0, j = 1, l;
107 /* this will need EBCDICification */
108 for (s = src, send = src + slen; s < send; s += UTF8SKIP(s)) {
109 UV k = utf8_to_uvchr((U8*)s, &l);
112 (*s == '"' || *s == '\\') ? 2 :
113 (k < 0x80 ? 1 : UNISKIP(k) + 1 + 4); /* 4: \x{} */
115 sv_grow(sv, SvCUR(sv)+3+grow); /* 3: ""\0 */
116 r = SvPVX(sv) + SvCUR(sv);
118 for (s = src; s < send; s += UTF8SKIP(s)) {
119 UV k = utf8_to_uvchr((U8*)s, &l);
121 if (*s == '"' || *s == '\\') {
131 j += sprintf(r + j, "%"UVxf, k);
139 r[0] = r[j++] = '\'';
141 SvCUR_set(sv, SvCUR(sv) + j);
146 /* append a repeated string to an SV */
148 sv_x(pTHX_ SV *sv, register char *str, STRLEN len, I32 n)
151 sv = newSVpvn("", 0);
153 assert(SvTYPE(sv) >= SVt_PV);
156 SvGROW(sv, len*n + SvCUR(sv) + 1);
158 char *start = SvPVX(sv) + SvCUR(sv);
166 sv_catpvn(sv, str, len);
174 * This ought to be split into smaller functions. (it is one long function since
175 * it exactly parallels the perl version, which was one long thing for
176 * efficiency raisins.) Ugggh!
179 DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
180 AV *postav, I32 *levelp, I32 indent, SV *pad, SV *xpad,
181 SV *apad, SV *sep, SV *freezer, SV *toaster, I32 purity,
182 I32 deepcopy, I32 quotekeys, SV *bless, I32 maxdepth)
186 char *c, *r, *realpack, id[128];
188 SV *sv, *ipad, *ival;
189 SV *blesspad = Nullsv;
190 AV *seenentry = Nullav;
192 STRLEN inamelen, idlen = 0;
198 realtype = SvTYPE(val);
204 if (SvOBJECT(SvRV(val)) && freezer &&
205 SvPOK(freezer) && SvCUR(freezer))
207 dSP; ENTER; SAVETMPS; PUSHMARK(sp);
208 XPUSHs(val); PUTBACK;
209 i = perl_call_method(SvPVX(freezer), G_EVAL|G_SCALAR);
212 warn("WARNING(Freezer method call failed): %s",
216 PUTBACK; FREETMPS; LEAVE;
218 (void)sv_2mortal(val);
222 realtype = SvTYPE(ival);
223 (void) sprintf(id, "0x%lx", (unsigned long)ival);
226 realpack = HvNAME(SvSTASH(ival));
230 /* if it has a name, we need to either look it up, or keep a tab
231 * on it so we know when we hit it later
234 if ((svp = hv_fetch(seenhv, id, idlen, FALSE))
235 && (sv = *svp) && SvROK(sv) && (seenentry = (AV*)SvRV(sv)))
238 if ((svp = av_fetch(seenentry, 0, FALSE))
239 && (othername = *svp))
241 if (purity && *levelp > 0) {
244 if (realtype == SVt_PVHV)
245 sv_catpvn(retval, "{}", 2);
246 else if (realtype == SVt_PVAV)
247 sv_catpvn(retval, "[]", 2);
249 sv_catpvn(retval, "do{my $o}", 9);
250 postentry = newSVpvn(name, namelen);
251 sv_catpvn(postentry, " = ", 3);
252 sv_catsv(postentry, othername);
253 av_push(postav, postentry);
256 if (name[0] == '@' || name[0] == '%') {
257 if ((SvPVX(othername))[0] == '\\' &&
258 (SvPVX(othername))[1] == name[0]) {
259 sv_catpvn(retval, SvPVX(othername)+1,
263 sv_catpvn(retval, name, 1);
264 sv_catpvn(retval, "{", 1);
265 sv_catsv(retval, othername);
266 sv_catpvn(retval, "}", 1);
270 sv_catsv(retval, othername);
275 warn("ref name not found for %s", id);
279 else { /* store our name and continue */
281 if (name[0] == '@' || name[0] == '%') {
282 namesv = newSVpvn("\\", 1);
283 sv_catpvn(namesv, name, namelen);
285 else if (realtype == SVt_PVCV && name[0] == '*') {
286 namesv = newSVpvn("\\", 2);
287 sv_catpvn(namesv, name, namelen);
288 (SvPVX(namesv))[1] = '&';
291 namesv = newSVpvn(name, namelen);
293 av_push(seenentry, namesv);
294 (void)SvREFCNT_inc(val);
295 av_push(seenentry, val);
296 (void)hv_store(seenhv, id, strlen(id),
297 newRV((SV*)seenentry), 0);
298 SvREFCNT_dec(seenentry);
302 if (realpack && *realpack == 'R' && strEQ(realpack, "Regexp")) {
304 char *rval = SvPV(val, rlen);
305 char *slash = strchr(rval, '/');
306 sv_catpvn(retval, "qr/", 3);
308 sv_catpvn(retval, rval, slash-rval);
309 sv_catpvn(retval, "\\/", 2);
310 rlen -= slash-rval+1;
312 slash = strchr(rval, '/');
314 sv_catpvn(retval, rval, rlen);
315 sv_catpvn(retval, "/", 1);
319 /* If purity is not set and maxdepth is set, then check depth:
320 * if we have reached maximum depth, return the string
321 * representation of the thing we are currently examining
322 * at this depth (i.e., 'Foo=ARRAY(0xdeadbeef)').
324 if (!purity && maxdepth > 0 && *levelp >= maxdepth) {
326 char *valstr = SvPV(val,vallen);
327 sv_catpvn(retval, "'", 1);
328 sv_catpvn(retval, valstr, vallen);
329 sv_catpvn(retval, "'", 1);
333 if (realpack) { /* we have a blessed ref */
335 char *blessstr = SvPV(bless, blesslen);
336 sv_catpvn(retval, blessstr, blesslen);
337 sv_catpvn(retval, "( ", 2);
340 apad = newSVsv(apad);
341 sv_x(aTHX_ apad, " ", 1, blesslen+2);
346 ipad = sv_x(aTHX_ Nullsv, SvPVX(xpad), SvCUR(xpad), *levelp);
348 if (realtype <= SVt_PVBM) { /* scalar ref */
349 SV *namesv = newSVpvn("${", 2);
350 sv_catpvn(namesv, name, namelen);
351 sv_catpvn(namesv, "}", 1);
352 if (realpack) { /* blessed */
353 sv_catpvn(retval, "do{\\(my $o = ", 13);
354 DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
355 postav, levelp, indent, pad, xpad, apad, sep,
356 freezer, toaster, purity, deepcopy, quotekeys, bless,
358 sv_catpvn(retval, ")}", 2);
361 sv_catpvn(retval, "\\", 1);
362 DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
363 postav, levelp, indent, pad, xpad, apad, sep,
364 freezer, toaster, purity, deepcopy, quotekeys, bless,
367 SvREFCNT_dec(namesv);
369 else if (realtype == SVt_PVGV) { /* glob ref */
370 SV *namesv = newSVpvn("*{", 2);
371 sv_catpvn(namesv, name, namelen);
372 sv_catpvn(namesv, "}", 1);
373 sv_catpvn(retval, "\\", 1);
374 DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
375 postav, levelp, indent, pad, xpad, apad, sep,
376 freezer, toaster, purity, deepcopy, quotekeys, bless,
378 SvREFCNT_dec(namesv);
380 else if (realtype == SVt_PVAV) {
383 I32 ixmax = av_len((AV *)ival);
385 SV *ixsv = newSViv(0);
386 /* allowing for a 24 char wide array index */
387 New(0, iname, namelen+28, char);
388 (void)strcpy(iname, name);
390 if (name[0] == '@') {
391 sv_catpvn(retval, "(", 1);
395 sv_catpvn(retval, "[", 1);
396 /* omit "->" in $foo{bar}->[0], but not in ${$foo}->[0] */
398 && name[namelen-1] != ']' && name[namelen-1] != '}'
399 && (namelen < 4 || (name[1] != '{' && name[2] != '{')))*/
401 && name[namelen-1] != ']' && name[namelen-1] != '}')
404 || (name[0] == '\\' && name[2] == '{'))))
406 iname[inamelen++] = '-'; iname[inamelen++] = '>';
407 iname[inamelen] = '\0';
410 if (iname[0] == '*' && iname[inamelen-1] == '}' && inamelen >= 8 &&
411 (instr(iname+inamelen-8, "{SCALAR}") ||
412 instr(iname+inamelen-7, "{ARRAY}") ||
413 instr(iname+inamelen-6, "{HASH}"))) {
414 iname[inamelen++] = '-'; iname[inamelen++] = '>';
416 iname[inamelen++] = '['; iname[inamelen] = '\0';
417 totpad = newSVsv(sep);
418 sv_catsv(totpad, pad);
419 sv_catsv(totpad, apad);
421 for (ix = 0; ix <= ixmax; ++ix) {
424 svp = av_fetch((AV*)ival, ix, FALSE);
432 (void) sprintf(iname+ilen, "%"IVdf, (IV)ix);
433 ilen = strlen(iname);
434 iname[ilen++] = ']'; iname[ilen] = '\0';
436 sv_catsv(retval, totpad);
437 sv_catsv(retval, ipad);
438 sv_catpvn(retval, "#", 1);
439 sv_catsv(retval, ixsv);
441 sv_catsv(retval, totpad);
442 sv_catsv(retval, ipad);
443 DD_dump(aTHX_ elem, iname, ilen, retval, seenhv, postav,
444 levelp, indent, pad, xpad, apad, sep,
445 freezer, toaster, purity, deepcopy, quotekeys, bless,
448 sv_catpvn(retval, ",", 1);
451 SV *opad = sv_x(aTHX_ Nullsv, SvPVX(xpad), SvCUR(xpad), (*levelp)-1);
452 sv_catsv(retval, totpad);
453 sv_catsv(retval, opad);
457 sv_catpvn(retval, ")", 1);
459 sv_catpvn(retval, "]", 1);
461 SvREFCNT_dec(totpad);
464 else if (realtype == SVt_PVHV) {
465 SV *totpad, *newapad;
472 iname = newSVpvn(name, namelen);
473 if (name[0] == '%') {
474 sv_catpvn(retval, "(", 1);
475 (SvPVX(iname))[0] = '$';
478 sv_catpvn(retval, "{", 1);
479 /* omit "->" in $foo[0]->{bar}, but not in ${$foo}->{bar} */
481 && name[namelen-1] != ']' && name[namelen-1] != '}')
484 || (name[0] == '\\' && name[2] == '{'))))
486 sv_catpvn(iname, "->", 2);
489 if (name[0] == '*' && name[namelen-1] == '}' && namelen >= 8 &&
490 (instr(name+namelen-8, "{SCALAR}") ||
491 instr(name+namelen-7, "{ARRAY}") ||
492 instr(name+namelen-6, "{HASH}"))) {
493 sv_catpvn(iname, "->", 2);
495 sv_catpvn(iname, "{", 1);
496 totpad = newSVsv(sep);
497 sv_catsv(totpad, pad);
498 sv_catsv(totpad, apad);
500 (void)hv_iterinit((HV*)ival);
502 while ((entry = hv_iternext((HV*)ival))) {
507 bool do_utf8 = FALSE;
510 sv_catpvn(retval, ",", 1);
512 keysv = hv_iterkeysv(entry);
513 hval = hv_iterval((HV*)ival, entry);
515 do_utf8 = DO_UTF8(keysv);
516 key = SvPV(keysv, keylen);
520 char *okey = SvPVX(retval) + SvCUR(retval);
523 sv_catsv(retval, totpad);
524 sv_catsv(retval, ipad);
525 nlen = esc_q_utf8(aTHX_ retval, key, klen);
527 sname = newSVsv(iname);
528 sv_catpvn(sname, okey, nlen);
529 sv_catpvn(sname, "}", 1);
532 if (quotekeys || needs_quote(key)) {
533 nticks = num_q(key, klen);
534 New(0, nkey, klen+nticks+3, char);
537 klen += esc_q(nkey+1, key, klen);
539 (void)Copy(key, nkey+1, klen, char);
544 New(0, nkey, klen, char);
545 (void)Copy(key, nkey, klen, char);
548 sname = newSVsv(iname);
549 sv_catpvn(sname, nkey, klen);
550 sv_catpvn(sname, "}", 1);
552 sv_catsv(retval, totpad);
553 sv_catsv(retval, ipad);
554 sv_catpvn(retval, nkey, klen);
556 sv_catpvn(retval, " => ", 4);
560 newapad = newSVsv(apad);
561 New(0, extra, klen+4+1, char);
562 while (elen < (klen+4))
565 sv_catpvn(newapad, extra, elen);
571 DD_dump(aTHX_ hval, SvPVX(sname), SvCUR(sname), retval, seenhv,
572 postav, levelp, indent, pad, xpad, newapad, sep,
573 freezer, toaster, purity, deepcopy, quotekeys, bless,
578 SvREFCNT_dec(newapad);
581 SV *opad = sv_x(aTHX_ Nullsv, SvPVX(xpad), SvCUR(xpad), *levelp-1);
582 sv_catsv(retval, totpad);
583 sv_catsv(retval, opad);
587 sv_catpvn(retval, ")", 1);
589 sv_catpvn(retval, "}", 1);
591 SvREFCNT_dec(totpad);
593 else if (realtype == SVt_PVCV) {
594 sv_catpvn(retval, "sub { \"DUMMY\" }", 15);
596 warn("Encountered CODE ref, using dummy placeholder");
599 warn("cannot handle ref type %ld", realtype);
602 if (realpack) { /* free blessed allocs */
607 sv_catpvn(retval, ", '", 3);
608 sv_catpvn(retval, realpack, strlen(realpack));
609 sv_catpvn(retval, "' )", 3);
610 if (toaster && SvPOK(toaster) && SvCUR(toaster)) {
611 sv_catpvn(retval, "->", 2);
612 sv_catsv(retval, toaster);
613 sv_catpvn(retval, "()", 2);
623 (void) sprintf(id, "0x%lx", (unsigned long)val);
624 if ((svp = hv_fetch(seenhv, id, (idlen = strlen(id)), FALSE)) &&
625 (sv = *svp) && SvROK(sv) &&
626 (seenentry = (AV*)SvRV(sv)))
629 if ((svp = av_fetch(seenentry, 0, FALSE)) && (othername = *svp)
630 && (svp = av_fetch(seenentry, 2, FALSE)) && *svp && SvIV(*svp) > 0)
632 sv_catpvn(retval, "${", 2);
633 sv_catsv(retval, othername);
634 sv_catpvn(retval, "}", 1);
640 namesv = newSVpvn("\\", 1);
641 sv_catpvn(namesv, name, namelen);
643 av_push(seenentry, namesv);
644 av_push(seenentry, newRV(val));
645 (void)hv_store(seenhv, id, strlen(id), newRV((SV*)seenentry), 0);
646 SvREFCNT_dec(seenentry);
653 (void) sprintf(tmpbuf, "%"UVuf, SvUV(val));
655 (void) sprintf(tmpbuf, "%"IVdf, SvIV(val));
656 len = strlen(tmpbuf);
657 sv_catpvn(retval, tmpbuf, len);
659 else if (realtype == SVt_PVGV) {/* GLOBs can end up with scribbly names */
661 ++c; --i; /* just get the name */
662 if (i >= 6 && strncmp(c, "main::", 6) == 0) {
666 if (needs_quote(c)) {
667 sv_grow(retval, SvCUR(retval)+6+2*i);
668 r = SvPVX(retval)+SvCUR(retval);
669 r[0] = '*'; r[1] = '{'; r[2] = '\'';
670 i += esc_q(r+3, c, i);
672 r[i++] = '\''; r[i++] = '}';
676 sv_grow(retval, SvCUR(retval)+i+2);
677 r = SvPVX(retval)+SvCUR(retval);
678 r[0] = '*'; strcpy(r+1, c);
681 SvCUR_set(retval, SvCUR(retval)+i);
684 static char *entries[] = { "{SCALAR}", "{ARRAY}", "{HASH}" };
685 static STRLEN sizes[] = { 8, 7, 6 };
687 SV *nname = newSVpvn("", 0);
688 SV *newapad = newSVpvn("", 0);
692 for (j=0; j<3; j++) {
693 e = ((j == 0) ? GvSV(gv) : (j == 1) ? (SV*)GvAV(gv) : (SV*)GvHV(gv));
696 if (j == 0 && !SvOK(e))
701 SV *postentry = newSVpvn(r,i);
703 sv_setsv(nname, postentry);
704 sv_catpvn(nname, entries[j], sizes[j]);
705 sv_catpvn(postentry, " = ", 3);
706 av_push(postav, postentry);
711 (void)sv_x(aTHX_ newapad, " ", 1, SvCUR(postentry));
713 DD_dump(aTHX_ e, SvPVX(nname), SvCUR(nname), postentry,
714 seenhv, postav, &nlevel, indent, pad, xpad,
715 newapad, sep, freezer, toaster, purity,
716 deepcopy, quotekeys, bless, maxdepth);
721 SvREFCNT_dec(newapad);
725 else if (val == &PL_sv_undef || !SvOK(val)) {
726 sv_catpvn(retval, "undef", 5);
731 i += esc_q_utf8(aTHX_ retval, c, i);
733 sv_grow(retval, SvCUR(retval)+3+2*i); /* 3: ""\0 */
734 r = SvPVX(retval) + SvCUR(retval);
736 i += esc_q(r+1, c, i);
740 SvCUR_set(retval, SvCUR(retval)+i);
747 (void)hv_delete(seenhv, id, idlen, G_DISCARD);
748 else if (namelen && seenentry) {
749 SV *mark = *av_fetch(seenentry, 2, TRUE);
757 MODULE = Data::Dumper PACKAGE = Data::Dumper PREFIX = Data_Dumper_
760 # This is the exact equivalent of Dump. Well, almost. The things that are
761 # different as of now (due to Laziness):
762 # * doesnt do double-quotes yet.
766 Data_Dumper_Dumpxs(href, ...)
774 AV *postav, *todumpav, *namesav;
776 I32 indent, terse, i, imax, postlen;
778 SV *val, *name, *pad, *xpad, *apad, *sep, *varname;
779 SV *freezer, *toaster, *bless;
780 I32 purity, deepcopy, quotekeys, maxdepth = 0;
784 if (!SvROK(href)) { /* call new to get an object first */
786 croak("Usage: Data::Dumper::Dumpxs(PACKAGE, VAL_ARY_REF, [NAME_ARY_REF])");
793 XPUSHs(sv_2mortal(newSVsv(ST(1))));
795 XPUSHs(sv_2mortal(newSVsv(ST(2))));
797 i = perl_call_method("new", G_SCALAR);
800 href = newSVsv(POPs);
806 (void)sv_2mortal(href);
809 todumpav = namesav = Nullav;
811 val = pad = xpad = apad = sep = varname
812 = freezer = toaster = bless = &PL_sv_undef;
813 name = sv_newmortal();
815 terse = purity = deepcopy = 0;
818 retval = newSVpvn("", 0);
820 && (hv = (HV*)SvRV((SV*)href))
821 && SvTYPE(hv) == SVt_PVHV) {
823 if ((svp = hv_fetch(hv, "seen", 4, FALSE)) && SvROK(*svp))
824 seenhv = (HV*)SvRV(*svp);
825 if ((svp = hv_fetch(hv, "todump", 6, FALSE)) && SvROK(*svp))
826 todumpav = (AV*)SvRV(*svp);
827 if ((svp = hv_fetch(hv, "names", 5, FALSE)) && SvROK(*svp))
828 namesav = (AV*)SvRV(*svp);
829 if ((svp = hv_fetch(hv, "indent", 6, FALSE)))
831 if ((svp = hv_fetch(hv, "purity", 6, FALSE)))
833 if ((svp = hv_fetch(hv, "terse", 5, FALSE)))
834 terse = SvTRUE(*svp);
835 #if 0 /* useqq currently unused */
836 if ((svp = hv_fetch(hv, "useqq", 5, FALSE)))
837 useqq = SvTRUE(*svp);
839 if ((svp = hv_fetch(hv, "pad", 3, FALSE)))
841 if ((svp = hv_fetch(hv, "xpad", 4, FALSE)))
843 if ((svp = hv_fetch(hv, "apad", 4, FALSE)))
845 if ((svp = hv_fetch(hv, "sep", 3, FALSE)))
847 if ((svp = hv_fetch(hv, "varname", 7, FALSE)))
849 if ((svp = hv_fetch(hv, "freezer", 7, FALSE)))
851 if ((svp = hv_fetch(hv, "toaster", 7, FALSE)))
853 if ((svp = hv_fetch(hv, "deepcopy", 8, FALSE)))
854 deepcopy = SvTRUE(*svp);
855 if ((svp = hv_fetch(hv, "quotekeys", 9, FALSE)))
856 quotekeys = SvTRUE(*svp);
857 if ((svp = hv_fetch(hv, "bless", 5, FALSE)))
859 if ((svp = hv_fetch(hv, "maxdepth", 8, FALSE)))
860 maxdepth = SvIV(*svp);
864 imax = av_len(todumpav);
867 valstr = newSVpvn("",0);
868 for (i = 0; i <= imax; ++i) {
872 if ((svp = av_fetch(todumpav, i, FALSE)))
876 if ((svp = av_fetch(namesav, i, TRUE)))
877 sv_setsv(name, *svp);
879 (void)SvOK_off(name);
882 if ((SvPVX(name))[0] == '*') {
884 switch (SvTYPE(SvRV(val))) {
886 (SvPVX(name))[0] = '@';
889 (SvPVX(name))[0] = '%';
892 (SvPVX(name))[0] = '*';
895 (SvPVX(name))[0] = '$';
900 (SvPVX(name))[0] = '$';
902 else if ((SvPVX(name))[0] != '$')
903 sv_insert(name, 0, 0, "$", 1);
907 sv_setpvn(name, "$", 1);
908 sv_catsv(name, varname);
909 (void) sprintf(tmpbuf, "%"IVdf, (IV)(i+1));
910 nchars = strlen(tmpbuf);
911 sv_catpvn(name, tmpbuf, nchars);
915 SV *tmpsv = sv_x(aTHX_ Nullsv, " ", 1, SvCUR(name)+3);
916 newapad = newSVsv(apad);
917 sv_catsv(newapad, tmpsv);
923 DD_dump(aTHX_ val, SvPVX(name), SvCUR(name), valstr, seenhv,
924 postav, &level, indent, pad, xpad, newapad, sep,
925 freezer, toaster, purity, deepcopy, quotekeys,
929 SvREFCNT_dec(newapad);
931 postlen = av_len(postav);
932 if (postlen >= 0 || !terse) {
933 sv_insert(valstr, 0, 0, " = ", 3);
934 sv_insert(valstr, 0, 0, SvPVX(name), SvCUR(name));
935 sv_catpvn(valstr, ";", 1);
937 sv_catsv(retval, pad);
938 sv_catsv(retval, valstr);
939 sv_catsv(retval, sep);
942 sv_catsv(retval, pad);
943 for (i = 0; i <= postlen; ++i) {
945 svp = av_fetch(postav, i, FALSE);
946 if (svp && (elem = *svp)) {
947 sv_catsv(retval, elem);
949 sv_catpvn(retval, ";", 1);
950 sv_catsv(retval, sep);
951 sv_catsv(retval, pad);
955 sv_catpvn(retval, ";", 1);
956 sv_catsv(retval, sep);
958 sv_setpvn(valstr, "", 0);
959 if (gimme == G_ARRAY) {
960 XPUSHs(sv_2mortal(retval));
961 if (i < imax) /* not the last time thro ? */
962 retval = newSVpvn("",0);
965 SvREFCNT_dec(postav);
966 SvREFCNT_dec(valstr);
969 croak("Call to new() method failed to return HASH ref");
970 if (gimme == G_SCALAR)
971 XPUSHs(sv_2mortal(retval));