3 * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 * 2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
12 * "It's a big house this, and very peculiar. Always a bit more to discover,
13 * and no knowing what you'll find around a corner. And Elves, sir!" --Samwise
16 /* This file contains general pp ("push/pop") functions that execute the
17 * opcodes that make up a perl program. A typical pp function expects to
18 * find its arguments on the stack, and usually pushes its results onto
19 * the stack, hence the 'pp' terminology. Each OP structure contains
20 * a pointer to the relevant pp_foo() function.
30 /* XXX I can't imagine anyone who doesn't have this actually _needs_
31 it, since pid_t is an integral type.
34 #ifdef NEED_GETPID_PROTO
35 extern Pid_t getpid (void);
39 * Some BSDs and Cygwin default to POSIX math instead of IEEE.
40 * This switches them over to IEEE.
42 #if defined(LIBM_LIB_VERSION)
43 _LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;
46 /* variations on pp_null */
51 if (GIMME_V == G_SCALAR)
67 if (PL_op->op_private & OPpLVAL_INTRO)
68 SAVECLEARSV(PAD_SVl(PL_op->op_targ));
70 if (PL_op->op_flags & OPf_REF) {
74 if (GIMME == G_SCALAR)
75 Perl_croak(aTHX_ "Can't return array to lvalue scalar context");
80 if (gimme == G_ARRAY) {
81 const I32 maxarg = AvFILL((AV*)TARG) + 1;
83 if (SvMAGICAL(TARG)) {
85 for (i=0; i < (U32)maxarg; i++) {
86 SV ** const svp = av_fetch((AV*)TARG, i, FALSE);
87 SP[i+1] = (svp) ? *svp : &PL_sv_undef;
91 Copy(AvARRAY((AV*)TARG), SP+1, maxarg, SV*);
95 else if (gimme == G_SCALAR) {
96 SV* const sv = sv_newmortal();
97 const I32 maxarg = AvFILL((AV*)TARG) + 1;
110 if (PL_op->op_private & OPpLVAL_INTRO)
111 SAVECLEARSV(PAD_SVl(PL_op->op_targ));
112 if (PL_op->op_flags & OPf_REF)
115 if (GIMME == G_SCALAR)
116 Perl_croak(aTHX_ "Can't return hash to lvalue scalar context");
120 if (gimme == G_ARRAY) {
123 else if (gimme == G_SCALAR) {
124 SV* const sv = Perl_hv_scalar(aTHX_ (HV*)TARG);
132 DIE(aTHX_ "NOT IMPL LINE %d",__LINE__);
143 tryAMAGICunDEREF(to_gv);
146 if (SvTYPE(sv) == SVt_PVIO) {
147 GV * const gv = (GV*) sv_newmortal();
148 gv_init(gv, 0, "", 0, 0);
149 GvIOp(gv) = (IO *)sv;
150 (void)SvREFCNT_inc(sv);
153 else if (SvTYPE(sv) != SVt_PVGV)
154 DIE(aTHX_ "Not a GLOB reference");
157 if (SvTYPE(sv) != SVt_PVGV) {
158 if (SvGMAGICAL(sv)) {
163 if (!SvOK(sv) && sv != &PL_sv_undef) {
164 /* If this is a 'my' scalar and flag is set then vivify
168 Perl_croak(aTHX_ PL_no_modify);
169 if (PL_op->op_private & OPpDEREF) {
171 if (cUNOP->op_targ) {
173 SV *namesv = PAD_SV(cUNOP->op_targ);
174 const char *name = SvPV(namesv, len);
175 gv = (GV*)NEWSV(0,0);
176 gv_init(gv, CopSTASH(PL_curcop), name, len, 0);
179 const char *name = CopSTASHPV(PL_curcop);
182 if (SvTYPE(sv) < SVt_RV)
183 sv_upgrade(sv, SVt_RV);
184 if (SvPVX_const(sv)) {
189 SvRV_set(sv, (SV*)gv);
194 if (PL_op->op_flags & OPf_REF ||
195 PL_op->op_private & HINT_STRICT_REFS)
196 DIE(aTHX_ PL_no_usym, "a symbol");
197 if (ckWARN(WARN_UNINITIALIZED))
201 if ((PL_op->op_flags & OPf_SPECIAL) &&
202 !(PL_op->op_flags & OPf_MOD))
204 SV * const temp = (SV*)gv_fetchsv(sv, FALSE, SVt_PVGV);
206 && (!is_gv_magical_sv(sv,0)
207 || !(sv = (SV*)gv_fetchsv(sv, TRUE, SVt_PVGV)))) {
213 if (PL_op->op_private & HINT_STRICT_REFS)
214 DIE(aTHX_ PL_no_symref_sv, sv, "a symbol");
215 sv = (SV*)gv_fetchsv(sv, TRUE, SVt_PVGV);
219 if (PL_op->op_private & OPpLVAL_INTRO)
220 save_gp((GV*)sv, !(PL_op->op_flags & OPf_SPECIAL));
232 tryAMAGICunDEREF(to_sv);
235 switch (SvTYPE(sv)) {
239 DIE(aTHX_ "Not a SCALAR reference");
245 if (SvTYPE(gv) != SVt_PVGV) {
246 if (SvGMAGICAL(sv)) {
252 if (PL_op->op_flags & OPf_REF ||
253 PL_op->op_private & HINT_STRICT_REFS)
254 DIE(aTHX_ PL_no_usym, "a SCALAR");
255 if (ckWARN(WARN_UNINITIALIZED))
259 if ((PL_op->op_flags & OPf_SPECIAL) &&
260 !(PL_op->op_flags & OPf_MOD))
262 gv = (GV*)gv_fetchsv(sv, FALSE, SVt_PV);
264 && (!is_gv_magical_sv(sv, 0)
265 || !(gv = (GV*)gv_fetchsv(sv, TRUE, SVt_PV))))
271 if (PL_op->op_private & HINT_STRICT_REFS)
272 DIE(aTHX_ PL_no_symref_sv, sv, "a SCALAR");
273 gv = (GV*)gv_fetchsv(sv, TRUE, SVt_PV);
278 if (PL_op->op_flags & OPf_MOD) {
279 if (PL_op->op_private & OPpLVAL_INTRO) {
280 if (cUNOP->op_first->op_type == OP_NULL)
281 sv = save_scalar((GV*)TOPs);
283 sv = save_scalar(gv);
285 Perl_croak(aTHX_ PL_no_localize_ref);
287 else if (PL_op->op_private & OPpDEREF)
288 vivify_ref(sv, PL_op->op_private & OPpDEREF);
297 AV * const av = (AV*)TOPs;
298 SV ** const sv = Perl_av_arylen_p(aTHX_ (AV*)av);
301 sv_upgrade(*sv, SVt_PVMG);
302 sv_magic(*sv, (SV*)av, PERL_MAGIC_arylen, Nullch, 0);
310 dSP; dTARGET; dPOPss;
312 if (PL_op->op_flags & OPf_MOD || LVRET) {
313 if (SvTYPE(TARG) < SVt_PVLV) {
314 sv_upgrade(TARG, SVt_PVLV);
315 sv_magic(TARG, Nullsv, PERL_MAGIC_pos, Nullch, 0);
319 if (LvTARG(TARG) != sv) {
321 SvREFCNT_dec(LvTARG(TARG));
322 LvTARG(TARG) = SvREFCNT_inc(sv);
324 PUSHs(TARG); /* no SvSETMAGIC */
328 if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv)) {
329 const MAGIC * const mg = mg_find(sv, PERL_MAGIC_regex_global);
330 if (mg && mg->mg_len >= 0) {
334 PUSHi(i + PL_curcop->cop_arybase);
348 /* We usually try to add a non-existent subroutine in case of AUTOLOAD. */
349 /* (But not in defined().) */
350 CV *cv = sv_2cv(TOPs, &stash, &gv, !(PL_op->op_flags & OPf_SPECIAL));
353 cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
354 if ((PL_op->op_private & OPpLVAL_INTRO)) {
355 if (gv && GvCV(gv) == cv && (gv = gv_autoload4(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), FALSE)))
358 DIE(aTHX_ "Can't modify non-lvalue subroutine call");
362 cv = (CV*)&PL_sv_undef;
376 if (SvPOK(TOPs) && SvCUR(TOPs) >= 7) {
377 const char *s = SvPVX_const(TOPs);
378 if (strnEQ(s, "CORE::", 6)) {
379 const int code = keyword(s + 6, SvCUR(TOPs) - 6);
380 if (code < 0) { /* Overridable. */
381 #define MAX_ARGS_OP ((sizeof(I32) - 1) * 2)
382 int i = 0, n = 0, seen_question = 0;
384 char str[ MAX_ARGS_OP * 2 + 2 ]; /* One ';', one '\0' */
386 if (code == -KEY_chop || code == -KEY_chomp
387 || code == -KEY_exec || code == -KEY_system)
389 while (i < MAXO) { /* The slow way. */
390 if (strEQ(s + 6, PL_op_name[i])
391 || strEQ(s + 6, PL_op_desc[i]))
397 goto nonesuch; /* Should not happen... */
399 oa = PL_opargs[i] >> OASHIFT;
401 if (oa & OA_OPTIONAL && !seen_question) {
405 if ((oa & (OA_OPTIONAL - 1)) >= OA_AVREF
406 && (oa & (OA_OPTIONAL - 1)) <= OA_SCALARREF
407 /* But globs are already references (kinda) */
408 && (oa & (OA_OPTIONAL - 1)) != OA_FILEREF
412 str[n++] = ("?$@@%&*$")[oa & (OA_OPTIONAL - 1)];
416 ret = sv_2mortal(newSVpvn(str, n - 1));
418 else if (code) /* Non-Overridable */
420 else { /* None such */
422 DIE(aTHX_ "Can't find an opnumber for \"%s\"", s+6);
426 cv = sv_2cv(TOPs, &stash, &gv, FALSE);
428 ret = sv_2mortal(newSVpvn(SvPVX_const(cv), SvCUR(cv)));
437 CV* cv = (CV*)PAD_SV(PL_op->op_targ);
439 cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
455 if (GIMME != G_ARRAY) {
459 *MARK = &PL_sv_undef;
460 *MARK = refto(*MARK);
464 EXTEND_MORTAL(SP - MARK);
466 *MARK = refto(*MARK);
471 S_refto(pTHX_ SV *sv)
475 if (SvTYPE(sv) == SVt_PVLV && LvTYPE(sv) == 'y') {
478 if (!(sv = LvTARG(sv)))
481 (void)SvREFCNT_inc(sv);
483 else if (SvTYPE(sv) == SVt_PVAV) {
484 if (!AvREAL((AV*)sv) && AvREIFY((AV*)sv))
487 (void)SvREFCNT_inc(sv);
489 else if (SvPADTMP(sv) && !IS_PADGV(sv))
493 (void)SvREFCNT_inc(sv);
496 sv_upgrade(rv, SVt_RV);
506 SV * const sv = POPs;
511 if (!sv || !SvROK(sv))
514 pv = sv_reftype(SvRV(sv),TRUE);
515 PUSHp(pv, strlen(pv));
525 stash = CopSTASH(PL_curcop);
527 SV * const ssv = POPs;
531 if (ssv && !SvGMAGICAL(ssv) && !SvAMAGIC(ssv) && SvROK(ssv))
532 Perl_croak(aTHX_ "Attempt to bless into a reference");
533 ptr = SvPV_const(ssv,len);
534 if (len == 0 && ckWARN(WARN_MISC))
535 Perl_warner(aTHX_ packWARN(WARN_MISC),
536 "Explicit blessing to '' (assuming package main)");
537 stash = gv_stashpvn(ptr, len, TRUE);
540 (void)sv_bless(TOPs, stash);
549 const char * const elem = SvPV_nolen_const(sv);
550 GV * const gv = (GV*)POPs;
551 SV * tmpRef = Nullsv;
555 /* elem will always be NUL terminated. */
556 const char * const second_letter = elem + 1;
559 if (strEQ(second_letter, "RRAY"))
560 tmpRef = (SV*)GvAV(gv);
563 if (strEQ(second_letter, "ODE"))
564 tmpRef = (SV*)GvCVu(gv);
567 if (strEQ(second_letter, "ILEHANDLE")) {
568 /* finally deprecated in 5.8.0 */
569 deprecate("*glob{FILEHANDLE}");
570 tmpRef = (SV*)GvIOp(gv);
573 if (strEQ(second_letter, "ORMAT"))
574 tmpRef = (SV*)GvFORM(gv);
577 if (strEQ(second_letter, "LOB"))
581 if (strEQ(second_letter, "ASH"))
582 tmpRef = (SV*)GvHV(gv);
585 if (*second_letter == 'O' && !elem[2])
586 tmpRef = (SV*)GvIOp(gv);
589 if (strEQ(second_letter, "AME"))
590 sv = newSVpvn(GvNAME(gv), GvNAMELEN(gv));
593 if (strEQ(second_letter, "ACKAGE")) {
594 const HEK *hek = HvNAME_HEK(GvSTASH(gv));
595 sv = hek ? newSVhek(hek) : newSVpvn("__ANON__", 8);
599 if (strEQ(second_letter, "CALAR"))
614 /* Pattern matching */
619 register unsigned char *s;
622 register I32 *sfirst;
626 if (sv == PL_lastscream) {
632 SvSCREAM_off(PL_lastscream);
633 SvREFCNT_dec(PL_lastscream);
635 PL_lastscream = SvREFCNT_inc(sv);
638 s = (unsigned char*)(SvPV(sv, len));
642 if (pos > PL_maxscream) {
643 if (PL_maxscream < 0) {
644 PL_maxscream = pos + 80;
645 Newx(PL_screamfirst, 256, I32);
646 Newx(PL_screamnext, PL_maxscream, I32);
649 PL_maxscream = pos + pos / 4;
650 Renew(PL_screamnext, PL_maxscream, I32);
654 sfirst = PL_screamfirst;
655 snext = PL_screamnext;
657 if (!sfirst || !snext)
658 DIE(aTHX_ "do_study: out of memory");
660 for (ch = 256; ch; --ch)
665 register const I32 ch = s[pos];
667 snext[pos] = sfirst[ch] - pos;
674 /* piggyback on m//g magic */
675 sv_magic(sv, Nullsv, PERL_MAGIC_regex_global, Nullch, 0);
684 if (PL_op->op_flags & OPf_STACKED)
686 else if (PL_op->op_private & OPpTARGET_MY)
692 TARG = sv_newmortal();
697 /* Lvalue operators. */
709 dSP; dMARK; dTARGET; dORIGMARK;
711 do_chop(TARG, *++MARK);
720 SETi(do_chomp(TOPs));
727 register I32 count = 0;
730 count += do_chomp(POPs);
738 register SV* const sv = POPs;
740 if (!sv || !SvANY(sv))
742 switch (SvTYPE(sv)) {
744 if (AvMAX(sv) >= 0 || SvGMAGICAL(sv)
745 || (SvRMAGICAL(sv) && mg_find(sv, PERL_MAGIC_tied)))
749 if (HvARRAY(sv) || SvGMAGICAL(sv)
750 || (SvRMAGICAL(sv) && mg_find(sv, PERL_MAGIC_tied)))
754 if (CvROOT(sv) || CvXSUB(sv))
770 if (!PL_op->op_private) {
779 SV_CHECK_THINKFIRST_COW_DROP(sv);
781 switch (SvTYPE(sv)) {
791 if (cv_const_sv((CV*)sv) && ckWARN(WARN_MISC))
792 Perl_warner(aTHX_ packWARN(WARN_MISC), "Constant subroutine %s undefined",
793 CvANON((CV*)sv) ? "(anonymous)" : GvENAME(CvGV((CV*)sv)));
797 /* let user-undef'd sub keep its identity */
798 GV* gv = CvGV((CV*)sv);
805 SvSetMagicSV(sv, &PL_sv_undef);
810 GvGP(sv) = gp_ref(gp);
811 GvSV(sv) = NEWSV(72,0);
812 GvLINE(sv) = CopLINE(PL_curcop);
818 if (SvTYPE(sv) >= SVt_PV && SvPVX_const(sv) && SvLEN(sv)) {
820 SvPV_set(sv, Nullch);
833 if (SvTYPE(TOPs) >= SVt_PVGV && SvTYPE(TOPs) != SVt_PVLV)
834 DIE(aTHX_ PL_no_modify);
835 if (!SvREADONLY(TOPs) && SvIOK_notUV(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs)
836 && SvIVX(TOPs) != IV_MIN)
838 SvIV_set(TOPs, SvIVX(TOPs) - 1);
839 SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
850 if (SvTYPE(TOPs) >= SVt_PVGV && SvTYPE(TOPs) != SVt_PVLV)
851 DIE(aTHX_ PL_no_modify);
852 sv_setsv(TARG, TOPs);
853 if (!SvREADONLY(TOPs) && SvIOK_notUV(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs)
854 && SvIVX(TOPs) != IV_MAX)
856 SvIV_set(TOPs, SvIVX(TOPs) + 1);
857 SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
862 /* special case for undef: see thread at 2003-03/msg00536.html in archive */
872 if (SvTYPE(TOPs) >= SVt_PVGV && SvTYPE(TOPs) != SVt_PVLV)
873 DIE(aTHX_ PL_no_modify);
874 sv_setsv(TARG, TOPs);
875 if (!SvREADONLY(TOPs) && SvIOK_notUV(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs)
876 && SvIVX(TOPs) != IV_MIN)
878 SvIV_set(TOPs, SvIVX(TOPs) - 1);
879 SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
888 /* Ordinary operators. */
893 #ifdef PERL_PRESERVE_IVUV
896 tryAMAGICbin(pow,opASSIGN);
897 #ifdef PERL_PRESERVE_IVUV
898 /* For integer to integer power, we do the calculation by hand wherever
899 we're sure it is safe; otherwise we call pow() and try to convert to
900 integer afterwards. */
913 const IV iv = SvIVX(TOPs);
917 goto float_it; /* Can't do negative powers this way. */
921 baseuok = SvUOK(TOPm1s);
923 baseuv = SvUVX(TOPm1s);
925 const IV iv = SvIVX(TOPm1s);
928 baseuok = TRUE; /* effectively it's a UV now */
930 baseuv = -iv; /* abs, baseuok == false records sign */
933 /* now we have integer ** positive integer. */
936 /* foo & (foo - 1) is zero only for a power of 2. */
937 if (!(baseuv & (baseuv - 1))) {
938 /* We are raising power-of-2 to a positive integer.
939 The logic here will work for any base (even non-integer
940 bases) but it can be less accurate than
941 pow (base,power) or exp (power * log (base)) when the
942 intermediate values start to spill out of the mantissa.
943 With powers of 2 we know this can't happen.
944 And powers of 2 are the favourite thing for perl
945 programmers to notice ** not doing what they mean. */
947 NV base = baseuok ? baseuv : -(NV)baseuv;
952 while (power >>= 1) {
963 register unsigned int highbit = 8 * sizeof(UV);
964 register unsigned int diff = 8 * sizeof(UV);
967 if (baseuv >> highbit) {
971 /* we now have baseuv < 2 ** highbit */
972 if (power * highbit <= 8 * sizeof(UV)) {
973 /* result will definitely fit in UV, so use UV math
974 on same algorithm as above */
975 register UV result = 1;
976 register UV base = baseuv;
977 const bool odd_power = (bool)(power & 1);
981 while (power >>= 1) {
988 if (baseuok || !odd_power)
989 /* answer is positive */
991 else if (result <= (UV)IV_MAX)
992 /* answer negative, fits in IV */
994 else if (result == (UV)IV_MIN)
995 /* 2's complement assumption: special case IV_MIN */
998 /* answer negative, doesn't fit */
1010 SETn( Perl_pow( left, right) );
1011 #ifdef PERL_PRESERVE_IVUV
1021 dSP; dATARGET; tryAMAGICbin(mult,opASSIGN);
1022 #ifdef PERL_PRESERVE_IVUV
1025 /* Unless the left argument is integer in range we are going to have to
1026 use NV maths. Hence only attempt to coerce the right argument if
1027 we know the left is integer. */
1028 /* Left operand is defined, so is it IV? */
1029 SvIV_please(TOPm1s);
1030 if (SvIOK(TOPm1s)) {
1031 bool auvok = SvUOK(TOPm1s);
1032 bool buvok = SvUOK(TOPs);
1033 const UV topmask = (~ (UV)0) << (4 * sizeof (UV));
1034 const UV botmask = ~((~ (UV)0) << (4 * sizeof (UV)));
1041 alow = SvUVX(TOPm1s);
1043 const IV aiv = SvIVX(TOPm1s);
1046 auvok = TRUE; /* effectively it's a UV now */
1048 alow = -aiv; /* abs, auvok == false records sign */
1054 const IV biv = SvIVX(TOPs);
1057 buvok = TRUE; /* effectively it's a UV now */
1059 blow = -biv; /* abs, buvok == false records sign */
1063 /* If this does sign extension on unsigned it's time for plan B */
1064 ahigh = alow >> (4 * sizeof (UV));
1066 bhigh = blow >> (4 * sizeof (UV));
1068 if (ahigh && bhigh) {
1069 /* eg 32 bit is at least 0x10000 * 0x10000 == 0x100000000
1070 which is overflow. Drop to NVs below. */
1071 } else if (!ahigh && !bhigh) {
1072 /* eg 32 bit is at most 0xFFFF * 0xFFFF == 0xFFFE0001
1073 so the unsigned multiply cannot overflow. */
1074 UV product = alow * blow;
1075 if (auvok == buvok) {
1076 /* -ve * -ve or +ve * +ve gives a +ve result. */
1080 } else if (product <= (UV)IV_MIN) {
1081 /* 2s complement assumption that (UV)-IV_MIN is correct. */
1082 /* -ve result, which could overflow an IV */
1084 SETi( -(IV)product );
1086 } /* else drop to NVs below. */
1088 /* One operand is large, 1 small */
1091 /* swap the operands */
1093 bhigh = blow; /* bhigh now the temp var for the swap */
1097 /* now, ((ahigh * blow) << half_UV_len) + (alow * blow)
1098 multiplies can't overflow. shift can, add can, -ve can. */
1099 product_middle = ahigh * blow;
1100 if (!(product_middle & topmask)) {
1101 /* OK, (ahigh * blow) won't lose bits when we shift it. */
1103 product_middle <<= (4 * sizeof (UV));
1104 product_low = alow * blow;
1106 /* as for pp_add, UV + something mustn't get smaller.
1107 IIRC ANSI mandates this wrapping *behaviour* for
1108 unsigned whatever the actual representation*/
1109 product_low += product_middle;
1110 if (product_low >= product_middle) {
1111 /* didn't overflow */
1112 if (auvok == buvok) {
1113 /* -ve * -ve or +ve * +ve gives a +ve result. */
1115 SETu( product_low );
1117 } else if (product_low <= (UV)IV_MIN) {
1118 /* 2s complement assumption again */
1119 /* -ve result, which could overflow an IV */
1121 SETi( -(IV)product_low );
1123 } /* else drop to NVs below. */
1125 } /* product_middle too large */
1126 } /* ahigh && bhigh */
1127 } /* SvIOK(TOPm1s) */
1132 SETn( left * right );
1139 dSP; dATARGET; tryAMAGICbin(div,opASSIGN);
1140 /* Only try to do UV divide first
1141 if ((SLOPPYDIVIDE is true) or
1142 (PERL_PRESERVE_IVUV is true and one or both SV is a UV too large
1144 The assumption is that it is better to use floating point divide
1145 whenever possible, only doing integer divide first if we can't be sure.
1146 If NV_PRESERVES_UV is true then we know at compile time that no UV
1147 can be too large to preserve, so don't need to compile the code to
1148 test the size of UVs. */
1151 # define PERL_TRY_UV_DIVIDE
1152 /* ensure that 20./5. == 4. */
1154 # ifdef PERL_PRESERVE_IVUV
1155 # ifndef NV_PRESERVES_UV
1156 # define PERL_TRY_UV_DIVIDE
1161 #ifdef PERL_TRY_UV_DIVIDE
1164 SvIV_please(TOPm1s);
1165 if (SvIOK(TOPm1s)) {
1166 bool left_non_neg = SvUOK(TOPm1s);
1167 bool right_non_neg = SvUOK(TOPs);
1171 if (right_non_neg) {
1172 right = SvUVX(TOPs);
1175 const IV biv = SvIVX(TOPs);
1178 right_non_neg = TRUE; /* effectively it's a UV now */
1184 /* historically undef()/0 gives a "Use of uninitialized value"
1185 warning before dieing, hence this test goes here.
1186 If it were immediately before the second SvIV_please, then
1187 DIE() would be invoked before left was even inspected, so
1188 no inpsection would give no warning. */
1190 DIE(aTHX_ "Illegal division by zero");
1193 left = SvUVX(TOPm1s);
1196 const IV aiv = SvIVX(TOPm1s);
1199 left_non_neg = TRUE; /* effectively it's a UV now */
1208 /* For sloppy divide we always attempt integer division. */
1210 /* Otherwise we only attempt it if either or both operands
1211 would not be preserved by an NV. If both fit in NVs
1212 we fall through to the NV divide code below. However,
1213 as left >= right to ensure integer result here, we know that
1214 we can skip the test on the right operand - right big
1215 enough not to be preserved can't get here unless left is
1218 && (left > ((UV)1 << NV_PRESERVES_UV_BITS))
1221 /* Integer division can't overflow, but it can be imprecise. */
1222 const UV result = left / right;
1223 if (result * right == left) {
1224 SP--; /* result is valid */
1225 if (left_non_neg == right_non_neg) {
1226 /* signs identical, result is positive. */
1230 /* 2s complement assumption */
1231 if (result <= (UV)IV_MIN)
1232 SETi( -(IV)result );
1234 /* It's exact but too negative for IV. */
1235 SETn( -(NV)result );
1238 } /* tried integer divide but it was not an integer result */
1239 } /* else (PERL_ABS(result) < 1.0) or (both UVs in range for NV) */
1240 } /* left wasn't SvIOK */
1241 } /* right wasn't SvIOK */
1242 #endif /* PERL_TRY_UV_DIVIDE */
1246 DIE(aTHX_ "Illegal division by zero");
1247 PUSHn( left / right );
1254 dSP; dATARGET; tryAMAGICbin(modulo,opASSIGN);
1258 bool left_neg = FALSE;
1259 bool right_neg = FALSE;
1260 bool use_double = FALSE;
1261 bool dright_valid = FALSE;
1267 right_neg = !SvUOK(TOPs);
1269 right = SvUVX(POPs);
1271 const IV biv = SvIVX(POPs);
1274 right_neg = FALSE; /* effectively it's a UV now */
1282 right_neg = dright < 0;
1285 if (dright < UV_MAX_P1) {
1286 right = U_V(dright);
1287 dright_valid = TRUE; /* In case we need to use double below. */
1293 /* At this point use_double is only true if right is out of range for
1294 a UV. In range NV has been rounded down to nearest UV and
1295 use_double false. */
1297 if (!use_double && SvIOK(TOPs)) {
1299 left_neg = !SvUOK(TOPs);
1303 IV aiv = SvIVX(POPs);
1306 left_neg = FALSE; /* effectively it's a UV now */
1315 left_neg = dleft < 0;
1319 /* This should be exactly the 5.6 behaviour - if left and right are
1320 both in range for UV then use U_V() rather than floor. */
1322 if (dleft < UV_MAX_P1) {
1323 /* right was in range, so is dleft, so use UVs not double.
1327 /* left is out of range for UV, right was in range, so promote
1328 right (back) to double. */
1330 /* The +0.5 is used in 5.6 even though it is not strictly
1331 consistent with the implicit +0 floor in the U_V()
1332 inside the #if 1. */
1333 dleft = Perl_floor(dleft + 0.5);
1336 dright = Perl_floor(dright + 0.5);
1346 DIE(aTHX_ "Illegal modulus zero");
1348 dans = Perl_fmod(dleft, dright);
1349 if ((left_neg != right_neg) && dans)
1350 dans = dright - dans;
1353 sv_setnv(TARG, dans);
1359 DIE(aTHX_ "Illegal modulus zero");
1362 if ((left_neg != right_neg) && ans)
1365 /* XXX may warn: unary minus operator applied to unsigned type */
1366 /* could change -foo to be (~foo)+1 instead */
1367 if (ans <= ~((UV)IV_MAX)+1)
1368 sv_setiv(TARG, ~ans+1);
1370 sv_setnv(TARG, -(NV)ans);
1373 sv_setuv(TARG, ans);
1382 dSP; dATARGET; tryAMAGICbin(repeat,opASSIGN);
1389 const UV uv = SvUV(sv);
1391 count = IV_MAX; /* The best we can do? */
1402 else if (SvNOKp(sv)) {
1403 const NV nv = SvNV(sv);
1411 if (GIMME == G_ARRAY && PL_op->op_private & OPpREPEAT_DOLIST) {
1413 I32 items = SP - MARK;
1415 static const char oom_list_extend[] =
1416 "Out of memory during list extend";
1418 max = items * count;
1419 MEM_WRAP_CHECK_1(max, SV*, oom_list_extend);
1420 /* Did the max computation overflow? */
1421 if (items > 0 && max > 0 && (max < items || max < count))
1422 Perl_croak(aTHX_ oom_list_extend);
1427 /* This code was intended to fix 20010809.028:
1430 for (($x =~ /./g) x 2) {
1431 print chop; # "abcdabcd" expected as output.
1434 * but that change (#11635) broke this code:
1436 $x = [("foo")x2]; # only one "foo" ended up in the anonlist.
1438 * I can't think of a better fix that doesn't introduce
1439 * an efficiency hit by copying the SVs. The stack isn't
1440 * refcounted, and mortalisation obviously doesn't
1441 * Do The Right Thing when the stack has more than
1442 * one pointer to the same mortal value.
1446 *SP = sv_2mortal(newSVsv(*SP));
1456 repeatcpy((char*)(MARK + items), (char*)MARK,
1457 items * sizeof(SV*), count - 1);
1460 else if (count <= 0)
1463 else { /* Note: mark already snarfed by pp_list */
1467 static const char oom_string_extend[] =
1468 "Out of memory during string extend";
1470 SvSetSV(TARG, tmpstr);
1471 SvPV_force(TARG, len);
1472 isutf = DO_UTF8(TARG);
1477 STRLEN max = (UV)count * len;
1478 if (len > ((MEM_SIZE)~0)/count)
1479 Perl_croak(aTHX_ oom_string_extend);
1480 MEM_WRAP_CHECK_1(max, char, oom_string_extend);
1481 SvGROW(TARG, max + 1);
1482 repeatcpy(SvPVX(TARG) + len, SvPVX(TARG), len, count - 1);
1483 SvCUR_set(TARG, SvCUR(TARG) * count);
1485 *SvEND(TARG) = '\0';
1488 (void)SvPOK_only_UTF8(TARG);
1490 (void)SvPOK_only(TARG);
1492 if (PL_op->op_private & OPpREPEAT_DOLIST) {
1493 /* The parser saw this as a list repeat, and there
1494 are probably several items on the stack. But we're
1495 in scalar context, and there's no pp_list to save us
1496 now. So drop the rest of the items -- robin@kitsite.com
1509 dSP; dATARGET; bool useleft; tryAMAGICbin(subtr,opASSIGN);
1510 useleft = USE_LEFT(TOPm1s);
1511 #ifdef PERL_PRESERVE_IVUV
1512 /* See comments in pp_add (in pp_hot.c) about Overflow, and how
1513 "bad things" happen if you rely on signed integers wrapping. */
1516 /* Unless the left argument is integer in range we are going to have to
1517 use NV maths. Hence only attempt to coerce the right argument if
1518 we know the left is integer. */
1519 register UV auv = 0;
1525 a_valid = auvok = 1;
1526 /* left operand is undef, treat as zero. */
1528 /* Left operand is defined, so is it IV? */
1529 SvIV_please(TOPm1s);
1530 if (SvIOK(TOPm1s)) {
1531 if ((auvok = SvUOK(TOPm1s)))
1532 auv = SvUVX(TOPm1s);
1534 register const IV aiv = SvIVX(TOPm1s);
1537 auvok = 1; /* Now acting as a sign flag. */
1538 } else { /* 2s complement assumption for IV_MIN */
1546 bool result_good = 0;
1549 bool buvok = SvUOK(TOPs);
1554 register const IV biv = SvIVX(TOPs);
1561 /* ?uvok if value is >= 0. basically, flagged as UV if it's +ve,
1562 else "IV" now, independent of how it came in.
1563 if a, b represents positive, A, B negative, a maps to -A etc
1568 all UV maths. negate result if A negative.
1569 subtract if signs same, add if signs differ. */
1571 if (auvok ^ buvok) {
1580 /* Must get smaller */
1585 if (result <= buv) {
1586 /* result really should be -(auv-buv). as its negation
1587 of true value, need to swap our result flag */
1599 if (result <= (UV)IV_MIN)
1600 SETi( -(IV)result );
1602 /* result valid, but out of range for IV. */
1603 SETn( -(NV)result );
1607 } /* Overflow, drop through to NVs. */
1611 useleft = USE_LEFT(TOPm1s);
1615 /* left operand is undef, treat as zero - value */
1619 SETn( TOPn - value );
1626 dSP; dATARGET; tryAMAGICbin(lshift,opASSIGN);
1628 const IV shift = POPi;
1629 if (PL_op->op_private & HINT_INTEGER) {
1643 dSP; dATARGET; tryAMAGICbin(rshift,opASSIGN);
1645 const IV shift = POPi;
1646 if (PL_op->op_private & HINT_INTEGER) {
1660 dSP; tryAMAGICbinSET(lt,0);
1661 #ifdef PERL_PRESERVE_IVUV
1664 SvIV_please(TOPm1s);
1665 if (SvIOK(TOPm1s)) {
1666 bool auvok = SvUOK(TOPm1s);
1667 bool buvok = SvUOK(TOPs);
1669 if (!auvok && !buvok) { /* ## IV < IV ## */
1670 const IV aiv = SvIVX(TOPm1s);
1671 const IV biv = SvIVX(TOPs);
1674 SETs(boolSV(aiv < biv));
1677 if (auvok && buvok) { /* ## UV < UV ## */
1678 const UV auv = SvUVX(TOPm1s);
1679 const UV buv = SvUVX(TOPs);
1682 SETs(boolSV(auv < buv));
1685 if (auvok) { /* ## UV < IV ## */
1687 const IV biv = SvIVX(TOPs);
1690 /* As (a) is a UV, it's >=0, so it cannot be < */
1695 SETs(boolSV(auv < (UV)biv));
1698 { /* ## IV < UV ## */
1699 const IV aiv = SvIVX(TOPm1s);
1703 /* As (b) is a UV, it's >=0, so it must be < */
1710 SETs(boolSV((UV)aiv < buv));
1716 #ifndef NV_PRESERVES_UV
1717 #ifdef PERL_PRESERVE_IVUV
1720 if (SvROK(TOPs) && !SvAMAGIC(TOPs) && SvROK(TOPm1s) && !SvAMAGIC(TOPm1s)) {
1722 SETs(boolSV(SvRV(TOPs) < SvRV(TOPp1s)));
1728 SETs(boolSV(TOPn < value));
1735 dSP; tryAMAGICbinSET(gt,0);
1736 #ifdef PERL_PRESERVE_IVUV
1739 SvIV_please(TOPm1s);
1740 if (SvIOK(TOPm1s)) {
1741 bool auvok = SvUOK(TOPm1s);
1742 bool buvok = SvUOK(TOPs);
1744 if (!auvok && !buvok) { /* ## IV > IV ## */
1745 const IV aiv = SvIVX(TOPm1s);
1746 const IV biv = SvIVX(TOPs);
1749 SETs(boolSV(aiv > biv));
1752 if (auvok && buvok) { /* ## UV > UV ## */
1753 const UV auv = SvUVX(TOPm1s);
1754 const UV buv = SvUVX(TOPs);
1757 SETs(boolSV(auv > buv));
1760 if (auvok) { /* ## UV > IV ## */
1762 const IV biv = SvIVX(TOPs);
1766 /* As (a) is a UV, it's >=0, so it must be > */
1771 SETs(boolSV(auv > (UV)biv));
1774 { /* ## IV > UV ## */
1775 const IV aiv = SvIVX(TOPm1s);
1779 /* As (b) is a UV, it's >=0, so it cannot be > */
1786 SETs(boolSV((UV)aiv > buv));
1792 #ifndef NV_PRESERVES_UV
1793 #ifdef PERL_PRESERVE_IVUV
1796 if (SvROK(TOPs) && !SvAMAGIC(TOPs) && SvROK(TOPm1s) && !SvAMAGIC(TOPm1s)) {
1798 SETs(boolSV(SvRV(TOPs) > SvRV(TOPp1s)));
1804 SETs(boolSV(TOPn > value));
1811 dSP; tryAMAGICbinSET(le,0);
1812 #ifdef PERL_PRESERVE_IVUV
1815 SvIV_please(TOPm1s);
1816 if (SvIOK(TOPm1s)) {
1817 bool auvok = SvUOK(TOPm1s);
1818 bool buvok = SvUOK(TOPs);
1820 if (!auvok && !buvok) { /* ## IV <= IV ## */
1821 const IV aiv = SvIVX(TOPm1s);
1822 const IV biv = SvIVX(TOPs);
1825 SETs(boolSV(aiv <= biv));
1828 if (auvok && buvok) { /* ## UV <= UV ## */
1829 UV auv = SvUVX(TOPm1s);
1830 UV buv = SvUVX(TOPs);
1833 SETs(boolSV(auv <= buv));
1836 if (auvok) { /* ## UV <= IV ## */
1838 const IV biv = SvIVX(TOPs);
1842 /* As (a) is a UV, it's >=0, so a cannot be <= */
1847 SETs(boolSV(auv <= (UV)biv));
1850 { /* ## IV <= UV ## */
1851 const IV aiv = SvIVX(TOPm1s);
1855 /* As (b) is a UV, it's >=0, so a must be <= */
1862 SETs(boolSV((UV)aiv <= buv));
1868 #ifndef NV_PRESERVES_UV
1869 #ifdef PERL_PRESERVE_IVUV
1872 if (SvROK(TOPs) && !SvAMAGIC(TOPs) && SvROK(TOPm1s) && !SvAMAGIC(TOPm1s)) {
1874 SETs(boolSV(SvRV(TOPs) <= SvRV(TOPp1s)));
1880 SETs(boolSV(TOPn <= value));
1887 dSP; tryAMAGICbinSET(ge,0);
1888 #ifdef PERL_PRESERVE_IVUV
1891 SvIV_please(TOPm1s);
1892 if (SvIOK(TOPm1s)) {
1893 bool auvok = SvUOK(TOPm1s);
1894 bool buvok = SvUOK(TOPs);
1896 if (!auvok && !buvok) { /* ## IV >= IV ## */
1897 const IV aiv = SvIVX(TOPm1s);
1898 const IV biv = SvIVX(TOPs);
1901 SETs(boolSV(aiv >= biv));
1904 if (auvok && buvok) { /* ## UV >= UV ## */
1905 const UV auv = SvUVX(TOPm1s);
1906 const UV buv = SvUVX(TOPs);
1909 SETs(boolSV(auv >= buv));
1912 if (auvok) { /* ## UV >= IV ## */
1914 const IV biv = SvIVX(TOPs);
1918 /* As (a) is a UV, it's >=0, so it must be >= */
1923 SETs(boolSV(auv >= (UV)biv));
1926 { /* ## IV >= UV ## */
1927 const IV aiv = SvIVX(TOPm1s);
1931 /* As (b) is a UV, it's >=0, so a cannot be >= */
1938 SETs(boolSV((UV)aiv >= buv));
1944 #ifndef NV_PRESERVES_UV
1945 #ifdef PERL_PRESERVE_IVUV
1948 if (SvROK(TOPs) && !SvAMAGIC(TOPs) && SvROK(TOPm1s) && !SvAMAGIC(TOPm1s)) {
1950 SETs(boolSV(SvRV(TOPs) >= SvRV(TOPp1s)));
1956 SETs(boolSV(TOPn >= value));
1963 dSP; tryAMAGICbinSET(ne,0);
1964 #ifndef NV_PRESERVES_UV
1965 if (SvROK(TOPs) && !SvAMAGIC(TOPs) && SvROK(TOPm1s) && !SvAMAGIC(TOPm1s)) {
1967 SETs(boolSV(SvRV(TOPs) != SvRV(TOPp1s)));
1971 #ifdef PERL_PRESERVE_IVUV
1974 SvIV_please(TOPm1s);
1975 if (SvIOK(TOPm1s)) {
1976 bool auvok = SvUOK(TOPm1s);
1977 bool buvok = SvUOK(TOPs);
1979 if (auvok == buvok) { /* ## IV == IV or UV == UV ## */
1980 /* Casting IV to UV before comparison isn't going to matter
1981 on 2s complement. On 1s complement or sign&magnitude
1982 (if we have any of them) it could make negative zero
1983 differ from normal zero. As I understand it. (Need to
1984 check - is negative zero implementation defined behaviour
1986 const UV buv = SvUVX(POPs);
1987 const UV auv = SvUVX(TOPs);
1989 SETs(boolSV(auv != buv));
1992 { /* ## Mixed IV,UV ## */
1996 /* != is commutative so swap if needed (save code) */
1998 /* swap. top of stack (b) is the iv */
2002 /* As (a) is a UV, it's >0, so it cannot be == */
2011 /* As (b) is a UV, it's >0, so it cannot be == */
2015 uv = SvUVX(*(SP+1)); /* Do I want TOPp1s() ? */
2017 SETs(boolSV((UV)iv != uv));
2025 SETs(boolSV(TOPn != value));
2032 dSP; dTARGET; tryAMAGICbin(ncmp,0);
2033 #ifndef NV_PRESERVES_UV
2034 if (SvROK(TOPs) && !SvAMAGIC(TOPs) && SvROK(TOPm1s) && !SvAMAGIC(TOPm1s)) {
2035 UV right = PTR2UV(SvRV(POPs));
2036 UV left = PTR2UV(SvRV(TOPs));
2037 SETi((left > right) - (left < right));
2041 #ifdef PERL_PRESERVE_IVUV
2042 /* Fortunately it seems NaN isn't IOK */
2045 SvIV_please(TOPm1s);
2046 if (SvIOK(TOPm1s)) {
2047 const bool leftuvok = SvUOK(TOPm1s);
2048 const bool rightuvok = SvUOK(TOPs);
2050 if (!leftuvok && !rightuvok) { /* ## IV <=> IV ## */
2051 const IV leftiv = SvIVX(TOPm1s);
2052 const IV rightiv = SvIVX(TOPs);
2054 if (leftiv > rightiv)
2056 else if (leftiv < rightiv)
2060 } else if (leftuvok && rightuvok) { /* ## UV <=> UV ## */
2061 const UV leftuv = SvUVX(TOPm1s);
2062 const UV rightuv = SvUVX(TOPs);
2064 if (leftuv > rightuv)
2066 else if (leftuv < rightuv)
2070 } else if (leftuvok) { /* ## UV <=> IV ## */
2071 const IV rightiv = SvIVX(TOPs);
2073 /* As (a) is a UV, it's >=0, so it cannot be < */
2076 const UV leftuv = SvUVX(TOPm1s);
2077 if (leftuv > (UV)rightiv) {
2079 } else if (leftuv < (UV)rightiv) {
2085 } else { /* ## IV <=> UV ## */
2086 const IV leftiv = SvIVX(TOPm1s);
2088 /* As (b) is a UV, it's >=0, so it must be < */
2091 const UV rightuv = SvUVX(TOPs);
2092 if ((UV)leftiv > rightuv) {
2094 } else if ((UV)leftiv < rightuv) {
2112 if (Perl_isnan(left) || Perl_isnan(right)) {
2116 value = (left > right) - (left < right);
2120 else if (left < right)
2122 else if (left > right)
2136 dSP; tryAMAGICbinSET(slt,0);
2139 const int cmp = (IN_LOCALE_RUNTIME
2140 ? sv_cmp_locale(left, right)
2141 : sv_cmp(left, right));
2142 SETs(boolSV(cmp < 0));
2149 dSP; tryAMAGICbinSET(sgt,0);
2152 const int cmp = (IN_LOCALE_RUNTIME
2153 ? sv_cmp_locale(left, right)
2154 : sv_cmp(left, right));
2155 SETs(boolSV(cmp > 0));
2162 dSP; tryAMAGICbinSET(sle,0);
2165 const int cmp = (IN_LOCALE_RUNTIME
2166 ? sv_cmp_locale(left, right)
2167 : sv_cmp(left, right));
2168 SETs(boolSV(cmp <= 0));
2175 dSP; tryAMAGICbinSET(sge,0);
2178 const int cmp = (IN_LOCALE_RUNTIME
2179 ? sv_cmp_locale(left, right)
2180 : sv_cmp(left, right));
2181 SETs(boolSV(cmp >= 0));
2188 dSP; tryAMAGICbinSET(seq,0);
2191 SETs(boolSV(sv_eq(left, right)));
2198 dSP; tryAMAGICbinSET(sne,0);
2201 SETs(boolSV(!sv_eq(left, right)));
2208 dSP; dTARGET; tryAMAGICbin(scmp,0);
2211 const int cmp = (IN_LOCALE_RUNTIME
2212 ? sv_cmp_locale(left, right)
2213 : sv_cmp(left, right));
2221 dSP; dATARGET; tryAMAGICbin(band,opASSIGN);
2226 if (SvNIOKp(left) || SvNIOKp(right)) {
2227 if (PL_op->op_private & HINT_INTEGER) {
2228 const IV i = SvIV_nomg(left) & SvIV_nomg(right);
2232 const UV u = SvUV_nomg(left) & SvUV_nomg(right);
2237 do_vop(PL_op->op_type, TARG, left, right);
2246 dSP; dATARGET; tryAMAGICbin(bxor,opASSIGN);
2251 if (SvNIOKp(left) || SvNIOKp(right)) {
2252 if (PL_op->op_private & HINT_INTEGER) {
2253 const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) ^ SvIV_nomg(right);
2257 const UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) ^ SvUV_nomg(right);
2262 do_vop(PL_op->op_type, TARG, left, right);
2271 dSP; dATARGET; tryAMAGICbin(bor,opASSIGN);
2276 if (SvNIOKp(left) || SvNIOKp(right)) {
2277 if (PL_op->op_private & HINT_INTEGER) {
2278 const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) | SvIV_nomg(right);
2282 const UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) | SvUV_nomg(right);
2287 do_vop(PL_op->op_type, TARG, left, right);
2296 dSP; dTARGET; tryAMAGICun(neg);
2299 const int flags = SvFLAGS(sv);
2301 if ((flags & SVf_IOK) || ((flags & (SVp_IOK | SVp_NOK)) == SVp_IOK)) {
2302 /* It's publicly an integer, or privately an integer-not-float */
2305 if (SvIVX(sv) == IV_MIN) {
2306 /* 2s complement assumption. */
2307 SETi(SvIVX(sv)); /* special case: -((UV)IV_MAX+1) == IV_MIN */
2310 else if (SvUVX(sv) <= IV_MAX) {
2315 else if (SvIVX(sv) != IV_MIN) {
2319 #ifdef PERL_PRESERVE_IVUV
2328 else if (SvPOKp(sv)) {
2330 const char *s = SvPV_const(sv, len);
2331 if (isIDFIRST(*s)) {
2332 sv_setpvn(TARG, "-", 1);
2335 else if (*s == '+' || *s == '-') {
2337 *SvPV_force(TARG, len) = *s == '-' ? '+' : '-';
2339 else if (DO_UTF8(sv)) {
2342 goto oops_its_an_int;
2344 sv_setnv(TARG, -SvNV(sv));
2346 sv_setpvn(TARG, "-", 1);
2353 goto oops_its_an_int;
2354 sv_setnv(TARG, -SvNV(sv));
2366 dSP; tryAMAGICunSET(not);
2367 *PL_stack_sp = boolSV(!SvTRUE(*PL_stack_sp));
2373 dSP; dTARGET; tryAMAGICun(compl);
2378 if (PL_op->op_private & HINT_INTEGER) {
2379 const IV i = ~SvIV_nomg(sv);
2383 const UV u = ~SvUV_nomg(sv);
2392 (void)SvPV_nomg_const(sv,len); /* force check for uninit var */
2393 sv_setsv_nomg(TARG, sv);
2394 tmps = (U8*)SvPV_force(TARG, len);
2397 /* Calculate exact length, let's not estimate. */
2406 while (tmps < send) {
2407 const UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV);
2408 tmps += UTF8SKIP(tmps);
2409 targlen += UNISKIP(~c);
2415 /* Now rewind strings and write them. */
2419 Newxz(result, targlen + 1, U8);
2420 while (tmps < send) {
2421 const UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV);
2422 tmps += UTF8SKIP(tmps);
2423 result = uvchr_to_utf8_flags(result, ~c, UNICODE_ALLOW_ANY);
2427 sv_setpvn(TARG, (char*)result, targlen);
2431 Newxz(result, nchar + 1, U8);
2432 while (tmps < send) {
2433 const U8 c = (U8)utf8n_to_uvchr(tmps, 0, &l, UTF8_ALLOW_ANY);
2434 tmps += UTF8SKIP(tmps);
2439 sv_setpvn(TARG, (char*)result, nchar);
2448 register long *tmpl;
2449 for ( ; anum && (unsigned long)tmps % sizeof(long); anum--, tmps++)
2452 for ( ; anum >= sizeof(long); anum -= sizeof(long), tmpl++)
2457 for ( ; anum > 0; anum--, tmps++)
2466 /* integer versions of some of the above */
2470 dSP; dATARGET; tryAMAGICbin(mult,opASSIGN);
2473 SETi( left * right );
2480 dSP; dATARGET; tryAMAGICbin(div,opASSIGN);
2484 DIE(aTHX_ "Illegal division by zero");
2485 value = POPi / value;
2494 /* This is the vanilla old i_modulo. */
2495 dVAR; dSP; dATARGET; tryAMAGICbin(modulo,opASSIGN);
2499 DIE(aTHX_ "Illegal modulus zero");
2500 SETi( left % right );
2505 #if defined(__GLIBC__) && IVSIZE == 8
2509 /* This is the i_modulo with the workaround for the _moddi3 bug
2510 * in (at least) glibc 2.2.5 (the PERL_ABS() the workaround).
2511 * See below for pp_i_modulo. */
2512 dVAR; dSP; dATARGET; tryAMAGICbin(modulo,opASSIGN);
2516 DIE(aTHX_ "Illegal modulus zero");
2517 SETi( left % PERL_ABS(right) );
2525 dVAR; dSP; dATARGET; tryAMAGICbin(modulo,opASSIGN);
2529 DIE(aTHX_ "Illegal modulus zero");
2530 /* The assumption is to use hereafter the old vanilla version... */
2532 PL_ppaddr[OP_I_MODULO] =
2534 /* .. but if we have glibc, we might have a buggy _moddi3
2535 * (at least glicb 2.2.5 is known to have this bug), in other
2536 * words our integer modulus with negative quad as the second
2537 * argument might be broken. Test for this and re-patch the
2538 * opcode dispatch table if that is the case, remembering to
2539 * also apply the workaround so that this first round works
2540 * right, too. See [perl #9402] for more information. */
2541 #if defined(__GLIBC__) && IVSIZE == 8
2545 /* Cannot do this check with inlined IV constants since
2546 * that seems to work correctly even with the buggy glibc. */
2548 /* Yikes, we have the bug.
2549 * Patch in the workaround version. */
2551 PL_ppaddr[OP_I_MODULO] =
2552 &Perl_pp_i_modulo_1;
2553 /* Make certain we work right this time, too. */
2554 right = PERL_ABS(right);
2558 SETi( left % right );
2565 dSP; dATARGET; tryAMAGICbin(add,opASSIGN);
2568 SETi( left + right );
2575 dSP; dATARGET; tryAMAGICbin(subtr,opASSIGN);
2578 SETi( left - right );
2585 dSP; tryAMAGICbinSET(lt,0);
2588 SETs(boolSV(left < right));
2595 dSP; tryAMAGICbinSET(gt,0);
2598 SETs(boolSV(left > right));
2605 dSP; tryAMAGICbinSET(le,0);
2608 SETs(boolSV(left <= right));
2615 dSP; tryAMAGICbinSET(ge,0);
2618 SETs(boolSV(left >= right));
2625 dSP; tryAMAGICbinSET(eq,0);
2628 SETs(boolSV(left == right));
2635 dSP; tryAMAGICbinSET(ne,0);
2638 SETs(boolSV(left != right));
2645 dSP; dTARGET; tryAMAGICbin(ncmp,0);
2652 else if (left < right)
2663 dSP; dTARGET; tryAMAGICun(neg);
2668 /* High falutin' math. */
2672 dSP; dTARGET; tryAMAGICbin(atan2,0);
2675 SETn(Perl_atan2(left, right));
2682 dSP; dTARGET; tryAMAGICun(sin);
2684 const NV value = POPn;
2685 XPUSHn(Perl_sin(value));
2692 dSP; dTARGET; tryAMAGICun(cos);
2694 const NV value = POPn;
2695 XPUSHn(Perl_cos(value));
2700 /* Support Configure command-line overrides for rand() functions.
2701 After 5.005, perhaps we should replace this by Configure support
2702 for drand48(), random(), or rand(). For 5.005, though, maintain
2703 compatibility by calling rand() but allow the user to override it.
2704 See INSTALL for details. --Andy Dougherty 15 July 1998
2706 /* Now it's after 5.005, and Configure supports drand48() and random(),
2707 in addition to rand(). So the overrides should not be needed any more.
2708 --Jarkko Hietaniemi 27 September 1998
2711 #ifndef HAS_DRAND48_PROTO
2712 extern double drand48 (void);
2725 if (!PL_srand_called) {
2726 (void)seedDrand01((Rand_seed_t)seed());
2727 PL_srand_called = TRUE;
2742 (void)seedDrand01((Rand_seed_t)anum);
2743 PL_srand_called = TRUE;
2750 dSP; dTARGET; tryAMAGICun(exp);
2754 value = Perl_exp(value);
2762 dSP; dTARGET; tryAMAGICun(log);
2764 const NV value = POPn;
2766 SET_NUMERIC_STANDARD();
2767 DIE(aTHX_ "Can't take log of %"NVgf, value);
2769 XPUSHn(Perl_log(value));
2776 dSP; dTARGET; tryAMAGICun(sqrt);
2778 const NV value = POPn;
2780 SET_NUMERIC_STANDARD();
2781 DIE(aTHX_ "Can't take sqrt of %"NVgf, value);
2783 XPUSHn(Perl_sqrt(value));
2790 dSP; dTARGET; tryAMAGICun(int);
2792 const IV iv = TOPi; /* attempt to convert to IV if possible. */
2793 /* XXX it's arguable that compiler casting to IV might be subtly
2794 different from modf (for numbers inside (IV_MIN,UV_MAX)) in which
2795 else preferring IV has introduced a subtle behaviour change bug. OTOH
2796 relying on floating point to be accurate is a bug. */
2800 else if (SvIOK(TOPs)) {
2807 const NV value = TOPn;
2809 if (value < (NV)UV_MAX + 0.5) {
2812 SETn(Perl_floor(value));
2816 if (value > (NV)IV_MIN - 0.5) {
2819 SETn(Perl_ceil(value));
2829 dSP; dTARGET; tryAMAGICun(abs);
2831 /* This will cache the NV value if string isn't actually integer */
2836 else if (SvIOK(TOPs)) {
2837 /* IVX is precise */
2839 SETu(TOPu); /* force it to be numeric only */
2847 /* 2s complement assumption. Also, not really needed as
2848 IV_MIN and -IV_MIN should both be %100...00 and NV-able */
2854 const NV value = TOPn;
2869 I32 flags = PERL_SCAN_ALLOW_UNDERSCORES;
2873 SV* const sv = POPs;
2875 tmps = (SvPV_const(sv, len));
2877 /* If Unicode, try to downgrade
2878 * If not possible, croak. */
2879 SV* const tsv = sv_2mortal(newSVsv(sv));
2882 sv_utf8_downgrade(tsv, FALSE);
2883 tmps = SvPV_const(tsv, len);
2885 result_uv = grok_hex (tmps, &len, &flags, &result_nv);
2886 if (flags & PERL_SCAN_GREATER_THAN_UV_MAX) {
2899 I32 flags = PERL_SCAN_ALLOW_UNDERSCORES;
2903 SV* const sv = POPs;
2905 tmps = (SvPV_const(sv, len));
2907 /* If Unicode, try to downgrade
2908 * If not possible, croak. */
2909 SV* const tsv = sv_2mortal(newSVsv(sv));
2912 sv_utf8_downgrade(tsv, FALSE);
2913 tmps = SvPV_const(tsv, len);
2915 while (*tmps && len && isSPACE(*tmps))
2920 result_uv = grok_hex (tmps, &len, &flags, &result_nv);
2921 else if (*tmps == 'b')
2922 result_uv = grok_bin (tmps, &len, &flags, &result_nv);
2924 result_uv = grok_oct (tmps, &len, &flags, &result_nv);
2926 if (flags & PERL_SCAN_GREATER_THAN_UV_MAX) {
2943 SETi(sv_len_utf8(sv));
2959 const I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET;
2961 const I32 arybase = PL_curcop->cop_arybase;
2963 const char *repl = 0;
2965 const int num_args = PL_op->op_private & 7;
2966 bool repl_need_utf8_upgrade = FALSE;
2967 bool repl_is_utf8 = FALSE;
2969 SvTAINTED_off(TARG); /* decontaminate */
2970 SvUTF8_off(TARG); /* decontaminate */
2974 repl = SvPV_const(repl_sv, repl_len);
2975 repl_is_utf8 = DO_UTF8(repl_sv) && SvCUR(repl_sv);
2985 sv_utf8_upgrade(sv);
2987 else if (DO_UTF8(sv))
2988 repl_need_utf8_upgrade = TRUE;
2990 tmps = SvPV_const(sv, curlen);
2992 utf8_curlen = sv_len_utf8(sv);
2993 if (utf8_curlen == curlen)
2996 curlen = utf8_curlen;
3001 if (pos >= arybase) {
3019 else if (len >= 0) {
3021 if (rem > (I32)curlen)
3036 Perl_croak(aTHX_ "substr outside of string");
3037 if (ckWARN(WARN_SUBSTR))
3038 Perl_warner(aTHX_ packWARN(WARN_SUBSTR), "substr outside of string");
3042 const I32 upos = pos;
3043 const I32 urem = rem;
3045 sv_pos_u2b(sv, &pos, &rem);
3047 /* we either return a PV or an LV. If the TARG hasn't been used
3048 * before, or is of that type, reuse it; otherwise use a mortal
3049 * instead. Note that LVs can have an extended lifetime, so also
3050 * dont reuse if refcount > 1 (bug #20933) */
3051 if (SvTYPE(TARG) > SVt_NULL) {
3052 if ( (SvTYPE(TARG) == SVt_PVLV)
3053 ? (!lvalue || SvREFCNT(TARG) > 1)
3056 TARG = sv_newmortal();
3060 sv_setpvn(TARG, tmps, rem);
3061 #ifdef USE_LOCALE_COLLATE
3062 sv_unmagic(TARG, PERL_MAGIC_collxfrm);
3067 SV* repl_sv_copy = NULL;
3069 if (repl_need_utf8_upgrade) {
3070 repl_sv_copy = newSVsv(repl_sv);
3071 sv_utf8_upgrade(repl_sv_copy);
3072 repl = SvPV_const(repl_sv_copy, repl_len);
3073 repl_is_utf8 = DO_UTF8(repl_sv_copy) && SvCUR(sv);
3075 sv_insert(sv, pos, rem, repl, repl_len);
3079 SvREFCNT_dec(repl_sv_copy);
3081 else if (lvalue) { /* it's an lvalue! */
3082 if (!SvGMAGICAL(sv)) {
3084 SvPV_force_nolen(sv);
3085 if (ckWARN(WARN_SUBSTR))
3086 Perl_warner(aTHX_ packWARN(WARN_SUBSTR),
3087 "Attempt to use reference as lvalue in substr");
3089 if (SvOK(sv)) /* is it defined ? */
3090 (void)SvPOK_only_UTF8(sv);
3092 sv_setpvn(sv,"",0); /* avoid lexical reincarnation */
3095 if (SvTYPE(TARG) < SVt_PVLV) {
3096 sv_upgrade(TARG, SVt_PVLV);
3097 sv_magic(TARG, Nullsv, PERL_MAGIC_substr, Nullch, 0);
3103 if (LvTARG(TARG) != sv) {
3105 SvREFCNT_dec(LvTARG(TARG));
3106 LvTARG(TARG) = SvREFCNT_inc(sv);
3108 LvTARGOFF(TARG) = upos;
3109 LvTARGLEN(TARG) = urem;
3113 PUSHs(TARG); /* avoid SvSETMAGIC here */
3120 register const IV size = POPi;
3121 register const IV offset = POPi;
3122 register SV * const src = POPs;
3123 const I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET;
3125 SvTAINTED_off(TARG); /* decontaminate */
3126 if (lvalue) { /* it's an lvalue! */
3127 if (SvREFCNT(TARG) > 1) /* don't share the TARG (#20933) */
3128 TARG = sv_newmortal();
3129 if (SvTYPE(TARG) < SVt_PVLV) {
3130 sv_upgrade(TARG, SVt_PVLV);
3131 sv_magic(TARG, Nullsv, PERL_MAGIC_vec, Nullch, 0);
3134 if (LvTARG(TARG) != src) {
3136 SvREFCNT_dec(LvTARG(TARG));
3137 LvTARG(TARG) = SvREFCNT_inc(src);
3139 LvTARGOFF(TARG) = offset;
3140 LvTARGLEN(TARG) = size;
3143 sv_setuv(TARG, do_vecget(src, offset, size));
3159 const I32 arybase = PL_curcop->cop_arybase;
3166 offset = POPi - arybase;
3169 big_utf8 = DO_UTF8(big);
3170 little_utf8 = DO_UTF8(little);
3171 if (big_utf8 ^ little_utf8) {
3172 /* One needs to be upgraded. */
3173 SV * const bytes = little_utf8 ? big : little;
3175 const char * const p = SvPV_const(bytes, len);
3177 temp = newSVpvn(p, len);
3180 sv_recode_to_utf8(temp, PL_encoding);
3182 sv_utf8_upgrade(temp);
3191 if (big_utf8 && offset > 0)
3192 sv_pos_u2b(big, &offset, 0);
3193 tmps = SvPV_const(big, biglen);
3196 else if (offset > (I32)biglen)
3198 if (!(tmps2 = fbm_instr((unsigned char*)tmps + offset,
3199 (unsigned char*)tmps + biglen, little, 0)))
3202 retval = tmps2 - tmps;
3203 if (retval > 0 && big_utf8)
3204 sv_pos_b2u(big, &retval);
3207 PUSHi(retval + arybase);
3223 const I32 arybase = PL_curcop->cop_arybase;
3231 big_utf8 = DO_UTF8(big);
3232 little_utf8 = DO_UTF8(little);
3233 if (big_utf8 ^ little_utf8) {
3234 /* One needs to be upgraded. */
3235 SV * const bytes = little_utf8 ? big : little;
3237 const char *p = SvPV_const(bytes, len);
3239 temp = newSVpvn(p, len);
3242 sv_recode_to_utf8(temp, PL_encoding);
3244 sv_utf8_upgrade(temp);
3253 tmps2 = SvPV_const(little, llen);
3254 tmps = SvPV_const(big, blen);
3259 if (offset > 0 && big_utf8)
3260 sv_pos_u2b(big, &offset, 0);
3261 offset = offset - arybase + llen;
3265 else if (offset > (I32)blen)
3267 if (!(tmps2 = rninstr(tmps, tmps + offset,
3268 tmps2, tmps2 + llen)))
3271 retval = tmps2 - tmps;
3272 if (retval > 0 && big_utf8)
3273 sv_pos_b2u(big, &retval);
3276 PUSHi(retval + arybase);
3282 dSP; dMARK; dORIGMARK; dTARGET;
3283 do_sprintf(TARG, SP-MARK, MARK+1);
3284 TAINT_IF(SvTAINTED(TARG));
3285 if (DO_UTF8(*(MARK+1)))
3297 const U8 *s = (U8*)SvPV_const(argsv, len);
3300 if (PL_encoding && SvPOK(argsv) && !DO_UTF8(argsv)) {
3301 tmpsv = sv_2mortal(newSVsv(argsv));
3302 s = (U8*)sv_recode_to_utf8(tmpsv, PL_encoding);
3306 XPUSHu(DO_UTF8(argsv) ?
3307 utf8n_to_uvchr(s, UTF8_MAXBYTES, 0, UTF8_ALLOW_ANYUV) :
3319 if (((SvIOK_notUV(TOPs) && SvIV(TOPs) < 0)
3321 (SvNOK(TOPs) && SvNV(TOPs) < 0.0))) {
3323 value = POPu; /* chr(-1) eq chr(0xff), etc. */
3325 (void) POPs; /* Ignore the argument value. */
3326 value = UNICODE_REPLACEMENT;
3332 SvUPGRADE(TARG,SVt_PV);
3334 if (value > 255 && !IN_BYTES) {
3335 SvGROW(TARG, (STRLEN)UNISKIP(value)+1);
3336 tmps = (char*)uvchr_to_utf8_flags((U8*)SvPVX(TARG), value, 0);
3337 SvCUR_set(TARG, tmps - SvPVX_const(TARG));
3339 (void)SvPOK_only(TARG);
3348 *tmps++ = (char)value;
3350 (void)SvPOK_only(TARG);
3351 if (PL_encoding && !IN_BYTES) {
3352 sv_recode_to_utf8(TARG, PL_encoding);
3354 if (SvCUR(TARG) == 0 || !is_utf8_string((U8*)tmps, SvCUR(TARG)) ||
3355 memEQ(tmps, "\xef\xbf\xbd\0", 4)) {
3359 *tmps++ = (U8)UTF8_EIGHT_BIT_HI(value);
3360 *tmps++ = (U8)UTF8_EIGHT_BIT_LO(value);
3375 const char *tmps = SvPV_const(left, len);
3377 if (DO_UTF8(left)) {
3378 /* If Unicode, try to downgrade.
3379 * If not possible, croak.
3380 * Yes, we made this up. */
3381 SV* const tsv = sv_2mortal(newSVsv(left));
3384 sv_utf8_downgrade(tsv, FALSE);
3385 tmps = SvPV_const(tsv, len);
3387 # ifdef USE_ITHREADS
3389 if (!PL_reentrant_buffer->_crypt_struct_buffer) {
3390 /* This should be threadsafe because in ithreads there is only
3391 * one thread per interpreter. If this would not be true,
3392 * we would need a mutex to protect this malloc. */
3393 PL_reentrant_buffer->_crypt_struct_buffer =
3394 (struct crypt_data *)safemalloc(sizeof(struct crypt_data));
3395 #if defined(__GLIBC__) || defined(__EMX__)
3396 if (PL_reentrant_buffer->_crypt_struct_buffer) {
3397 PL_reentrant_buffer->_crypt_struct_buffer->initialized = 0;
3398 /* work around glibc-2.2.5 bug */
3399 PL_reentrant_buffer->_crypt_struct_buffer->current_saltbits = 0;
3403 # endif /* HAS_CRYPT_R */
3404 # endif /* USE_ITHREADS */
3406 sv_setpv(TARG, fcrypt(tmps, SvPV_nolen_const(right)));
3408 sv_setpv(TARG, PerlProc_crypt(tmps, SvPV_nolen_const(right)));
3414 "The crypt() function is unimplemented due to excessive paranoia.");
3427 (s = (const U8*)SvPV_nomg_const(sv, slen)) && slen &&
3428 UTF8_IS_START(*s)) {
3429 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
3433 utf8_to_uvchr(s, &ulen);
3434 toTITLE_utf8(s, tmpbuf, &tculen);
3435 utf8_to_uvchr(tmpbuf, 0);
3437 if (!SvPADTMP(sv) || SvREADONLY(sv)) {
3439 /* slen is the byte length of the whole SV.
3440 * ulen is the byte length of the original Unicode character
3441 * stored as UTF-8 at s.
3442 * tculen is the byte length of the freshly titlecased
3443 * Unicode character stored as UTF-8 at tmpbuf.
3444 * We first set the result to be the titlecased character,
3445 * and then append the rest of the SV data. */
3446 sv_setpvn(TARG, (char*)tmpbuf, tculen);
3448 sv_catpvn(TARG, (char*)(s + ulen), slen - ulen);
3453 s = (U8*)SvPV_force_nomg(sv, slen);
3454 Copy(tmpbuf, s, tculen, U8);
3459 if (!SvPADTMP(sv) || SvREADONLY(sv)) {
3461 SvUTF8_off(TARG); /* decontaminate */
3462 sv_setsv_nomg(TARG, sv);
3466 s1 = (U8*)SvPV_force_nomg(sv, slen);
3468 if (IN_LOCALE_RUNTIME) {
3471 *s1 = toUPPER_LC(*s1);
3490 (s = (const U8*)SvPV_nomg_const(sv, slen)) && slen &&
3491 UTF8_IS_START(*s)) {
3493 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
3497 toLOWER_utf8(s, tmpbuf, &ulen);
3498 uv = utf8_to_uvchr(tmpbuf, 0);
3499 tend = uvchr_to_utf8(tmpbuf, uv);
3501 if (!SvPADTMP(sv) || (STRLEN)(tend - tmpbuf) != ulen || SvREADONLY(sv)) {
3503 sv_setpvn(TARG, (char*)tmpbuf, tend - tmpbuf);
3505 sv_catpvn(TARG, (char*)(s + ulen), slen - ulen);
3510 s = (U8*)SvPV_force_nomg(sv, slen);
3511 Copy(tmpbuf, s, ulen, U8);
3516 if (!SvPADTMP(sv) || SvREADONLY(sv)) {
3518 SvUTF8_off(TARG); /* decontaminate */
3519 sv_setsv_nomg(TARG, sv);
3523 s1 = (U8*)SvPV_force_nomg(sv, slen);
3525 if (IN_LOCALE_RUNTIME) {
3528 *s1 = toLOWER_LC(*s1);
3551 U8 tmpbuf[UTF8_MAXBYTES+1];
3553 s = (const U8*)SvPV_nomg_const(sv,len);
3555 SvUTF8_off(TARG); /* decontaminate */
3556 sv_setpvn(TARG, "", 0);
3560 STRLEN min = len + 1;
3562 SvUPGRADE(TARG, SVt_PV);
3564 (void)SvPOK_only(TARG);
3565 d = (U8*)SvPVX(TARG);
3568 STRLEN u = UTF8SKIP(s);
3570 toUPPER_utf8(s, tmpbuf, &ulen);
3571 if (ulen > u && (SvLEN(TARG) < (min += ulen - u))) {
3572 /* If the eventually required minimum size outgrows
3573 * the available space, we need to grow. */
3574 UV o = d - (U8*)SvPVX_const(TARG);
3576 /* If someone uppercases one million U+03B0s we
3577 * SvGROW() one million times. Or we could try
3578 * guessing how much to allocate without allocating
3579 * too much. Such is life. */
3581 d = (U8*)SvPVX(TARG) + o;
3583 Copy(tmpbuf, d, ulen, U8);
3589 SvCUR_set(TARG, d - (U8*)SvPVX_const(TARG));
3595 if (!SvPADTMP(sv) || SvREADONLY(sv)) {
3597 SvUTF8_off(TARG); /* decontaminate */
3598 sv_setsv_nomg(TARG, sv);
3602 s = (U8*)SvPV_force_nomg(sv, len);
3604 const register U8 *send = s + len;
3606 if (IN_LOCALE_RUNTIME) {
3609 for (; s < send; s++)
3610 *s = toUPPER_LC(*s);
3613 for (; s < send; s++)
3635 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
3637 s = (const U8*)SvPV_nomg_const(sv,len);
3639 SvUTF8_off(TARG); /* decontaminate */
3640 sv_setpvn(TARG, "", 0);
3644 STRLEN min = len + 1;
3646 SvUPGRADE(TARG, SVt_PV);
3648 (void)SvPOK_only(TARG);
3649 d = (U8*)SvPVX(TARG);
3652 const STRLEN u = UTF8SKIP(s);
3653 const UV uv = toLOWER_utf8(s, tmpbuf, &ulen);
3655 #define GREEK_CAPITAL_LETTER_SIGMA 0x03A3 /* Unicode U+03A3 */
3656 if (uv == GREEK_CAPITAL_LETTER_SIGMA) {
3658 * Now if the sigma is NOT followed by
3659 * /$ignorable_sequence$cased_letter/;
3660 * and it IS preceded by
3661 * /$cased_letter$ignorable_sequence/;
3662 * where $ignorable_sequence is
3663 * [\x{2010}\x{AD}\p{Mn}]*
3664 * and $cased_letter is
3665 * [\p{Ll}\p{Lo}\p{Lt}]
3666 * then it should be mapped to 0x03C2,
3667 * (GREEK SMALL LETTER FINAL SIGMA),
3668 * instead of staying 0x03A3.
3669 * "should be": in other words,
3670 * this is not implemented yet.
3671 * See lib/unicore/SpecialCasing.txt.
3674 if (ulen > u && (SvLEN(TARG) < (min += ulen - u))) {
3675 /* If the eventually required minimum size outgrows
3676 * the available space, we need to grow. */
3677 UV o = d - (U8*)SvPVX_const(TARG);
3679 /* If someone lowercases one million U+0130s we
3680 * SvGROW() one million times. Or we could try
3681 * guessing how much to allocate without allocating.
3682 * too much. Such is life. */
3684 d = (U8*)SvPVX(TARG) + o;
3686 Copy(tmpbuf, d, ulen, U8);
3692 SvCUR_set(TARG, d - (U8*)SvPVX_const(TARG));
3698 if (!SvPADTMP(sv) || SvREADONLY(sv)) {
3700 SvUTF8_off(TARG); /* decontaminate */
3701 sv_setsv_nomg(TARG, sv);
3706 s = (U8*)SvPV_force_nomg(sv, len);
3708 register const U8 * const send = s + len;
3710 if (IN_LOCALE_RUNTIME) {
3713 for (; s < send; s++)
3714 *s = toLOWER_LC(*s);
3717 for (; s < send; s++)
3729 SV * const sv = TOPs;
3731 const register char *s = SvPV_const(sv,len);
3733 SvUTF8_off(TARG); /* decontaminate */
3736 SvUPGRADE(TARG, SVt_PV);
3737 SvGROW(TARG, (len * 2) + 1);
3741 if (UTF8_IS_CONTINUED(*s)) {
3742 STRLEN ulen = UTF8SKIP(s);
3766 SvCUR_set(TARG, d - SvPVX_const(TARG));
3767 (void)SvPOK_only_UTF8(TARG);
3770 sv_setpvn(TARG, s, len);
3772 if (SvSMAGICAL(TARG))
3781 dSP; dMARK; dORIGMARK;
3782 register AV* const av = (AV*)POPs;
3783 register const I32 lval = (PL_op->op_flags & OPf_MOD || LVRET);
3785 if (SvTYPE(av) == SVt_PVAV) {
3786 const I32 arybase = PL_curcop->cop_arybase;
3787 if (lval && PL_op->op_private & OPpLVAL_INTRO) {
3790 for (svp = MARK + 1; svp <= SP; svp++) {
3791 const I32 elem = SvIVx(*svp);
3795 if (max > AvMAX(av))
3798 while (++MARK <= SP) {
3800 I32 elem = SvIVx(*MARK);
3804 svp = av_fetch(av, elem, lval);
3806 if (!svp || *svp == &PL_sv_undef)
3807 DIE(aTHX_ PL_no_aelem, elem);
3808 if (PL_op->op_private & OPpLVAL_INTRO)
3809 save_aelem(av, elem, svp);
3811 *MARK = svp ? *svp : &PL_sv_undef;
3814 if (GIMME != G_ARRAY) {
3816 *++MARK = SP > ORIGMARK ? *SP : &PL_sv_undef;
3822 /* Associative arrays. */
3827 HV * const hash = (HV*)POPs;
3829 const I32 gimme = GIMME_V;
3832 /* might clobber stack_sp */
3833 entry = hv_iternext(hash);
3838 SV* const sv = hv_iterkeysv(entry);
3839 PUSHs(sv); /* won't clobber stack_sp */
3840 if (gimme == G_ARRAY) {
3843 /* might clobber stack_sp */
3844 val = hv_iterval(hash, entry);
3849 else if (gimme == G_SCALAR)
3868 const I32 gimme = GIMME_V;
3869 const I32 discard = (gimme == G_VOID) ? G_DISCARD : 0;
3871 if (PL_op->op_private & OPpSLICE) {
3873 HV * const hv = (HV*)POPs;
3874 const U32 hvtype = SvTYPE(hv);
3875 if (hvtype == SVt_PVHV) { /* hash element */
3876 while (++MARK <= SP) {
3877 SV * const sv = hv_delete_ent(hv, *MARK, discard, 0);
3878 *MARK = sv ? sv : &PL_sv_undef;
3881 else if (hvtype == SVt_PVAV) { /* array element */
3882 if (PL_op->op_flags & OPf_SPECIAL) {
3883 while (++MARK <= SP) {
3884 SV * const sv = av_delete((AV*)hv, SvIV(*MARK), discard);
3885 *MARK = sv ? sv : &PL_sv_undef;
3890 DIE(aTHX_ "Not a HASH reference");
3893 else if (gimme == G_SCALAR) {
3898 *++MARK = &PL_sv_undef;
3904 HV * const hv = (HV*)POPs;
3906 if (SvTYPE(hv) == SVt_PVHV)
3907 sv = hv_delete_ent(hv, keysv, discard, 0);
3908 else if (SvTYPE(hv) == SVt_PVAV) {
3909 if (PL_op->op_flags & OPf_SPECIAL)
3910 sv = av_delete((AV*)hv, SvIV(keysv), discard);
3912 DIE(aTHX_ "panic: avhv_delete no longer supported");
3915 DIE(aTHX_ "Not a HASH reference");
3930 if (PL_op->op_private & OPpEXISTS_SUB) {
3933 CV * const cv = sv_2cv(sv, &hv, &gv, FALSE);
3936 if (gv && isGV(gv) && GvCV(gv) && !GvCVGEN(gv))
3942 if (SvTYPE(hv) == SVt_PVHV) {
3943 if (hv_exists_ent(hv, tmpsv, 0))
3946 else if (SvTYPE(hv) == SVt_PVAV) {
3947 if (PL_op->op_flags & OPf_SPECIAL) { /* array element */
3948 if (av_exists((AV*)hv, SvIV(tmpsv)))
3953 DIE(aTHX_ "Not a HASH reference");
3960 dSP; dMARK; dORIGMARK;
3961 register HV * const hv = (HV*)POPs;
3962 register const I32 lval = (PL_op->op_flags & OPf_MOD || LVRET);
3963 const bool localizing = PL_op->op_private & OPpLVAL_INTRO;
3964 bool other_magic = FALSE;
3970 other_magic = mg_find((SV*)hv, PERL_MAGIC_env) ||
3971 ((mg = mg_find((SV*)hv, PERL_MAGIC_tied))
3972 /* Try to preserve the existenceness of a tied hash
3973 * element by using EXISTS and DELETE if possible.
3974 * Fallback to FETCH and STORE otherwise */
3975 && (stash = SvSTASH(SvRV(SvTIED_obj((SV*)hv, mg))))
3976 && gv_fetchmethod_autoload(stash, "EXISTS", TRUE)
3977 && gv_fetchmethod_autoload(stash, "DELETE", TRUE));
3980 while (++MARK <= SP) {
3981 SV * const keysv = *MARK;
3984 bool preeminent = FALSE;
3987 preeminent = SvRMAGICAL(hv) && !other_magic ? 1 :
3988 hv_exists_ent(hv, keysv, 0);
3991 he = hv_fetch_ent(hv, keysv, lval, 0);
3992 svp = he ? &HeVAL(he) : 0;
3995 if (!svp || *svp == &PL_sv_undef) {
3996 DIE(aTHX_ PL_no_helem_sv, keysv);
4000 save_helem(hv, keysv, svp);
4003 const char *key = SvPV_const(keysv, keylen);
4004 SAVEDELETE(hv, savepvn(key,keylen), keylen);
4008 *MARK = svp ? *svp : &PL_sv_undef;
4010 if (GIMME != G_ARRAY) {
4012 *++MARK = SP > ORIGMARK ? *SP : &PL_sv_undef;
4018 /* List operators. */
4023 if (GIMME != G_ARRAY) {
4025 *MARK = *SP; /* unwanted list, return last item */
4027 *MARK = &PL_sv_undef;
4036 SV ** const lastrelem = PL_stack_sp;
4037 SV ** const lastlelem = PL_stack_base + POPMARK;
4038 SV ** const firstlelem = PL_stack_base + POPMARK + 1;
4039 register SV ** const firstrelem = lastlelem + 1;
4040 const I32 arybase = PL_curcop->cop_arybase;
4041 I32 is_something_there = PL_op->op_flags & OPf_MOD;
4043 register const I32 max = lastrelem - lastlelem;
4044 register SV **lelem;
4046 if (GIMME != G_ARRAY) {
4047 I32 ix = SvIVx(*lastlelem);
4052 if (ix < 0 || ix >= max)
4053 *firstlelem = &PL_sv_undef;
4055 *firstlelem = firstrelem[ix];
4061 SP = firstlelem - 1;
4065 for (lelem = firstlelem; lelem <= lastlelem; lelem++) {
4066 I32 ix = SvIVx(*lelem);
4071 if (ix < 0 || ix >= max)
4072 *lelem = &PL_sv_undef;
4074 is_something_there = TRUE;
4075 if (!(*lelem = firstrelem[ix]))
4076 *lelem = &PL_sv_undef;
4079 if (is_something_there)
4082 SP = firstlelem - 1;
4088 dSP; dMARK; dORIGMARK;
4089 const I32 items = SP - MARK;
4090 SV * const av = sv_2mortal((SV*)av_make(items, MARK+1));
4091 SP = ORIGMARK; /* av_make() might realloc stack_sp */
4098 dSP; dMARK; dORIGMARK;
4099 HV* const hv = (HV*)sv_2mortal((SV*)newHV());
4102 SV * const key = *++MARK;
4103 SV * const val = NEWSV(46, 0);
4105 sv_setsv(val, *++MARK);
4106 else if (ckWARN(WARN_MISC))
4107 Perl_warner(aTHX_ packWARN(WARN_MISC), "Odd number of elements in anonymous hash");
4108 (void)hv_store_ent(hv,key,val,0);
4117 dVAR; dSP; dMARK; dORIGMARK;
4118 register AV *ary = (AV*)*++MARK;
4122 register I32 offset;
4123 register I32 length;
4128 const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied);
4131 *MARK-- = SvTIED_obj((SV*)ary, mg);
4135 call_method("SPLICE",GIMME_V);
4144 offset = i = SvIVx(*MARK);
4146 offset += AvFILLp(ary) + 1;
4148 offset -= PL_curcop->cop_arybase;
4150 DIE(aTHX_ PL_no_aelem, i);
4152 length = SvIVx(*MARK++);
4154 length += AvFILLp(ary) - offset + 1;
4160 length = AvMAX(ary) + 1; /* close enough to infinity */
4164 length = AvMAX(ary) + 1;
4166 if (offset > AvFILLp(ary) + 1) {
4167 if (ckWARN(WARN_MISC))
4168 Perl_warner(aTHX_ packWARN(WARN_MISC), "splice() offset past end of array" );
4169 offset = AvFILLp(ary) + 1;
4171 after = AvFILLp(ary) + 1 - (offset + length);
4172 if (after < 0) { /* not that much array */
4173 length += after; /* offset+length now in array */
4179 /* At this point, MARK .. SP-1 is our new LIST */
4182 diff = newlen - length;
4183 if (newlen && !AvREAL(ary) && AvREIFY(ary))
4186 /* make new elements SVs now: avoid problems if they're from the array */
4187 for (dst = MARK, i = newlen; i; i--) {
4188 SV * const h = *dst;
4189 *dst++ = newSVsv(h);
4192 if (diff < 0) { /* shrinking the area */
4194 Newx(tmparyval, newlen, SV*); /* so remember insertion */
4195 Copy(MARK, tmparyval, newlen, SV*);
4198 MARK = ORIGMARK + 1;
4199 if (GIMME == G_ARRAY) { /* copy return vals to stack */
4200 MEXTEND(MARK, length);
4201 Copy(AvARRAY(ary)+offset, MARK, length, SV*);
4203 EXTEND_MORTAL(length);
4204 for (i = length, dst = MARK; i; i--) {
4205 sv_2mortal(*dst); /* free them eventualy */
4212 *MARK = AvARRAY(ary)[offset+length-1];
4215 for (i = length - 1, dst = &AvARRAY(ary)[offset]; i > 0; i--)
4216 SvREFCNT_dec(*dst++); /* free them now */
4219 AvFILLp(ary) += diff;
4221 /* pull up or down? */
4223 if (offset < after) { /* easier to pull up */
4224 if (offset) { /* esp. if nothing to pull */
4225 src = &AvARRAY(ary)[offset-1];
4226 dst = src - diff; /* diff is negative */
4227 for (i = offset; i > 0; i--) /* can't trust Copy */
4231 SvPV_set(ary, (char*)(AvARRAY(ary) - diff)); /* diff is negative */
4235 if (after) { /* anything to pull down? */
4236 src = AvARRAY(ary) + offset + length;
4237 dst = src + diff; /* diff is negative */
4238 Move(src, dst, after, SV*);
4240 dst = &AvARRAY(ary)[AvFILLp(ary)+1];
4241 /* avoid later double free */
4245 dst[--i] = &PL_sv_undef;
4248 Copy( tmparyval, AvARRAY(ary) + offset, newlen, SV* );
4249 Safefree(tmparyval);
4252 else { /* no, expanding (or same) */
4254 Newx(tmparyval, length, SV*); /* so remember deletion */
4255 Copy(AvARRAY(ary)+offset, tmparyval, length, SV*);
4258 if (diff > 0) { /* expanding */
4260 /* push up or down? */
4262 if (offset < after && diff <= AvARRAY(ary) - AvALLOC(ary)) {
4266 Move(src, dst, offset, SV*);
4268 SvPV_set(ary, (char*)(AvARRAY(ary) - diff));/* diff is positive */
4270 AvFILLp(ary) += diff;
4273 if (AvFILLp(ary) + diff >= AvMAX(ary)) /* oh, well */
4274 av_extend(ary, AvFILLp(ary) + diff);
4275 AvFILLp(ary) += diff;
4278 dst = AvARRAY(ary) + AvFILLp(ary);
4280 for (i = after; i; i--) {
4288 Copy( MARK, AvARRAY(ary) + offset, newlen, SV* );
4291 MARK = ORIGMARK + 1;
4292 if (GIMME == G_ARRAY) { /* copy return vals to stack */
4294 Copy(tmparyval, MARK, length, SV*);
4296 EXTEND_MORTAL(length);
4297 for (i = length, dst = MARK; i; i--) {
4298 sv_2mortal(*dst); /* free them eventualy */
4302 Safefree(tmparyval);
4306 else if (length--) {
4307 *MARK = tmparyval[length];
4310 while (length-- > 0)
4311 SvREFCNT_dec(tmparyval[length]);
4313 Safefree(tmparyval);
4316 *MARK = &PL_sv_undef;
4324 dVAR; dSP; dMARK; dORIGMARK; dTARGET;
4325 register AV *ary = (AV*)*++MARK;
4326 const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied);
4329 *MARK-- = SvTIED_obj((SV*)ary, mg);
4333 call_method("PUSH",G_SCALAR|G_DISCARD);
4338 /* Why no pre-extend of ary here ? */
4339 for (++MARK; MARK <= SP; MARK++) {
4340 SV * const sv = NEWSV(51, 0);
4342 sv_setsv(sv, *MARK);
4347 PUSHi( AvFILL(ary) + 1 );
4354 AV * const av = (AV*)POPs;
4355 SV * const sv = av_pop(av);
4357 (void)sv_2mortal(sv);
4365 AV * const av = (AV*)POPs;
4366 SV * const sv = av_shift(av);
4371 (void)sv_2mortal(sv);
4378 dVAR; dSP; dMARK; dORIGMARK; dTARGET;
4379 register AV *ary = (AV*)*++MARK;
4380 const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied);
4383 *MARK-- = SvTIED_obj((SV*)ary, mg);
4387 call_method("UNSHIFT",G_SCALAR|G_DISCARD);
4393 av_unshift(ary, SP - MARK);
4395 SV * const sv = newSVsv(*++MARK);
4396 (void)av_store(ary, i++, sv);
4400 PUSHi( AvFILL(ary) + 1 );
4407 SV ** const oldsp = SP;
4409 if (GIMME == G_ARRAY) {
4412 register SV * const tmp = *MARK;
4416 /* safe as long as stack cannot get extended in the above */
4421 register char *down;
4427 SvUTF8_off(TARG); /* decontaminate */
4429 do_join(TARG, &PL_sv_no, MARK, SP);
4431 sv_setsv(TARG, (SP > MARK)
4433 : (padoff_du = find_rundefsvoffset(),
4434 (padoff_du == NOT_IN_PAD || PAD_COMPNAME_FLAGS(padoff_du) & SVpad_OUR)
4435 ? DEFSV : PAD_SVl(padoff_du)));
4436 up = SvPV_force(TARG, len);
4438 if (DO_UTF8(TARG)) { /* first reverse each character */
4439 U8* s = (U8*)SvPVX(TARG);
4440 const U8* send = (U8*)(s + len);
4442 if (UTF8_IS_INVARIANT(*s)) {
4447 if (!utf8_to_uvchr(s, 0))
4451 down = (char*)(s - 1);
4452 /* reverse this character */
4456 *down-- = (char)tmp;
4462 down = SvPVX(TARG) + len - 1;
4466 *down-- = (char)tmp;
4468 (void)SvPOK_only_UTF8(TARG);
4480 register IV limit = POPi; /* note, negative is forever */
4481 SV * const sv = POPs;
4483 register const char *s = SvPV_const(sv, len);
4484 const bool do_utf8 = DO_UTF8(sv);
4485 const char *strend = s + len;
4487 register REGEXP *rx;
4489 register const char *m;
4491 const STRLEN slen = do_utf8 ? utf8_length((U8*)s, (U8*)strend) : (strend - s);
4492 I32 maxiters = slen + 10;
4494 const I32 origlimit = limit;
4497 const I32 gimme = GIMME_V;
4498 const I32 oldsave = PL_savestack_ix;
4499 I32 make_mortal = 1;
4501 MAGIC *mg = (MAGIC *) NULL;
4504 Copy(&LvTARGOFF(POPs), &pm, 1, PMOP*);
4509 DIE(aTHX_ "panic: pp_split");
4512 TAINT_IF((pm->op_pmflags & PMf_LOCALE) &&
4513 (pm->op_pmflags & (PMf_WHITE | PMf_SKIPWHITE)));
4515 RX_MATCH_UTF8_set(rx, do_utf8);
4517 if (pm->op_pmreplroot) {
4519 ary = GvAVn((GV*)PAD_SVl(INT2PTR(PADOFFSET, pm->op_pmreplroot)));
4521 ary = GvAVn((GV*)pm->op_pmreplroot);
4524 else if (gimme != G_ARRAY)
4525 ary = GvAVn(PL_defgv);
4528 if (ary && (gimme != G_ARRAY || (pm->op_pmflags & PMf_ONCE))) {
4534 if ((mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied))) {
4536 XPUSHs(SvTIED_obj((SV*)ary, mg));
4543 for (i = AvFILLp(ary); i >= 0; i--)
4544 AvARRAY(ary)[i] = &PL_sv_undef; /* don't free mere refs */
4546 /* temporarily switch stacks */
4547 SAVESWITCHSTACK(PL_curstack, ary);
4551 base = SP - PL_stack_base;
4553 if (pm->op_pmflags & PMf_SKIPWHITE) {
4554 if (pm->op_pmflags & PMf_LOCALE) {
4555 while (isSPACE_LC(*s))
4563 if (pm->op_pmflags & PMf_MULTILINE) {
4568 limit = maxiters + 2;
4569 if (pm->op_pmflags & PMf_WHITE) {
4572 while (m < strend &&
4573 !((pm->op_pmflags & PMf_LOCALE)
4574 ? isSPACE_LC(*m) : isSPACE(*m)))
4579 dstr = newSVpvn(s, m-s);
4583 (void)SvUTF8_on(dstr);
4587 while (s < strend &&
4588 ((pm->op_pmflags & PMf_LOCALE)
4589 ? isSPACE_LC(*s) : isSPACE(*s)))
4593 else if (rx->precomp[0] == '^' && rx->precomp[1] == '\0') {
4595 for (m = s; m < strend && *m != '\n'; m++)
4600 dstr = newSVpvn(s, m-s);
4604 (void)SvUTF8_on(dstr);
4609 else if (do_utf8 == ((rx->reganch & ROPT_UTF8) != 0) &&
4610 (rx->reganch & RE_USE_INTUIT) && !rx->nparens
4611 && (rx->reganch & ROPT_CHECK_ALL)
4612 && !(rx->reganch & ROPT_ANCH)) {
4613 const int tail = (rx->reganch & RE_INTUIT_TAIL);
4614 SV * const csv = CALLREG_INTUIT_STRING(aTHX_ rx);
4617 if (len == 1 && !(rx->reganch & ROPT_UTF8) && !tail) {
4618 const char c = *SvPV_nolen_const(csv);
4620 for (m = s; m < strend && *m != c; m++)
4624 dstr = newSVpvn(s, m-s);
4628 (void)SvUTF8_on(dstr);
4630 /* The rx->minlen is in characters but we want to step
4631 * s ahead by bytes. */
4633 s = (char*)utf8_hop((U8*)m, len);
4635 s = m + len; /* Fake \n at the end */
4639 while (s < strend && --limit &&
4640 (m = fbm_instr((unsigned char*)s, (unsigned char*)strend,
4641 csv, multiline ? FBMrf_MULTILINE : 0)) )
4643 dstr = newSVpvn(s, m-s);
4647 (void)SvUTF8_on(dstr);
4649 /* The rx->minlen is in characters but we want to step
4650 * s ahead by bytes. */
4652 s = (char*)utf8_hop((U8*)m, len);
4654 s = m + len; /* Fake \n at the end */
4659 maxiters += slen * rx->nparens;
4660 while (s < strend && --limit)
4664 rex_return = CALLREGEXEC(aTHX_ rx, (char*)s, (char*)strend, (char*)orig, 1 ,
4667 if (rex_return == 0)
4669 TAINT_IF(RX_MATCH_TAINTED(rx));
4670 if (RX_MATCH_COPIED(rx) && rx->subbeg != orig) {
4675 strend = s + (strend - m);
4677 m = rx->startp[0] + orig;
4678 dstr = newSVpvn(s, m-s);
4682 (void)SvUTF8_on(dstr);
4686 for (i = 1; i <= (I32)rx->nparens; i++) {
4687 s = rx->startp[i] + orig;
4688 m = rx->endp[i] + orig;
4690 /* japhy (07/27/01) -- the (m && s) test doesn't catch
4691 parens that didn't match -- they should be set to
4692 undef, not the empty string */
4693 if (m >= orig && s >= orig) {
4694 dstr = newSVpvn(s, m-s);
4697 dstr = &PL_sv_undef; /* undef, not "" */
4701 (void)SvUTF8_on(dstr);
4705 s = rx->endp[0] + orig;
4709 iters = (SP - PL_stack_base) - base;
4710 if (iters > maxiters)
4711 DIE(aTHX_ "Split loop");
4713 /* keep field after final delim? */
4714 if (s < strend || (iters && origlimit)) {
4715 const STRLEN l = strend - s;
4716 dstr = newSVpvn(s, l);
4720 (void)SvUTF8_on(dstr);
4724 else if (!origlimit) {
4725 while (iters > 0 && (!TOPs || !SvANY(TOPs) || SvCUR(TOPs) == 0)) {
4726 if (TOPs && !make_mortal)
4729 *SP-- = &PL_sv_undef;
4734 LEAVE_SCOPE(oldsave); /* may undo an earlier SWITCHSTACK */
4738 if (SvSMAGICAL(ary)) {
4743 if (gimme == G_ARRAY) {
4745 Copy(AvARRAY(ary), SP + 1, iters, SV*);
4753 call_method("PUSH",G_SCALAR|G_DISCARD);
4756 if (gimme == G_ARRAY) {
4758 /* EXTEND should not be needed - we just popped them */
4760 for (i=0; i < iters; i++) {
4761 SV **svp = av_fetch(ary, i, FALSE);
4762 PUSHs((svp) ? *svp : &PL_sv_undef);
4769 if (gimme == G_ARRAY)
4784 if (SvTYPE(retsv) == SVt_PVAV || SvTYPE(retsv) == SVt_PVHV
4785 || SvTYPE(retsv) == SVt_PVCV) {
4786 retsv = refto(retsv);
4794 DIE(aTHX_ "tried to access per-thread data in non-threaded perl");
4799 * c-indentation-style: bsd
4801 * indent-tabs-mode: t
4804 * ex: set ts=8 sts=4 sw=4 noet: