3 * Copyright (c) 1991-1994, Larry Wall
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 * "It's a big house this, and very peculiar. Always a bit more to discover,
12 * and no knowing what you'll find around a corner. And Elves, sir!" --Samwise
18 static void doencodes _((SV *sv, char *s, I32 len));
20 /* variations on pp_null */
25 if (GIMME != G_ARRAY) {
41 if (op->op_private & OPpLVAL_INTRO)
42 SAVECLEARSV(curpad[op->op_targ]);
44 if (op->op_flags & OPf_REF) {
48 if (GIMME == G_ARRAY) {
49 I32 maxarg = AvFILL((AV*)TARG) + 1;
51 Copy(AvARRAY((AV*)TARG), SP+1, maxarg, SV*);
55 SV* sv = sv_newmortal();
56 I32 maxarg = AvFILL((AV*)TARG) + 1;
67 if (op->op_private & OPpLVAL_INTRO)
68 SAVECLEARSV(curpad[op->op_targ]);
69 if (op->op_flags & OPf_REF)
71 if (GIMME == G_ARRAY) { /* array wanted */
72 RETURNOP(do_kv(ARGS));
75 SV* sv = sv_newmortal();
76 if (HvFILL((HV*)TARG)) {
77 sprintf(buf, "%d/%d", HvFILL((HV*)TARG), HvMAX((HV*)TARG)+1);
89 DIE("NOT IMPL LINE %d",__LINE__);
101 if (SvTYPE(sv) != SVt_PVGV)
102 DIE("Not a GLOB reference");
105 if (SvTYPE(sv) != SVt_PVGV) {
108 if (SvGMAGICAL(sv)) {
114 if (op->op_flags & OPf_REF ||
115 op->op_private & HINT_STRICT_REFS)
116 DIE(no_usym, "a symbol");
120 if (op->op_private & HINT_STRICT_REFS)
121 DIE(no_symref, sym, "a symbol");
122 sv = (SV*)gv_fetchpv(sym, TRUE, SVt_PVGV);
125 if (op->op_private & OPpLVAL_INTRO) {
129 SSPUSHPTR(SvREFCNT_inc(sv));
133 if (op->op_flags & OPf_SPECIAL) {
134 GvGP(sv)->gp_refcnt++; /* will soon be assigned */
142 GvSV(sv) = NEWSV(72,0);
143 GvLINE(sv) = curcop->cop_line;
158 switch (SvTYPE(sv)) {
162 DIE("Not a SCALAR reference");
169 if (SvTYPE(gv) != SVt_PVGV) {
170 if (SvGMAGICAL(sv)) {
176 if (op->op_flags & OPf_REF ||
177 op->op_private & HINT_STRICT_REFS)
178 DIE(no_usym, "a SCALAR");
182 if (op->op_private & HINT_STRICT_REFS)
183 DIE(no_symref, sym, "a SCALAR");
184 gv = (SV*)gv_fetchpv(sym, TRUE, SVt_PV);
188 if (op->op_flags & OPf_MOD) {
189 if (op->op_private & OPpLVAL_INTRO)
190 sv = save_scalar((GV*)TOPs);
191 else if (op->op_private & (OPpDEREF_HV|OPpDEREF_AV))
202 SV *sv = AvARYLEN(av);
204 AvARYLEN(av) = sv = NEWSV(0,0);
205 sv_upgrade(sv, SVt_IV);
206 sv_magic(sv, (SV*)av, '#', Nullch, 0);
214 dSP; dTARGET; dPOPss;
216 if (op->op_flags & OPf_MOD) {
219 PUSHs(TARG); /* no SvSETMAGIC */
225 if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv)) {
226 mg = mg_find(sv, 'g');
227 if (mg && mg->mg_len >= 0) {
228 PUSHi(mg->mg_len + curcop->cop_arybase);
242 /* We usually try to add a non-existent subroutine in case of AUTOLOAD. */
243 /* (But not in defined().) */
244 CV *cv = sv_2cv(TOPs, &stash, &gv, !(op->op_flags & OPf_SPECIAL));
261 cv = sv_2cv(TOPs, &stash, &gv, FALSE);
262 if (cv && SvPOK(cv)) {
264 ret = sv_2mortal(newSVpv(p ? p : "", SvLEN(cv)));
273 CV* cv = (CV*)cSVOP->op_sv;
277 cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
288 sv_upgrade(rv, SVt_RV);
293 (void)SvREFCNT_inc(sv);
306 if (GIMME != G_ARRAY) {
313 sv_upgrade(rv, SVt_RV);
318 (void)SvREFCNT_inc(sv);
334 if (!sv || !SvROK(sv))
338 pv = sv_reftype(sv,TRUE);
339 PUSHp(pv, strlen(pv));
349 stash = curcop->cop_stash;
351 stash = gv_stashsv(POPs, TRUE);
353 (void)sv_bless(TOPs, stash);
357 /* Pattern matching */
362 register unsigned char *s;
365 register I32 *sfirst;
370 s = (unsigned char*)(SvPV(sv, len));
372 if (sv == lastscream)
376 SvSCREAM_off(lastscream);
377 SvREFCNT_dec(lastscream);
379 lastscream = SvREFCNT_inc(sv);
385 if (pos > maxscream) {
387 maxscream = pos + 80;
388 New(301, screamfirst, 256, I32);
389 New(302, screamnext, maxscream, I32);
392 maxscream = pos + pos / 4;
393 Renew(screamnext, maxscream, I32);
397 sfirst = screamfirst;
400 if (!sfirst || !snext)
401 DIE("do_study: out of memory");
403 for (ch = 256; ch; --ch)
410 snext[pos] = sfirst[ch] - pos;
415 /* If there were any case insensitive searches, we must assume they
416 * all are. This speeds up insensitive searches much more than
417 * it slows down sensitive ones.
420 sfirst[fold[ch]] = pos;
424 sv_magic(sv, Nullsv, 'g', Nullch, 0); /* piggyback on m//g magic */
427 XPUSHs(sv_2mortal(newSViv((I32)retval)));
436 if (op->op_flags & OPf_STACKED)
442 TARG = sv_newmortal();
443 PUSHi(do_trans(sv, op));
447 /* Lvalue operators. */
469 SETi(do_chomp(TOPs));
476 register I32 count = 0;
479 count += do_chomp(POPs);
490 if (!sv || !SvANY(sv))
492 switch (SvTYPE(sv)) {
494 if (AvMAX(sv) >= 0 || SvRMAGICAL(sv))
498 if (HvARRAY(sv) || SvRMAGICAL(sv))
502 if (CvROOT(sv) || CvXSUB(sv))
526 if (SvTHINKFIRST(sv)) {
533 switch (SvTYPE(sv)) {
548 sv_setsv(sv, &sv_undef);
552 if (SvPOK(sv) && SvLEN(sv)) {
555 SvPV_set(sv, Nullch);
570 SvFLAGS(TOPs) &= ~(SVf_NOK|SVf_POK|SVp_NOK|SVp_POK);
581 sv_setsv(TARG, TOPs);
584 SvFLAGS(TOPs) &= ~(SVf_NOK|SVf_POK|SVp_NOK|SVp_POK);
598 sv_setsv(TARG, TOPs);
601 SvFLAGS(TOPs) &= ~(SVf_NOK|SVf_POK|SVp_NOK|SVp_POK);
610 /* Ordinary operators. */
614 dSP; dATARGET; tryAMAGICbin(pow,opASSIGN);
617 SETn( pow( left, right) );
624 dSP; dATARGET; tryAMAGICbin(mult,opASSIGN);
627 SETn( left * right );
634 dSP; dATARGET; tryAMAGICbin(div,opASSIGN);
638 DIE("Illegal division by zero");
640 /* insure that 20./5. == 4. */
645 if ((double)I_32(x) == x &&
646 (double)I_32(value) == value &&
647 (k = I_32(x)/I_32(value))*I_32(value) == I_32(x)) {
654 value = POPn / value;
663 dSP; dATARGET; tryAMAGICbin(mod,opASSIGN);
665 register unsigned long tmpulong;
666 register long tmplong;
669 tmpulong = (unsigned long) POPn;
671 DIE("Illegal modulus zero");
674 value = (I32)(((unsigned long)value) % tmpulong);
676 tmplong = (long)value;
677 value = (I32)(tmpulong - ((-tmplong - 1) % tmpulong)) - 1;
686 dSP; dATARGET; tryAMAGICbin(repeat,opASSIGN);
688 register I32 count = POPi;
689 if (GIMME == G_ARRAY && op->op_private & OPpREPEAT_DOLIST) {
691 I32 items = SP - MARK;
703 repeatcpy((char*)(MARK + items), (char*)MARK,
704 items * sizeof(SV*), count - 1);
710 else { /* Note: mark already snarfed by pp_list */
715 if (TARG == tmpstr && SvTHINKFIRST(tmpstr)) {
716 if (SvREADONLY(tmpstr) && curcop != &compiling)
717 DIE("Can't x= to readonly value");
721 SvSetSV(TARG, tmpstr);
722 SvPV_force(TARG, len);
724 SvGROW(TARG, (count * len) + 1);
726 repeatcpy(SvPVX(TARG) + len, SvPVX(TARG), len, count - 1);
727 SvCUR(TARG) *= count;
729 (void)SvPOK_only(TARG);
732 sv_setsv(TARG, &sv_no);
741 dSP; dATARGET; tryAMAGICbin(subtr,opASSIGN);
744 SETn( left - right );
751 dSP; dATARGET; tryAMAGICbin(lshift,opASSIGN);
754 SETi( left << right );
761 dSP; dATARGET; tryAMAGICbin(rshift,opASSIGN);
764 SETi( left >> right );
771 dSP; tryAMAGICbinSET(lt,0);
774 SETs((TOPn < value) ? &sv_yes : &sv_no);
781 dSP; tryAMAGICbinSET(gt,0);
784 SETs((TOPn > value) ? &sv_yes : &sv_no);
791 dSP; tryAMAGICbinSET(le,0);
794 SETs((TOPn <= value) ? &sv_yes : &sv_no);
801 dSP; tryAMAGICbinSET(ge,0);
804 SETs((TOPn >= value) ? &sv_yes : &sv_no);
811 dSP; tryAMAGICbinSET(ne,0);
814 SETs((TOPn != value) ? &sv_yes : &sv_no);
821 dSP; dTARGET; tryAMAGICbin(ncmp,0);
828 else if (left < right)
839 dSP; tryAMAGICbinSET(slt,0);
842 SETs( sv_cmp(left, right) < 0 ? &sv_yes : &sv_no );
849 dSP; tryAMAGICbinSET(sgt,0);
852 SETs( sv_cmp(left, right) > 0 ? &sv_yes : &sv_no );
859 dSP; tryAMAGICbinSET(sle,0);
862 SETs( sv_cmp(left, right) <= 0 ? &sv_yes : &sv_no );
869 dSP; tryAMAGICbinSET(sge,0);
872 SETs( sv_cmp(left, right) >= 0 ? &sv_yes : &sv_no );
879 dSP; tryAMAGICbinSET(sne,0);
882 SETs( !sv_eq(left, right) ? &sv_yes : &sv_no );
889 dSP; dTARGET; tryAMAGICbin(scmp,0);
892 SETi( sv_cmp(left, right) );
898 dSP; dATARGET; tryAMAGICbin(band,opASSIGN);
901 if (SvNIOKp(left) || SvNIOKp(right)) {
902 unsigned long value = U_L(SvNV(left));
903 value = value & U_L(SvNV(right));
907 do_vop(op->op_type, TARG, left, right);
916 dSP; dATARGET; tryAMAGICbin(bxor,opASSIGN);
919 if (SvNIOKp(left) || SvNIOKp(right)) {
920 unsigned long value = U_L(SvNV(left));
921 value = value ^ U_L(SvNV(right));
925 do_vop(op->op_type, TARG, left, right);
934 dSP; dATARGET; tryAMAGICbin(bor,opASSIGN);
937 if (SvNIOKp(left) || SvNIOKp(right)) {
938 unsigned long value = U_L(SvNV(left));
939 value = value | U_L(SvNV(right));
943 do_vop(op->op_type, TARG, left, right);
952 dSP; dTARGET; tryAMAGICun(neg);
959 else if (SvPOKp(sv)) {
961 char *s = SvPV(sv, len);
962 if (isALPHA(*s) || *s == '_') {
963 sv_setpvn(TARG, "-", 1);
966 else if (*s == '+' || *s == '-') {
968 *SvPV_force(TARG, len) = *s == '-' ? '+' : '-';
971 sv_setnv(TARG, -SvNV(sv));
983 dSP; tryAMAGICunSET(not);
984 #endif /* OVERLOAD */
985 *stack_sp = SvTRUE(*stack_sp) ? &sv_no : &sv_yes;
991 dSP; dTARGET; tryAMAGICun(compl);
999 SETn( (double) ~U_L(SvNV(sv)) );
1004 register char *tmps;
1005 register long *tmpl;
1009 tmps = SvPV_force(TARG, len);
1012 for ( ; anum && (unsigned long)tmps % sizeof(long); anum--, tmps++)
1015 for ( ; anum >= sizeof(long); anum -= sizeof(long), tmpl++)
1019 for ( ; anum > 0; anum--, tmps++)
1028 /* integer versions of some of the above */
1032 dSP; dATARGET; tryAMAGICbin(mult,opASSIGN);
1035 SETi( left * right );
1042 dSP; dATARGET; tryAMAGICbin(div,opASSIGN);
1046 DIE("Illegal division by zero");
1047 value = POPi / value;
1055 dSP; dATARGET; tryAMAGICbin(mod,opASSIGN);
1058 SETi( left % right );
1065 dSP; dATARGET; tryAMAGICbin(add,opASSIGN);
1068 SETi( left + right );
1075 dSP; dATARGET; tryAMAGICbin(subtr,opASSIGN);
1078 SETi( left - right );
1085 dSP; tryAMAGICbinSET(lt,0);
1088 SETs((left < right) ? &sv_yes : &sv_no);
1095 dSP; tryAMAGICbinSET(gt,0);
1098 SETs((left > right) ? &sv_yes : &sv_no);
1105 dSP; tryAMAGICbinSET(le,0);
1108 SETs((left <= right) ? &sv_yes : &sv_no);
1115 dSP; tryAMAGICbinSET(ge,0);
1118 SETs((left >= right) ? &sv_yes : &sv_no);
1125 dSP; tryAMAGICbinSET(eq,0);
1128 SETs((left == right) ? &sv_yes : &sv_no);
1135 dSP; tryAMAGICbinSET(ne,0);
1138 SETs((left != right) ? &sv_yes : &sv_no);
1145 dSP; dTARGET; tryAMAGICbin(ncmp,0);
1152 else if (left < right)
1163 dSP; dTARGET; tryAMAGICun(neg);
1168 /* High falutin' math. */
1172 dSP; dTARGET; tryAMAGICbin(atan2,0);
1175 SETn(atan2(left, right));
1182 dSP; dTARGET; tryAMAGICun(sin);
1194 dSP; dTARGET; tryAMAGICun(cos);
1215 value = rand() * value / 2147483648.0;
1218 value = rand() * value / 65536.0;
1221 value = rand() * value / 32768.0;
1223 value = rand() * value / (double)(((unsigned long)1) << RANDBITS);
1250 dSP; dTARGET; tryAMAGICun(exp);
1262 dSP; dTARGET; tryAMAGICun(log);
1267 DIE("Can't take log of %g", value);
1276 dSP; dTARGET; tryAMAGICun(sqrt);
1281 DIE("Can't take sqrt of %g", value);
1282 value = sqrt(value);
1294 (void)modf(value, &value);
1296 (void)modf(-value, &value);
1305 dSP; dTARGET; tryAMAGICun(abs);
1322 unsigned long value;
1326 value = scan_hex(tmps, 99, &argtype);
1337 unsigned long value;
1342 while (*tmps && isSPACE(*tmps))
1347 value = scan_hex(++tmps, 99, &argtype);
1349 value = scan_oct(tmps, 99, &argtype);
1362 SETi( sv_len(TOPs) );
1374 I32 lvalue = op->op_flags & OPf_MOD;
1376 I32 arybase = curcop->cop_arybase;
1380 pos = POPi - arybase;
1382 tmps = SvPV(sv, curlen);
1384 pos += curlen + arybase;
1385 if (pos < 0 || pos > curlen) {
1386 if (dowarn || lvalue)
1387 warn("substr outside of string");
1394 len += curlen - pos;
1399 rem = curlen - pos; /* rem=how many bytes left*/
1402 sv_setpvn(TARG, tmps, rem);
1403 if (lvalue) { /* it's an lvalue! */
1404 if (!SvGMAGICAL(sv))
1405 (void)SvPOK_only(sv);
1406 if (SvTYPE(TARG) < SVt_PVLV) {
1407 sv_upgrade(TARG, SVt_PVLV);
1408 sv_magic(TARG, Nullsv, 'x', Nullch, 0);
1413 LvTARGOFF(TARG) = pos;
1414 LvTARGLEN(TARG) = rem;
1417 PUSHs(TARG); /* avoid SvSETMAGIC here */
1424 register I32 size = POPi;
1425 register I32 offset = POPi;
1426 register SV *src = POPs;
1427 I32 lvalue = op->op_flags & OPf_MOD;
1429 unsigned char *s = (unsigned char*)SvPV(src, srclen);
1430 unsigned long retnum;
1433 offset *= size; /* turn into bit offset */
1434 len = (offset + size + 7) / 8;
1435 if (offset < 0 || size < 1)
1438 if (lvalue) { /* it's an lvalue! */
1439 if (SvTYPE(TARG) < SVt_PVLV) {
1440 sv_upgrade(TARG, SVt_PVLV);
1441 sv_magic(TARG, Nullsv, 'v', Nullch, 0);
1446 LvTARGOFF(TARG) = offset;
1447 LvTARGLEN(TARG) = size;
1455 if (offset >= srclen)
1458 retnum = (unsigned long) s[offset] << 8;
1460 else if (size == 32) {
1461 if (offset >= srclen)
1463 else if (offset + 1 >= srclen)
1464 retnum = (unsigned long) s[offset] << 24;
1465 else if (offset + 2 >= srclen)
1466 retnum = ((unsigned long) s[offset] << 24) +
1467 ((unsigned long) s[offset + 1] << 16);
1469 retnum = ((unsigned long) s[offset] << 24) +
1470 ((unsigned long) s[offset + 1] << 16) +
1471 (s[offset + 2] << 8);
1476 retnum = (s[offset >> 3] >> (offset & 7)) & ((1 << size) - 1);
1481 else if (size == 16)
1482 retnum = ((unsigned long) s[offset] << 8) + s[offset+1];
1483 else if (size == 32)
1484 retnum = ((unsigned long) s[offset] << 24) +
1485 ((unsigned long) s[offset + 1] << 16) +
1486 (s[offset + 2] << 8) + s[offset+3];
1490 sv_setiv(TARG, (I32)retnum);
1505 I32 arybase = curcop->cop_arybase;
1510 offset = POPi - arybase;
1513 tmps = SvPV(big, biglen);
1516 else if (offset > biglen)
1518 if (!(tmps2 = fbm_instr((unsigned char*)tmps + offset,
1519 (unsigned char*)tmps + biglen, little)))
1520 retval = -1 + arybase;
1522 retval = tmps2 - tmps + arybase;
1539 I32 arybase = curcop->cop_arybase;
1545 tmps2 = SvPV(little, llen);
1546 tmps = SvPV(big, blen);
1550 offset = SvIV(offstr) - arybase + llen;
1553 else if (offset > blen)
1555 if (!(tmps2 = rninstr(tmps, tmps + offset,
1556 tmps2, tmps2 + llen)))
1557 retval = -1 + arybase;
1559 retval = tmps2 - tmps + arybase;
1566 dSP; dMARK; dORIGMARK; dTARGET;
1567 do_sprintf(TARG, SP-MARK, MARK+1);
1581 value = (I32) (*tmps & 255);
1586 value = (I32) (anum & 255);
1597 (void)SvUPGRADE(TARG,SVt_PV);
1603 (void)SvPOK_only(TARG);
1610 dSP; dTARGET; dPOPTOPssrl;
1612 char *tmps = SvPV(left, na);
1614 sv_setpv(TARG, fcrypt(tmps, SvPV(right, na)));
1616 sv_setpv(TARG, crypt(tmps, SvPV(right, na)));
1620 "The crypt() function is unimplemented due to excessive paranoia.");
1632 if (!SvPADTMP(sv)) {
1638 s = SvPV_force(sv, na);
1651 if (!SvPADTMP(sv)) {
1657 s = SvPV_force(sv, na);
1670 register char *send;
1673 if (!SvPADTMP(sv)) {
1679 s = SvPV_force(sv, len);
1694 register char *send;
1697 if (!SvPADTMP(sv)) {
1703 s = SvPV_force(sv, len);
1718 register char *s = SvPV(sv,len);
1722 (void)SvUPGRADE(TARG, SVt_PV);
1723 SvGROW(TARG, (len * 2) + 1);
1731 SvCUR_set(TARG, d - SvPVX(TARG));
1732 (void)SvPOK_only(TARG);
1735 sv_setpvn(TARG, s, len);
1744 dSP; dMARK; dORIGMARK;
1746 register AV* av = (AV*)POPs;
1747 register I32 lval = op->op_flags & OPf_MOD;
1748 I32 arybase = curcop->cop_arybase;
1751 if (SvTYPE(av) == SVt_PVAV) {
1752 if (lval && op->op_private & OPpLVAL_INTRO) {
1754 for (svp = mark + 1; svp <= sp; svp++) {
1759 if (max > AvMAX(av))
1762 while (++MARK <= SP) {
1763 elem = SvIVx(*MARK);
1767 svp = av_fetch(av, elem, lval);
1769 if (!svp || *svp == &sv_undef)
1770 DIE(no_aelem, elem);
1771 if (op->op_private & OPpLVAL_INTRO)
1774 *MARK = svp ? *svp : &sv_undef;
1777 if (GIMME != G_ARRAY) {
1785 /* Associative arrays. */
1790 HV *hash = (HV*)POPs;
1796 entry = hv_iternext(hash); /* might clobber stack_sp */
1801 tmps = hv_iterkey(entry, &i); /* won't clobber stack_sp */
1804 PUSHs(sv_2mortal(newSVpv(tmps, i)));
1805 if (GIMME == G_ARRAY) {
1807 sv_setsv(TARG, hv_iterval(hash, entry)); /* might clobber stack_sp */
1812 else if (GIMME == G_SCALAR)
1836 if (SvTYPE(hv) != SVt_PVHV) {
1837 DIE("Not a HASH reference");
1839 tmps = SvPV(tmpsv, len);
1840 sv = hv_delete(hv, tmps, len,
1841 op->op_private & OPpLEAVE_VOID ? G_DISCARD : 0);
1855 if (SvTYPE(hv) != SVt_PVHV) {
1856 DIE("Not a HASH reference");
1858 tmps = SvPV(tmpsv, len);
1859 if (hv_exists(hv, tmps, len))
1866 dSP; dMARK; dORIGMARK;
1868 register HV *hv = (HV*)POPs;
1869 register I32 lval = op->op_flags & OPf_MOD;
1871 if (SvTYPE(hv) == SVt_PVHV) {
1872 while (++MARK <= SP) {
1874 char *key = SvPV(*MARK, keylen);
1876 svp = hv_fetch(hv, key, keylen, lval);
1878 if (!svp || *svp == &sv_undef)
1880 if (op->op_private & OPpLVAL_INTRO)
1883 *MARK = svp ? *svp : &sv_undef;
1886 if (GIMME != G_ARRAY) {
1894 /* List operators. */
1899 if (GIMME != G_ARRAY) {
1901 *MARK = *SP; /* unwanted list, return last item */
1912 SV **lastrelem = stack_sp;
1913 SV **lastlelem = stack_base + POPMARK;
1914 SV **firstlelem = stack_base + POPMARK + 1;
1915 register SV **firstrelem = lastlelem + 1;
1916 I32 arybase = curcop->cop_arybase;
1917 I32 lval = op->op_flags & OPf_MOD;
1918 I32 is_something_there = lval;
1920 register I32 max = lastrelem - lastlelem;
1921 register SV **lelem;
1924 if (GIMME != G_ARRAY) {
1925 ix = SvIVx(*lastlelem);
1930 if (ix < 0 || ix >= max)
1931 *firstlelem = &sv_undef;
1933 *firstlelem = firstrelem[ix];
1939 SP = firstlelem - 1;
1943 for (lelem = firstlelem; lelem <= lastlelem; lelem++) {
1949 else if (!(*lelem = firstrelem[ix]))
1954 if (ix >= max || !(*lelem = firstrelem[ix]))
1957 if (!is_something_there && (SvOKp(*lelem) || SvGMAGICAL(*lelem)))
1958 is_something_there = TRUE;
1960 if (is_something_there)
1963 SP = firstlelem - 1;
1970 I32 items = SP - MARK;
1972 XPUSHs((SV*)sv_2mortal((SV*)av_make(items, MARK+1)));
1978 dSP; dMARK; dORIGMARK;
1980 HV* hv = (HV*)sv_2mortal((SV*)newHV());
1985 SV *val = NEWSV(46, 0);
1987 sv_setsv(val, *++MARK);
1989 warn("Odd number of elements in hash list");
1990 tmps = SvPV(key,len);
1991 (void)hv_store(hv,tmps,len,val,0);
2000 dSP; dMARK; dORIGMARK;
2001 register AV *ary = (AV*)*++MARK;
2005 register I32 offset;
2006 register I32 length;
2015 offset = SvIVx(*MARK);
2017 offset += AvFILL(ary) + 1;
2019 offset -= curcop->cop_arybase;
2021 length = SvIVx(*MARK++);
2026 length = AvMAX(ary) + 1; /* close enough to infinity */
2030 length = AvMAX(ary) + 1;
2038 if (offset > AvFILL(ary) + 1)
2039 offset = AvFILL(ary) + 1;
2040 after = AvFILL(ary) + 1 - (offset + length);
2041 if (after < 0) { /* not that much array */
2042 length += after; /* offset+length now in array */
2048 /* At this point, MARK .. SP-1 is our new LIST */
2051 diff = newlen - length;
2053 if (diff < 0) { /* shrinking the area */
2055 New(451, tmparyval, newlen, SV*); /* so remember insertion */
2056 Copy(MARK, tmparyval, newlen, SV*);
2059 MARK = ORIGMARK + 1;
2060 if (GIMME == G_ARRAY) { /* copy return vals to stack */
2061 MEXTEND(MARK, length);
2062 Copy(AvARRAY(ary)+offset, MARK, length, SV*);
2064 for (i = length, dst = MARK; i; i--)
2065 sv_2mortal(*dst++); /* free them eventualy */
2070 *MARK = AvARRAY(ary)[offset+length-1];
2073 for (i = length - 1, dst = &AvARRAY(ary)[offset]; i > 0; i--)
2074 SvREFCNT_dec(*dst++); /* free them now */
2077 AvFILL(ary) += diff;
2079 /* pull up or down? */
2081 if (offset < after) { /* easier to pull up */
2082 if (offset) { /* esp. if nothing to pull */
2083 src = &AvARRAY(ary)[offset-1];
2084 dst = src - diff; /* diff is negative */
2085 for (i = offset; i > 0; i--) /* can't trust Copy */
2089 SvPVX(ary) = (char*)(AvARRAY(ary) - diff); /* diff is negative */
2093 if (after) { /* anything to pull down? */
2094 src = AvARRAY(ary) + offset + length;
2095 dst = src + diff; /* diff is negative */
2096 Move(src, dst, after, SV*);
2098 dst = &AvARRAY(ary)[AvFILL(ary)+1];
2099 /* avoid later double free */
2103 dst[--i] = &sv_undef;
2106 for (src = tmparyval, dst = AvARRAY(ary) + offset;
2108 *dst = NEWSV(46, 0);
2109 sv_setsv(*dst++, *src++);
2111 Safefree(tmparyval);
2114 else { /* no, expanding (or same) */
2116 New(452, tmparyval, length, SV*); /* so remember deletion */
2117 Copy(AvARRAY(ary)+offset, tmparyval, length, SV*);
2120 if (diff > 0) { /* expanding */
2122 /* push up or down? */
2124 if (offset < after && diff <= AvARRAY(ary) - AvALLOC(ary)) {
2128 Move(src, dst, offset, SV*);
2130 SvPVX(ary) = (char*)(AvARRAY(ary) - diff);/* diff is positive */
2132 AvFILL(ary) += diff;
2135 if (AvFILL(ary) + diff >= AvMAX(ary)) /* oh, well */
2136 av_extend(ary, AvFILL(ary) + diff);
2137 AvFILL(ary) += diff;
2140 dst = AvARRAY(ary) + AvFILL(ary);
2142 for (i = after; i; i--) {
2149 for (src = MARK, dst = AvARRAY(ary) + offset; newlen; newlen--) {
2150 *dst = NEWSV(46, 0);
2151 sv_setsv(*dst++, *src++);
2153 MARK = ORIGMARK + 1;
2154 if (GIMME == G_ARRAY) { /* copy return vals to stack */
2156 Copy(tmparyval, MARK, length, SV*);
2158 for (i = length, dst = MARK; i; i--)
2159 sv_2mortal(*dst++); /* free them eventualy */
2161 Safefree(tmparyval);
2165 else if (length--) {
2166 *MARK = tmparyval[length];
2169 while (length-- > 0)
2170 SvREFCNT_dec(tmparyval[length]);
2172 Safefree(tmparyval);
2183 dSP; dMARK; dORIGMARK; dTARGET;
2184 register AV *ary = (AV*)*++MARK;
2185 register SV *sv = &sv_undef;
2187 for (++MARK; MARK <= SP; MARK++) {
2190 sv_setsv(sv, *MARK);
2194 PUSHi( AvFILL(ary) + 1 );
2202 SV *sv = av_pop(av);
2203 if (sv != &sv_undef && AvREAL(av))
2204 (void)sv_2mortal(sv);
2213 SV *sv = av_shift(av);
2217 if (sv != &sv_undef && AvREAL(av))
2218 (void)sv_2mortal(sv);
2225 dSP; dMARK; dORIGMARK; dTARGET;
2226 register AV *ary = (AV*)*++MARK;
2230 av_unshift(ary, SP - MARK);
2233 sv_setsv(sv, *++MARK);
2234 (void)av_store(ary, i++, sv);
2238 PUSHi( AvFILL(ary) + 1 );
2248 if (GIMME == G_ARRAY) {
2259 register char *down;
2265 do_join(TARG, &sv_no, MARK, SP);
2267 sv_setsv(TARG, *SP);
2268 up = SvPV_force(TARG, len);
2270 down = SvPVX(TARG) + len - 1;
2276 (void)SvPOK_only(TARG);
2284 /* Explosives and implosives. */
2293 register char *pat = SvPV(left, llen);
2294 register char *s = SvPV(right, rlen);
2295 char *strend = s + rlen;
2297 register char *patend = pat + llen;
2302 /* These must not be in registers: */
2313 unsigned Quad_t auquad;
2319 register U32 culong;
2321 static char* bitcount = 0;
2323 if (GIMME != G_ARRAY) { /* arrange to do first one only */
2325 for (patend = pat; !isALPHA(*patend) || *patend == 'x'; patend++) ;
2326 if (strchr("aAbBhHP", *patend) || *pat == '%') {
2328 while (isDIGIT(*patend) || *patend == '*')
2334 while (pat < patend) {
2339 else if (*pat == '*') {
2340 len = strend - strbeg; /* long enough */
2343 else if (isDIGIT(*pat)) {
2345 while (isDIGIT(*pat))
2346 len = (len * 10) + (*pat++ - '0');
2349 len = (datumtype != '@');
2354 if (len == 1 && pat[-1] != '1')
2363 if (len > strend - strbeg)
2364 DIE("@ outside of string");
2368 if (len > s - strbeg)
2369 DIE("X outside of string");
2373 if (len > strend - s)
2374 DIE("x outside of string");
2379 if (len > strend - s)
2382 goto uchar_checksum;
2383 sv = NEWSV(35, len);
2384 sv_setpvn(sv, s, len);
2386 if (datumtype == 'A') {
2387 aptr = s; /* borrow register */
2388 s = SvPVX(sv) + len - 1;
2389 while (s >= SvPVX(sv) && (!*s || isSPACE(*s)))
2392 SvCUR_set(sv, s - SvPVX(sv));
2393 s = aptr; /* unborrow register */
2395 XPUSHs(sv_2mortal(sv));
2399 if (pat[-1] == '*' || len > (strend - s) * 8)
2400 len = (strend - s) * 8;
2403 Newz(601, bitcount, 256, char);
2404 for (bits = 1; bits < 256; bits++) {
2405 if (bits & 1) bitcount[bits]++;
2406 if (bits & 2) bitcount[bits]++;
2407 if (bits & 4) bitcount[bits]++;
2408 if (bits & 8) bitcount[bits]++;
2409 if (bits & 16) bitcount[bits]++;
2410 if (bits & 32) bitcount[bits]++;
2411 if (bits & 64) bitcount[bits]++;
2412 if (bits & 128) bitcount[bits]++;
2416 culong += bitcount[*(unsigned char*)s++];
2421 if (datumtype == 'b') {
2423 if (bits & 1) culong++;
2429 if (bits & 128) culong++;
2436 sv = NEWSV(35, len + 1);
2439 aptr = pat; /* borrow register */
2441 if (datumtype == 'b') {
2443 for (len = 0; len < aint; len++) {
2444 if (len & 7) /*SUPPRESS 595*/
2448 *pat++ = '0' + (bits & 1);
2453 for (len = 0; len < aint; len++) {
2458 *pat++ = '0' + ((bits & 128) != 0);
2462 pat = aptr; /* unborrow register */
2463 XPUSHs(sv_2mortal(sv));
2467 if (pat[-1] == '*' || len > (strend - s) * 2)
2468 len = (strend - s) * 2;
2469 sv = NEWSV(35, len + 1);
2472 aptr = pat; /* borrow register */
2474 if (datumtype == 'h') {
2476 for (len = 0; len < aint; len++) {
2481 *pat++ = hexdigit[bits & 15];
2486 for (len = 0; len < aint; len++) {
2491 *pat++ = hexdigit[(bits >> 4) & 15];
2495 pat = aptr; /* unborrow register */
2496 XPUSHs(sv_2mortal(sv));
2499 if (len > strend - s)
2504 if (aint >= 128) /* fake up signed chars */
2513 if (aint >= 128) /* fake up signed chars */
2516 sv_setiv(sv, (I32)aint);
2517 PUSHs(sv_2mortal(sv));
2522 if (len > strend - s)
2536 sv_setiv(sv, (I32)auint);
2537 PUSHs(sv_2mortal(sv));
2542 along = (strend - s) / sizeof(I16);
2547 Copy(s, &ashort, 1, I16);
2555 Copy(s, &ashort, 1, I16);
2558 sv_setiv(sv, (I32)ashort);
2559 PUSHs(sv_2mortal(sv));
2566 along = (strend - s) / sizeof(U16);
2571 Copy(s, &aushort, 1, U16);
2574 if (datumtype == 'n')
2575 aushort = ntohs(aushort);
2578 if (datumtype == 'v')
2579 aushort = vtohs(aushort);
2587 Copy(s, &aushort, 1, U16);
2591 if (datumtype == 'n')
2592 aushort = ntohs(aushort);
2595 if (datumtype == 'v')
2596 aushort = vtohs(aushort);
2598 sv_setiv(sv, (I32)aushort);
2599 PUSHs(sv_2mortal(sv));
2604 along = (strend - s) / sizeof(int);
2609 Copy(s, &aint, 1, int);
2612 cdouble += (double)aint;
2620 Copy(s, &aint, 1, int);
2623 sv_setiv(sv, (I32)aint);
2624 PUSHs(sv_2mortal(sv));
2629 along = (strend - s) / sizeof(unsigned int);
2634 Copy(s, &auint, 1, unsigned int);
2635 s += sizeof(unsigned int);
2637 cdouble += (double)auint;
2645 Copy(s, &auint, 1, unsigned int);
2646 s += sizeof(unsigned int);
2648 sv_setiv(sv, (I32)auint);
2649 PUSHs(sv_2mortal(sv));
2654 along = (strend - s) / sizeof(I32);
2659 Copy(s, &along, 1, I32);
2662 cdouble += (double)along;
2670 Copy(s, &along, 1, I32);
2673 sv_setiv(sv, (I32)along);
2674 PUSHs(sv_2mortal(sv));
2681 along = (strend - s) / sizeof(U32);
2686 Copy(s, &aulong, 1, U32);
2689 if (datumtype == 'N')
2690 aulong = ntohl(aulong);
2693 if (datumtype == 'V')
2694 aulong = vtohl(aulong);
2697 cdouble += (double)aulong;
2705 Copy(s, &aulong, 1, U32);
2709 if (datumtype == 'N')
2710 aulong = ntohl(aulong);
2713 if (datumtype == 'V')
2714 aulong = vtohl(aulong);
2716 sv_setnv(sv, (double)aulong);
2717 PUSHs(sv_2mortal(sv));
2722 along = (strend - s) / sizeof(char*);
2727 if (sizeof(char*) > strend - s)
2730 Copy(s, &aptr, 1, char*);
2736 PUSHs(sv_2mortal(sv));
2741 if (sizeof(char*) > strend - s)
2744 Copy(s, &aptr, 1, char*);
2749 sv_setpvn(sv, aptr, len);
2750 PUSHs(sv_2mortal(sv));
2756 if (s + sizeof(Quad_t) > strend)
2759 Copy(s, &aquad, 1, Quad_t);
2760 s += sizeof(Quad_t);
2763 sv_setiv(sv, (IV)aquad);
2764 PUSHs(sv_2mortal(sv));
2770 if (s + sizeof(unsigned Quad_t) > strend)
2773 Copy(s, &auquad, 1, unsigned Quad_t);
2774 s += sizeof(unsigned Quad_t);
2777 sv_setiv(sv, (IV)auquad);
2778 PUSHs(sv_2mortal(sv));
2782 /* float and double added gnb@melba.bby.oz.au 22/11/89 */
2785 along = (strend - s) / sizeof(float);
2790 Copy(s, &afloat, 1, float);
2798 Copy(s, &afloat, 1, float);
2801 sv_setnv(sv, (double)afloat);
2802 PUSHs(sv_2mortal(sv));
2808 along = (strend - s) / sizeof(double);
2813 Copy(s, &adouble, 1, double);
2814 s += sizeof(double);
2821 Copy(s, &adouble, 1, double);
2822 s += sizeof(double);
2824 sv_setnv(sv, (double)adouble);
2825 PUSHs(sv_2mortal(sv));
2830 along = (strend - s) * 3 / 4;
2831 sv = NEWSV(42, along);
2832 while (s < strend && *s > ' ' && *s < 'a') {
2837 len = (*s++ - ' ') & 077;
2839 if (s < strend && *s >= ' ')
2840 a = (*s++ - ' ') & 077;
2843 if (s < strend && *s >= ' ')
2844 b = (*s++ - ' ') & 077;
2847 if (s < strend && *s >= ' ')
2848 c = (*s++ - ' ') & 077;
2851 if (s < strend && *s >= ' ')
2852 d = (*s++ - ' ') & 077;
2855 hunk[0] = a << 2 | b >> 4;
2856 hunk[1] = b << 4 | c >> 2;
2857 hunk[2] = c << 6 | d;
2858 sv_catpvn(sv, hunk, len > 3 ? 3 : len);
2863 else if (s[1] == '\n') /* possible checksum byte */
2866 XPUSHs(sv_2mortal(sv));
2871 if (strchr("fFdD", datumtype) ||
2872 (checksum > 32 && strchr("iIlLN", datumtype)) ) {
2876 while (checksum >= 16) {
2880 while (checksum >= 4) {
2886 along = (1 << checksum) - 1;
2887 while (cdouble < 0.0)
2889 cdouble = modf(cdouble / adouble, &trouble) * adouble;
2890 sv_setnv(sv, cdouble);
2893 if (checksum < 32) {
2894 along = (1 << checksum) - 1;
2895 culong &= (U32)along;
2897 sv_setnv(sv, (double)culong);
2899 XPUSHs(sv_2mortal(sv));
2907 doencodes(sv, s, len)
2915 sv_catpvn(sv, hunk, 1);
2918 hunk[0] = ' ' + (077 & (*s >> 2));
2919 hunk[1] = ' ' + (077 & ((*s << 4) & 060 | (s[1] >> 4) & 017));
2920 hunk[2] = ' ' + (077 & ((s[1] << 2) & 074 | (s[2] >> 6) & 03));
2921 hunk[3] = ' ' + (077 & (s[2] & 077));
2922 sv_catpvn(sv, hunk, 4);
2926 for (s = SvPVX(sv); *s; s++) {
2930 sv_catpvn(sv, "\n", 1);
2935 dSP; dMARK; dORIGMARK; dTARGET;
2936 register SV *cat = TARG;
2939 register char *pat = SvPVx(*++MARK, fromlen);
2940 register char *patend = pat + fromlen;
2945 static char null10[] = {0,0,0,0,0,0,0,0,0,0};
2946 static char *space10 = " ";
2948 /* These must not be in registers: */
2957 unsigned Quad_t auquad;
2965 sv_setpvn(cat, "", 0);
2966 while (pat < patend) {
2967 #define NEXTFROM (items-- > 0 ? *MARK++ : &sv_no)
2970 len = strchr("@Xxu", datumtype) ? 0 : items;
2973 else if (isDIGIT(*pat)) {
2975 while (isDIGIT(*pat))
2976 len = (len * 10) + (*pat++ - '0');
2984 DIE("%% may only be used in unpack");
2995 if (SvCUR(cat) < len)
2996 DIE("X outside of string");
3003 sv_catpvn(cat, null10, 10);
3006 sv_catpvn(cat, null10, len);
3011 aptr = SvPV(fromstr, fromlen);
3015 sv_catpvn(cat, aptr, len);
3017 sv_catpvn(cat, aptr, fromlen);
3019 if (datumtype == 'A') {
3021 sv_catpvn(cat, space10, 10);
3024 sv_catpvn(cat, space10, len);
3028 sv_catpvn(cat, null10, 10);
3031 sv_catpvn(cat, null10, len);
3038 char *savepat = pat;
3043 aptr = SvPV(fromstr, fromlen);
3048 SvCUR(cat) += (len+7)/8;
3049 SvGROW(cat, SvCUR(cat) + 1);
3050 aptr = SvPVX(cat) + aint;
3055 if (datumtype == 'B') {
3056 for (len = 0; len++ < aint;) {
3057 items |= *pat++ & 1;
3061 *aptr++ = items & 0xff;
3067 for (len = 0; len++ < aint;) {
3073 *aptr++ = items & 0xff;
3079 if (datumtype == 'B')
3080 items <<= 7 - (aint & 7);
3082 items >>= 7 - (aint & 7);
3083 *aptr++ = items & 0xff;
3085 pat = SvPVX(cat) + SvCUR(cat);
3096 char *savepat = pat;
3101 aptr = SvPV(fromstr, fromlen);
3106 SvCUR(cat) += (len+1)/2;
3107 SvGROW(cat, SvCUR(cat) + 1);
3108 aptr = SvPVX(cat) + aint;
3113 if (datumtype == 'H') {
3114 for (len = 0; len++ < aint;) {
3116 items |= ((*pat++ & 15) + 9) & 15;
3118 items |= *pat++ & 15;
3122 *aptr++ = items & 0xff;
3128 for (len = 0; len++ < aint;) {
3130 items |= (((*pat++ & 15) + 9) & 15) << 4;
3132 items |= (*pat++ & 15) << 4;
3136 *aptr++ = items & 0xff;
3142 *aptr++ = items & 0xff;
3143 pat = SvPVX(cat) + SvCUR(cat);
3155 aint = SvIV(fromstr);
3157 sv_catpvn(cat, &achar, sizeof(char));
3160 /* Float and double added by gnb@melba.bby.oz.au 22/11/89 */
3165 afloat = (float)SvNV(fromstr);
3166 sv_catpvn(cat, (char *)&afloat, sizeof (float));
3173 adouble = (double)SvNV(fromstr);
3174 sv_catpvn(cat, (char *)&adouble, sizeof (double));
3180 ashort = (I16)SvIV(fromstr);
3182 ashort = htons(ashort);
3184 sv_catpvn(cat, (char*)&ashort, sizeof(I16));
3190 ashort = (I16)SvIV(fromstr);
3192 ashort = htovs(ashort);
3194 sv_catpvn(cat, (char*)&ashort, sizeof(I16));
3201 ashort = (I16)SvIV(fromstr);
3202 sv_catpvn(cat, (char*)&ashort, sizeof(I16));
3208 auint = U_I(SvNV(fromstr));
3209 sv_catpvn(cat, (char*)&auint, sizeof(unsigned int));
3215 aint = SvIV(fromstr);
3216 sv_catpvn(cat, (char*)&aint, sizeof(int));
3222 aulong = U_L(SvNV(fromstr));
3224 aulong = htonl(aulong);
3226 sv_catpvn(cat, (char*)&aulong, sizeof(U32));
3232 aulong = U_L(SvNV(fromstr));
3234 aulong = htovl(aulong);
3236 sv_catpvn(cat, (char*)&aulong, sizeof(U32));
3242 aulong = U_L(SvNV(fromstr));
3243 sv_catpvn(cat, (char*)&aulong, sizeof(U32));
3249 along = SvIV(fromstr);
3250 sv_catpvn(cat, (char*)&along, sizeof(I32));
3257 auquad = (unsigned Quad_t)SvIV(fromstr);
3258 sv_catpvn(cat, (char*)&auquad, sizeof(unsigned Quad_t));
3264 aquad = (Quad_t)SvIV(fromstr);
3265 sv_catpvn(cat, (char*)&aquad, sizeof(Quad_t));
3268 #endif /* HAS_QUAD */
3270 len = 1; /* assume SV is correct length */
3275 aptr = SvPV_force(fromstr, na); /* XXX Error if TEMP? */
3276 sv_catpvn(cat, (char*)&aptr, sizeof(char*));
3281 aptr = SvPV(fromstr, fromlen);
3282 SvGROW(cat, fromlen * 4 / 3);
3287 while (fromlen > 0) {
3294 doencodes(cat, aptr, todo);
3312 register I32 limit = POPi; /* note, negative is forever */
3315 register char *s = SvPV(sv, len);
3316 char *strend = s + len;
3317 register PMOP *pm = (PMOP*)POPs;
3321 I32 maxiters = (strend - s) + 10;
3324 I32 origlimit = limit;
3327 AV *oldstack = stack;
3328 register REGEXP *rx = pm->op_pmregexp;
3330 I32 oldsave = savestack_ix;
3333 DIE("panic: do_split");
3334 if (pm->op_pmreplroot)
3335 ary = GvAVn((GV*)pm->op_pmreplroot);
3336 else if (gimme != G_ARRAY)
3340 if (ary && (gimme != G_ARRAY || (pm->op_pmflags & PMf_ONCE))) {
3344 for (i = AvFILL(ary); i >= 0; i--)
3345 AvARRAY(ary)[i] = &sv_undef; /* don't free mere refs */
3349 /* temporarily switch stacks */
3350 SWITCHSTACK(stack, ary);
3352 base = SP - stack_base;
3354 if (pm->op_pmflags & PMf_SKIPWHITE) {
3358 if (pm->op_pmflags & (PMf_MULTILINE|PMf_SINGLELINE)) {
3360 multiline = pm->op_pmflags & PMf_MULTILINE;
3364 limit = maxiters + 2;
3365 if (pm->op_pmflags & PMf_WHITE) {
3368 for (m = s; m < strend && !isSPACE(*m); m++) ;
3371 dstr = NEWSV(30, m-s);
3372 sv_setpvn(dstr, s, m-s);
3377 for (s = m + 1; s < strend && isSPACE(*s); s++) ;
3380 else if (strEQ("^", rx->precomp)) {
3383 for (m = s; m < strend && *m != '\n'; m++) ;
3387 dstr = NEWSV(30, m-s);
3388 sv_setpvn(dstr, s, m-s);
3395 else if (pm->op_pmshort) {
3396 i = SvCUR(pm->op_pmshort);
3398 I32 fold = (pm->op_pmflags & PMf_FOLD);
3399 i = *SvPVX(pm->op_pmshort);
3400 if (fold && isUPPER(i))
3405 m < strend && *m != i &&
3406 (!isUPPER(*m) || toLOWER(*m) != i);
3407 m++) /*SUPPRESS 530*/
3410 else /*SUPPRESS 530*/
3411 for (m = s; m < strend && *m != i; m++) ;
3414 dstr = NEWSV(30, m-s);
3415 sv_setpvn(dstr, s, m-s);
3424 while (s < strend && --limit &&
3425 (m=fbm_instr((unsigned char*)s, (unsigned char*)strend,
3429 dstr = NEWSV(31, m-s);
3430 sv_setpvn(dstr, s, m-s);
3439 maxiters += (strend - s) * rx->nparens;
3440 while (s < strend && --limit &&
3441 pregexec(rx, s, strend, orig, 1, Nullsv, TRUE) ) {
3443 && rx->subbase != orig) {
3448 strend = s + (strend - m);
3451 dstr = NEWSV(32, m-s);
3452 sv_setpvn(dstr, s, m-s);
3457 for (i = 1; i <= rx->nparens; i++) {
3461 dstr = NEWSV(33, m-s);
3462 sv_setpvn(dstr, s, m-s);
3465 dstr = NEWSV(33, 0);
3474 LEAVE_SCOPE(oldsave);
3475 iters = (SP - stack_base) - base;
3476 if (iters > maxiters)
3479 /* keep field after final delim? */
3480 if (s < strend || (iters && origlimit)) {
3481 dstr = NEWSV(34, strend-s);
3482 sv_setpvn(dstr, s, strend-s);
3488 else if (!origlimit) {
3489 while (iters > 0 && SvCUR(TOPs) == 0)
3493 SWITCHSTACK(ary, oldstack);
3494 if (gimme == G_ARRAY) {
3496 Copy(AvARRAY(ary), SP + 1, iters, SV*);
3502 if (gimme == G_ARRAY)
3505 if (iters || !pm->op_pmreplroot) {