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 (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(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, "%x", 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;
199 flags = SvFLAGS(val);
200 realtype = SvTYPE(val);
206 if (SvOBJECT(SvRV(val)) && freezer &&
207 SvPOK(freezer) && SvCUR(freezer))
209 dSP; ENTER; SAVETMPS; PUSHMARK(sp);
210 XPUSHs(val); PUTBACK;
211 i = perl_call_method(SvPVX(freezer), G_EVAL|G_SCALAR);
214 warn("WARNING(Freezer method call failed): %s",
218 PUTBACK; FREETMPS; LEAVE;
220 (void)sv_2mortal(val);
224 flags = SvFLAGS(ival);
225 realtype = SvTYPE(ival);
226 (void) sprintf(id, "0x%lx", (unsigned long)ival);
229 realpack = HvNAME(SvSTASH(ival));
233 /* if it has a name, we need to either look it up, or keep a tab
234 * on it so we know when we hit it later
237 if ((svp = hv_fetch(seenhv, id, idlen, FALSE))
238 && (sv = *svp) && SvROK(sv) && (seenentry = (AV*)SvRV(sv)))
241 if ((svp = av_fetch(seenentry, 0, FALSE))
242 && (othername = *svp))
244 if (purity && *levelp > 0) {
247 if (realtype == SVt_PVHV)
248 sv_catpvn(retval, "{}", 2);
249 else if (realtype == SVt_PVAV)
250 sv_catpvn(retval, "[]", 2);
252 sv_catpvn(retval, "do{my $o}", 9);
253 postentry = newSVpvn(name, namelen);
254 sv_catpvn(postentry, " = ", 3);
255 sv_catsv(postentry, othername);
256 av_push(postav, postentry);
259 if (name[0] == '@' || name[0] == '%') {
260 if ((SvPVX(othername))[0] == '\\' &&
261 (SvPVX(othername))[1] == name[0]) {
262 sv_catpvn(retval, SvPVX(othername)+1,
266 sv_catpvn(retval, name, 1);
267 sv_catpvn(retval, "{", 1);
268 sv_catsv(retval, othername);
269 sv_catpvn(retval, "}", 1);
273 sv_catsv(retval, othername);
278 warn("ref name not found for %s", id);
282 else { /* store our name and continue */
284 if (name[0] == '@' || name[0] == '%') {
285 namesv = newSVpvn("\\", 1);
286 sv_catpvn(namesv, name, namelen);
288 else if (realtype == SVt_PVCV && name[0] == '*') {
289 namesv = newSVpvn("\\", 2);
290 sv_catpvn(namesv, name, namelen);
291 (SvPVX(namesv))[1] = '&';
294 namesv = newSVpvn(name, namelen);
296 av_push(seenentry, namesv);
297 (void)SvREFCNT_inc(val);
298 av_push(seenentry, val);
299 (void)hv_store(seenhv, id, strlen(id),
300 newRV((SV*)seenentry), 0);
301 SvREFCNT_dec(seenentry);
305 if (realpack && *realpack == 'R' && strEQ(realpack, "Regexp")) {
307 char *rval = SvPV(val, rlen);
308 char *slash = strchr(rval, '/');
309 sv_catpvn(retval, "qr/", 3);
311 sv_catpvn(retval, rval, slash-rval);
312 sv_catpvn(retval, "\\/", 2);
313 rlen -= slash-rval+1;
315 slash = strchr(rval, '/');
317 sv_catpvn(retval, rval, rlen);
318 sv_catpvn(retval, "/", 1);
322 /* If purity is not set and maxdepth is set, then check depth:
323 * if we have reached maximum depth, return the string
324 * representation of the thing we are currently examining
325 * at this depth (i.e., 'Foo=ARRAY(0xdeadbeef)').
327 if (!purity && maxdepth > 0 && *levelp >= maxdepth) {
329 char *valstr = SvPV(val,vallen);
330 sv_catpvn(retval, "'", 1);
331 sv_catpvn(retval, valstr, vallen);
332 sv_catpvn(retval, "'", 1);
336 if (realpack) { /* we have a blessed ref */
338 char *blessstr = SvPV(bless, blesslen);
339 sv_catpvn(retval, blessstr, blesslen);
340 sv_catpvn(retval, "( ", 2);
343 apad = newSVsv(apad);
344 sv_x(aTHX_ apad, " ", 1, blesslen+2);
349 ipad = sv_x(aTHX_ Nullsv, SvPVX(xpad), SvCUR(xpad), *levelp);
351 if (realtype <= SVt_PVBM) { /* scalar ref */
352 SV *namesv = newSVpvn("${", 2);
353 sv_catpvn(namesv, name, namelen);
354 sv_catpvn(namesv, "}", 1);
355 if (realpack) { /* blessed */
356 sv_catpvn(retval, "do{\\(my $o = ", 13);
357 DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
358 postav, levelp, indent, pad, xpad, apad, sep,
359 freezer, toaster, purity, deepcopy, quotekeys, bless,
361 sv_catpvn(retval, ")}", 2);
364 sv_catpvn(retval, "\\", 1);
365 DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
366 postav, levelp, indent, pad, xpad, apad, sep,
367 freezer, toaster, purity, deepcopy, quotekeys, bless,
370 SvREFCNT_dec(namesv);
372 else if (realtype == SVt_PVGV) { /* glob ref */
373 SV *namesv = newSVpvn("*{", 2);
374 sv_catpvn(namesv, name, namelen);
375 sv_catpvn(namesv, "}", 1);
376 sv_catpvn(retval, "\\", 1);
377 DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
378 postav, levelp, indent, pad, xpad, apad, sep,
379 freezer, toaster, purity, deepcopy, quotekeys, bless,
381 SvREFCNT_dec(namesv);
383 else if (realtype == SVt_PVAV) {
386 I32 ixmax = av_len((AV *)ival);
388 SV *ixsv = newSViv(0);
389 /* allowing for a 24 char wide array index */
390 New(0, iname, namelen+28, char);
391 (void)strcpy(iname, name);
393 if (name[0] == '@') {
394 sv_catpvn(retval, "(", 1);
398 sv_catpvn(retval, "[", 1);
399 /* omit "->" in $foo{bar}->[0], but not in ${$foo}->[0] */
401 && name[namelen-1] != ']' && name[namelen-1] != '}'
402 && (namelen < 4 || (name[1] != '{' && name[2] != '{')))*/
404 && name[namelen-1] != ']' && name[namelen-1] != '}')
407 || (name[0] == '\\' && name[2] == '{'))))
409 iname[inamelen++] = '-'; iname[inamelen++] = '>';
410 iname[inamelen] = '\0';
413 if (iname[0] == '*' && iname[inamelen-1] == '}' && inamelen >= 8 &&
414 (instr(iname+inamelen-8, "{SCALAR}") ||
415 instr(iname+inamelen-7, "{ARRAY}") ||
416 instr(iname+inamelen-6, "{HASH}"))) {
417 iname[inamelen++] = '-'; iname[inamelen++] = '>';
419 iname[inamelen++] = '['; iname[inamelen] = '\0';
420 totpad = newSVsv(sep);
421 sv_catsv(totpad, pad);
422 sv_catsv(totpad, apad);
424 for (ix = 0; ix <= ixmax; ++ix) {
427 svp = av_fetch((AV*)ival, ix, FALSE);
435 (void) sprintf(iname+ilen, "%"IVdf, (IV)ix);
436 ilen = strlen(iname);
437 iname[ilen++] = ']'; iname[ilen] = '\0';
439 sv_catsv(retval, totpad);
440 sv_catsv(retval, ipad);
441 sv_catpvn(retval, "#", 1);
442 sv_catsv(retval, ixsv);
444 sv_catsv(retval, totpad);
445 sv_catsv(retval, ipad);
446 DD_dump(aTHX_ elem, iname, ilen, retval, seenhv, postav,
447 levelp, indent, pad, xpad, apad, sep,
448 freezer, toaster, purity, deepcopy, quotekeys, bless,
451 sv_catpvn(retval, ",", 1);
454 SV *opad = sv_x(aTHX_ Nullsv, SvPVX(xpad), SvCUR(xpad), (*levelp)-1);
455 sv_catsv(retval, totpad);
456 sv_catsv(retval, opad);
460 sv_catpvn(retval, ")", 1);
462 sv_catpvn(retval, "]", 1);
464 SvREFCNT_dec(totpad);
467 else if (realtype == SVt_PVHV) {
468 SV *totpad, *newapad;
475 iname = newSVpvn(name, namelen);
476 if (name[0] == '%') {
477 sv_catpvn(retval, "(", 1);
478 (SvPVX(iname))[0] = '$';
481 sv_catpvn(retval, "{", 1);
482 /* omit "->" in $foo[0]->{bar}, but not in ${$foo}->{bar} */
484 && name[namelen-1] != ']' && name[namelen-1] != '}')
487 || (name[0] == '\\' && name[2] == '{'))))
489 sv_catpvn(iname, "->", 2);
492 if (name[0] == '*' && name[namelen-1] == '}' && namelen >= 8 &&
493 (instr(name+namelen-8, "{SCALAR}") ||
494 instr(name+namelen-7, "{ARRAY}") ||
495 instr(name+namelen-6, "{HASH}"))) {
496 sv_catpvn(iname, "->", 2);
498 sv_catpvn(iname, "{", 1);
499 totpad = newSVsv(sep);
500 sv_catsv(totpad, pad);
501 sv_catsv(totpad, apad);
503 (void)hv_iterinit((HV*)ival);
505 while ((entry = hv_iternext((HV*)ival))) {
510 bool do_utf8 = FALSE;
513 sv_catpvn(retval, ",", 1);
515 keysv = hv_iterkeysv(entry);
516 hval = hv_iterval((HV*)ival, entry);
518 do_utf8 = DO_UTF8(keysv);
519 key = SvPV(keysv, keylen);
523 char *okey = SvPVX(retval) + SvCUR(retval);
526 sv_catsv(retval, totpad);
527 sv_catsv(retval, ipad);
528 nlen = esc_q_utf8(retval, key, klen);
530 sname = newSVsv(iname);
531 sv_catpvn(sname, okey, nlen);
532 sv_catpvn(sname, "}", 1);
535 if (quotekeys || needs_quote(key)) {
536 nticks = num_q(key, klen);
537 New(0, nkey, klen+nticks+3, char);
540 klen += esc_q(nkey+1, key, klen);
542 (void)Copy(key, nkey+1, klen, char);
547 New(0, nkey, klen, char);
548 (void)Copy(key, nkey, klen, char);
551 sname = newSVsv(iname);
552 sv_catpvn(sname, nkey, klen);
553 sv_catpvn(sname, "}", 1);
555 sv_catsv(retval, totpad);
556 sv_catsv(retval, ipad);
557 sv_catpvn(retval, nkey, klen);
559 sv_catpvn(retval, " => ", 4);
563 newapad = newSVsv(apad);
564 New(0, extra, klen+4+1, char);
565 while (elen < (klen+4))
568 sv_catpvn(newapad, extra, elen);
574 DD_dump(aTHX_ hval, SvPVX(sname), SvCUR(sname), retval, seenhv,
575 postav, levelp, indent, pad, xpad, newapad, sep,
576 freezer, toaster, purity, deepcopy, quotekeys, bless,
581 SvREFCNT_dec(newapad);
584 SV *opad = sv_x(aTHX_ Nullsv, SvPVX(xpad), SvCUR(xpad), *levelp-1);
585 sv_catsv(retval, totpad);
586 sv_catsv(retval, opad);
590 sv_catpvn(retval, ")", 1);
592 sv_catpvn(retval, "}", 1);
594 SvREFCNT_dec(totpad);
596 else if (realtype == SVt_PVCV) {
597 sv_catpvn(retval, "sub { \"DUMMY\" }", 15);
599 warn("Encountered CODE ref, using dummy placeholder");
602 warn("cannot handle ref type %ld", realtype);
605 if (realpack) { /* free blessed allocs */
610 sv_catpvn(retval, ", '", 3);
611 sv_catpvn(retval, realpack, strlen(realpack));
612 sv_catpvn(retval, "' )", 3);
613 if (toaster && SvPOK(toaster) && SvCUR(toaster)) {
614 sv_catpvn(retval, "->", 2);
615 sv_catsv(retval, toaster);
616 sv_catpvn(retval, "()", 2);
626 (void) sprintf(id, "0x%lx", (unsigned long)val);
627 if ((svp = hv_fetch(seenhv, id, (idlen = strlen(id)), FALSE)) &&
628 (sv = *svp) && SvROK(sv) &&
629 (seenentry = (AV*)SvRV(sv)))
632 if ((svp = av_fetch(seenentry, 0, FALSE)) && (othername = *svp)
633 && (svp = av_fetch(seenentry, 2, FALSE)) && *svp && SvIV(*svp) > 0)
635 sv_catpvn(retval, "${", 2);
636 sv_catsv(retval, othername);
637 sv_catpvn(retval, "}", 1);
643 namesv = newSVpvn("\\", 1);
644 sv_catpvn(namesv, name, namelen);
646 av_push(seenentry, namesv);
647 av_push(seenentry, newRV(val));
648 (void)hv_store(seenhv, id, strlen(id), newRV((SV*)seenentry), 0);
649 SvREFCNT_dec(seenentry);
656 (void) sprintf(tmpbuf, "%"UVuf, SvUV(val));
658 (void) sprintf(tmpbuf, "%"IVdf, SvIV(val));
659 len = strlen(tmpbuf);
660 sv_catpvn(retval, tmpbuf, len);
662 else if (realtype == SVt_PVGV) {/* GLOBs can end up with scribbly names */
664 ++c; --i; /* just get the name */
665 if (i >= 6 && strncmp(c, "main::", 6) == 0) {
669 if (needs_quote(c)) {
670 sv_grow(retval, SvCUR(retval)+6+2*i);
671 r = SvPVX(retval)+SvCUR(retval);
672 r[0] = '*'; r[1] = '{'; r[2] = '\'';
673 i += esc_q(r+3, c, i);
675 r[i++] = '\''; r[i++] = '}';
679 sv_grow(retval, SvCUR(retval)+i+2);
680 r = SvPVX(retval)+SvCUR(retval);
681 r[0] = '*'; strcpy(r+1, c);
684 SvCUR_set(retval, SvCUR(retval)+i);
687 static char *entries[] = { "{SCALAR}", "{ARRAY}", "{HASH}" };
688 static STRLEN sizes[] = { 8, 7, 6 };
690 SV *nname = newSVpvn("", 0);
691 SV *newapad = newSVpvn("", 0);
695 for (j=0; j<3; j++) {
696 e = ((j == 0) ? GvSV(gv) : (j == 1) ? (SV*)GvAV(gv) : (SV*)GvHV(gv));
699 if (j == 0 && !SvOK(e))
704 SV *postentry = newSVpvn(r,i);
706 sv_setsv(nname, postentry);
707 sv_catpvn(nname, entries[j], sizes[j]);
708 sv_catpvn(postentry, " = ", 3);
709 av_push(postav, postentry);
714 (void)sv_x(aTHX_ newapad, " ", 1, SvCUR(postentry));
716 DD_dump(aTHX_ e, SvPVX(nname), SvCUR(nname), postentry,
717 seenhv, postav, &nlevel, indent, pad, xpad,
718 newapad, sep, freezer, toaster, purity,
719 deepcopy, quotekeys, bless, maxdepth);
724 SvREFCNT_dec(newapad);
728 else if (val == &PL_sv_undef || !SvOK(val)) {
729 sv_catpvn(retval, "undef", 5);
734 i += esc_q_utf8(retval, c, i);
736 sv_grow(retval, SvCUR(retval)+3+2*i); /* 3: ""\0 */
737 r = SvPVX(retval) + SvCUR(retval);
739 i += esc_q(r+1, c, i);
743 SvCUR_set(retval, SvCUR(retval)+i);
750 (void)hv_delete(seenhv, id, idlen, G_DISCARD);
751 else if (namelen && seenentry) {
752 SV *mark = *av_fetch(seenentry, 2, TRUE);
760 MODULE = Data::Dumper PACKAGE = Data::Dumper PREFIX = Data_Dumper_
763 # This is the exact equivalent of Dump. Well, almost. The things that are
764 # different as of now (due to Laziness):
765 # * doesnt do double-quotes yet.
769 Data_Dumper_Dumpxs(href, ...)
777 AV *postav, *todumpav, *namesav;
779 I32 indent, terse, useqq, i, imax, postlen;
781 SV *val, *name, *pad, *xpad, *apad, *sep, *tmp, *varname;
782 SV *freezer, *toaster, *bless;
783 I32 purity, deepcopy, quotekeys, maxdepth = 0;
787 if (!SvROK(href)) { /* call new to get an object first */
789 croak("Usage: Data::Dumper::Dumpxs(PACKAGE, VAL_ARY_REF, [NAME_ARY_REF])");
796 XPUSHs(sv_2mortal(newSVsv(ST(1))));
798 XPUSHs(sv_2mortal(newSVsv(ST(2))));
800 i = perl_call_method("new", G_SCALAR);
803 href = newSVsv(POPs);
809 (void)sv_2mortal(href);
812 todumpav = namesav = Nullav;
814 val = pad = xpad = apad = sep = tmp = varname
815 = freezer = toaster = bless = &PL_sv_undef;
816 name = sv_newmortal();
818 terse = useqq = purity = deepcopy = 0;
821 retval = newSVpvn("", 0);
823 && (hv = (HV*)SvRV((SV*)href))
824 && SvTYPE(hv) == SVt_PVHV) {
826 if ((svp = hv_fetch(hv, "seen", 4, FALSE)) && SvROK(*svp))
827 seenhv = (HV*)SvRV(*svp);
828 if ((svp = hv_fetch(hv, "todump", 6, FALSE)) && SvROK(*svp))
829 todumpav = (AV*)SvRV(*svp);
830 if ((svp = hv_fetch(hv, "names", 5, FALSE)) && SvROK(*svp))
831 namesav = (AV*)SvRV(*svp);
832 if ((svp = hv_fetch(hv, "indent", 6, FALSE)))
834 if ((svp = hv_fetch(hv, "purity", 6, FALSE)))
836 if ((svp = hv_fetch(hv, "terse", 5, FALSE)))
837 terse = SvTRUE(*svp);
838 if ((svp = hv_fetch(hv, "useqq", 5, FALSE)))
839 useqq = SvTRUE(*svp);
840 if ((svp = hv_fetch(hv, "pad", 3, FALSE)))
842 if ((svp = hv_fetch(hv, "xpad", 4, FALSE)))
844 if ((svp = hv_fetch(hv, "apad", 4, FALSE)))
846 if ((svp = hv_fetch(hv, "sep", 3, FALSE)))
848 if ((svp = hv_fetch(hv, "varname", 7, FALSE)))
850 if ((svp = hv_fetch(hv, "freezer", 7, FALSE)))
852 if ((svp = hv_fetch(hv, "toaster", 7, FALSE)))
854 if ((svp = hv_fetch(hv, "deepcopy", 8, FALSE)))
855 deepcopy = SvTRUE(*svp);
856 if ((svp = hv_fetch(hv, "quotekeys", 9, FALSE)))
857 quotekeys = SvTRUE(*svp);
858 if ((svp = hv_fetch(hv, "bless", 5, FALSE)))
860 if ((svp = hv_fetch(hv, "maxdepth", 8, FALSE)))
861 maxdepth = SvIV(*svp);
865 imax = av_len(todumpav);
868 valstr = newSVpvn("",0);
869 for (i = 0; i <= imax; ++i) {
873 if ((svp = av_fetch(todumpav, i, FALSE)))
877 if ((svp = av_fetch(namesav, i, TRUE)))
878 sv_setsv(name, *svp);
880 (void)SvOK_off(name);
883 if ((SvPVX(name))[0] == '*') {
885 switch (SvTYPE(SvRV(val))) {
887 (SvPVX(name))[0] = '@';
890 (SvPVX(name))[0] = '%';
893 (SvPVX(name))[0] = '*';
896 (SvPVX(name))[0] = '$';
901 (SvPVX(name))[0] = '$';
903 else if ((SvPVX(name))[0] != '$')
904 sv_insert(name, 0, 0, "$", 1);
908 sv_setpvn(name, "$", 1);
909 sv_catsv(name, varname);
910 (void) sprintf(tmpbuf, "%"IVdf, (IV)(i+1));
911 nchars = strlen(tmpbuf);
912 sv_catpvn(name, tmpbuf, nchars);
916 SV *tmpsv = sv_x(aTHX_ Nullsv, " ", 1, SvCUR(name)+3);
917 newapad = newSVsv(apad);
918 sv_catsv(newapad, tmpsv);
924 DD_dump(aTHX_ val, SvPVX(name), SvCUR(name), valstr, seenhv,
925 postav, &level, indent, pad, xpad, newapad, sep,
926 freezer, toaster, purity, deepcopy, quotekeys,
930 SvREFCNT_dec(newapad);
932 postlen = av_len(postav);
933 if (postlen >= 0 || !terse) {
934 sv_insert(valstr, 0, 0, " = ", 3);
935 sv_insert(valstr, 0, 0, SvPVX(name), SvCUR(name));
936 sv_catpvn(valstr, ";", 1);
938 sv_catsv(retval, pad);
939 sv_catsv(retval, valstr);
940 sv_catsv(retval, sep);
943 sv_catsv(retval, pad);
944 for (i = 0; i <= postlen; ++i) {
946 svp = av_fetch(postav, i, FALSE);
947 if (svp && (elem = *svp)) {
948 sv_catsv(retval, elem);
950 sv_catpvn(retval, ";", 1);
951 sv_catsv(retval, sep);
952 sv_catsv(retval, pad);
956 sv_catpvn(retval, ";", 1);
957 sv_catsv(retval, sep);
959 sv_setpvn(valstr, "", 0);
960 if (gimme == G_ARRAY) {
961 XPUSHs(sv_2mortal(retval));
962 if (i < imax) /* not the last time thro ? */
963 retval = newSVpvn("",0);
966 SvREFCNT_dec(postav);
967 SvREFCNT_dec(valstr);
970 croak("Call to new() method failed to return HASH ref");
971 if (gimme == G_SCALAR)
972 XPUSHs(sv_2mortal(retval));