3 * Copyright (c) 1991-1997, 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
19 * The compiler on Concurrent CX/UX systems has a subtle bug which only
20 * seems to show up when compiling pp.c - it generates the wrong double
21 * precision constant value for (double)UV_MAX when used inline in the body
22 * of the code below, so this makes a static variable up front (which the
23 * compiler seems to get correct) and uses it in place of UV_MAX below.
25 #ifdef CXUX_BROKEN_CONSTANT_CONVERT
26 static double UV_MAX_cxux = ((double)UV_MAX);
30 * Types used in bitwise operations.
32 * Normally we'd just use IV and UV. However, some hardware and
33 * software combinations (e.g. Alpha and current OSF/1) don't have a
34 * floating-point type to use for NV that has adequate bits to fully
35 * hold an IV/UV. (In other words, sizeof(long) == sizeof(double).)
37 * It just so happens that "int" is the right size almost everywhere.
43 * Mask used after bitwise operations.
45 * There is at least one realm (Cray word machines) that doesn't
46 * have an integral type (except char) small enough to be represented
47 * in a double without loss; that is, it has no 32-bit type.
49 #if LONGSIZE > 4 && defined(_CRAY) && !defined(_CRAYMPP)
51 # define BW_MASK ((1 << BW_BITS) - 1)
52 # define BW_SIGN (1 << (BW_BITS - 1))
53 # define BWi(i) (((i) & BW_SIGN) ? ((i) | ~BW_MASK) : ((i) & BW_MASK))
54 # define BWu(u) ((u) & BW_MASK)
61 * Offset for integer pack/unpack.
63 * On architectures where I16 and I32 aren't really 16 and 32 bits,
64 * which for now are all Crays, pack and unpack have to play games.
68 * These values are required for portability of pack() output.
69 * If they're not right on your machine, then pack() and unpack()
70 * wouldn't work right anyway; you'll need to apply the Cray hack.
71 * (I'd like to check them with #if, but you can't use sizeof() in
72 * the preprocessor.) --???
75 The appropriate SHORTSIZE, INTSIZE, LONGSIZE, and LONGLONGSIZE
76 defines are now in config.h. --Andy Dougherty April 1998
81 #if BYTEORDER > 0xFFFF && defined(_CRAY) && !defined(_CRAYMPP)
82 # if BYTEORDER == 0x12345678
83 # define OFF16(p) (char*)(p)
84 # define OFF32(p) (char*)(p)
86 # if BYTEORDER == 0x87654321
87 # define OFF16(p) ((char*)(p) + (sizeof(U16) - SIZE16))
88 # define OFF32(p) ((char*)(p) + (sizeof(U32) - SIZE32))
90 }}}} bad cray byte order
93 # define COPY16(s,p) (*(p) = 0, Copy(s, OFF16(p), SIZE16, char))
94 # define COPY32(s,p) (*(p) = 0, Copy(s, OFF32(p), SIZE32, char))
95 # define CAT16(sv,p) sv_catpvn(sv, OFF16(p), SIZE16)
96 # define CAT32(sv,p) sv_catpvn(sv, OFF32(p), SIZE32)
98 # define COPY16(s,p) Copy(s, p, SIZE16, char)
99 # define COPY32(s,p) Copy(s, p, SIZE32, char)
100 # define CAT16(sv,p) sv_catpvn(sv, (char*)(p), SIZE16)
101 # define CAT32(sv,p) sv_catpvn(sv, (char*)(p), SIZE32)
105 static void doencodes _((SV* sv, char* s, I32 len));
106 static SV* refto _((SV* sv));
107 static U32 seed _((void));
110 static bool srand_called = FALSE;
112 /* variations on pp_null */
118 /* XXX I can't imagine anyone who doesn't have this actually _needs_
119 it, since pid_t is an integral type.
122 #ifdef NEED_GETPID_PROTO
123 extern Pid_t getpid (void);
129 if (GIMME_V == G_SCALAR)
144 if (op->op_private & OPpLVAL_INTRO)
145 SAVECLEARSV(curpad[op->op_targ]);
147 if (op->op_flags & OPf_REF) {
151 if (GIMME == G_ARRAY) {
152 I32 maxarg = AvFILL((AV*)TARG) + 1;
154 if (SvMAGICAL(TARG)) {
156 for (i=0; i < maxarg; i++) {
157 SV **svp = av_fetch((AV*)TARG, i, FALSE);
158 SP[i+1] = (svp) ? *svp : &sv_undef;
162 Copy(AvARRAY((AV*)TARG), SP+1, maxarg, SV*);
167 SV* sv = sv_newmortal();
168 I32 maxarg = AvFILL((AV*)TARG) + 1;
169 sv_setiv(sv, maxarg);
181 if (op->op_private & OPpLVAL_INTRO)
182 SAVECLEARSV(curpad[op->op_targ]);
183 if (op->op_flags & OPf_REF)
186 if (gimme == G_ARRAY) {
187 RETURNOP(do_kv(ARGS));
189 else if (gimme == G_SCALAR) {
190 SV* sv = sv_newmortal();
191 if (HvFILL((HV*)TARG))
192 sv_setpvf(sv, "%ld/%ld",
193 (long)HvFILL((HV*)TARG), (long)HvMAX((HV*)TARG) + 1);
203 DIE("NOT IMPL LINE %d",__LINE__);
215 if (SvTYPE(sv) == SVt_PVIO) {
216 GV *gv = (GV*) sv_newmortal();
217 gv_init(gv, 0, "", 0, 0);
218 GvIOp(gv) = (IO *)sv;
219 (void)SvREFCNT_inc(sv);
221 } else if (SvTYPE(sv) != SVt_PVGV)
222 DIE("Not a GLOB reference");
225 if (SvTYPE(sv) != SVt_PVGV) {
228 if (SvGMAGICAL(sv)) {
234 if (op->op_flags & OPf_REF ||
235 op->op_private & HINT_STRICT_REFS)
236 DIE(no_usym, "a symbol");
242 if (op->op_private & HINT_STRICT_REFS)
243 DIE(no_symref, sym, "a symbol");
244 sv = (SV*)gv_fetchpv(sym, TRUE, SVt_PVGV);
247 if (op->op_private & OPpLVAL_INTRO)
248 save_gp((GV*)sv, !(op->op_flags & OPf_SPECIAL));
260 switch (SvTYPE(sv)) {
264 DIE("Not a SCALAR reference");
271 if (SvTYPE(gv) != SVt_PVGV) {
272 if (SvGMAGICAL(sv)) {
278 if (op->op_flags & OPf_REF ||
279 op->op_private & HINT_STRICT_REFS)
280 DIE(no_usym, "a SCALAR");
286 if (op->op_private & HINT_STRICT_REFS)
287 DIE(no_symref, sym, "a SCALAR");
288 gv = (GV*)gv_fetchpv(sym, TRUE, SVt_PV);
292 if (op->op_flags & OPf_MOD) {
293 if (op->op_private & OPpLVAL_INTRO)
294 sv = save_scalar((GV*)TOPs);
295 else if (op->op_private & OPpDEREF)
296 vivify_ref(sv, op->op_private & OPpDEREF);
306 SV *sv = AvARYLEN(av);
308 AvARYLEN(av) = sv = NEWSV(0,0);
309 sv_upgrade(sv, SVt_IV);
310 sv_magic(sv, (SV*)av, '#', Nullch, 0);
318 djSP; dTARGET; dPOPss;
320 if (op->op_flags & OPf_MOD) {
321 if (SvTYPE(TARG) < SVt_PVLV) {
322 sv_upgrade(TARG, SVt_PVLV);
323 sv_magic(TARG, Nullsv, '.', Nullch, 0);
327 if (LvTARG(TARG) != sv) {
329 SvREFCNT_dec(LvTARG(TARG));
330 LvTARG(TARG) = SvREFCNT_inc(sv);
332 PUSHs(TARG); /* no SvSETMAGIC */
338 if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv)) {
339 mg = mg_find(sv, 'g');
340 if (mg && mg->mg_len >= 0) {
341 PUSHi(mg->mg_len + curcop->cop_arybase);
355 /* We usually try to add a non-existent subroutine in case of AUTOLOAD. */
356 /* (But not in defined().) */
357 CV *cv = sv_2cv(TOPs, &stash, &gv, !(op->op_flags & OPf_SPECIAL));
360 cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
377 if (SvPOK(TOPs) && SvCUR(TOPs) >= 7) {
378 char *s = SvPVX(TOPs);
379 if (strnEQ(s, "CORE::", 6)) {
382 code = keyword(s + 6, SvCUR(TOPs) - 6);
383 if (code < 0) { /* Overridable. */
384 #define MAX_ARGS_OP ((sizeof(I32) - 1) * 2)
385 int i = 0, n = 0, seen_question = 0;
387 char str[ MAX_ARGS_OP * 2 + 2 ]; /* One ';', one '\0' */
389 while (i < MAXO) { /* The slow way. */
390 if (strEQ(s + 6, op_name[i]) || strEQ(s + 6, op_desc[i]))
394 goto nonesuch; /* Should not happen... */
396 oa = opargs[i] >> OASHIFT;
398 if (oa & OA_OPTIONAL) {
401 } else if (seen_question)
402 goto set; /* XXXX system, exec */
403 if ((oa & (OA_OPTIONAL - 1)) >= OA_AVREF
404 && (oa & (OA_OPTIONAL - 1)) <= OA_HVREF) {
407 /* What to do with R ((un)tie, tied, (sys)read, recv)? */
408 str[n++] = ("?$@@%&*$")[oa & (OA_OPTIONAL - 1)];
412 ret = sv_2mortal(newSVpv(str, n - 1));
413 } else if (code) /* Non-Overridable */
415 else { /* None such */
417 croak("Cannot find an opnumber for \"%s\"", s+6);
421 cv = sv_2cv(TOPs, &stash, &gv, FALSE);
423 ret = sv_2mortal(newSVpv(SvPVX(cv), SvCUR(cv)));
432 CV* cv = (CV*)curpad[op->op_targ];
434 cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
450 if (GIMME != G_ARRAY) {
455 *MARK = refto(*MARK);
459 EXTEND_MORTAL(SP - MARK);
461 *MARK = refto(*MARK);
470 if (SvTYPE(sv) == SVt_PVLV && LvTYPE(sv) == 'y') {
473 if (!(sv = LvTARG(sv)))
476 else if (SvPADTMP(sv))
480 (void)SvREFCNT_inc(sv);
483 sv_upgrade(rv, SVt_RV);
497 if (sv && SvGMAGICAL(sv))
500 if (!sv || !SvROK(sv))
504 pv = sv_reftype(sv,TRUE);
505 PUSHp(pv, strlen(pv));
515 stash = curcop->cop_stash;
519 char *ptr = SvPV(ssv,len);
520 if (dowarn && len == 0)
521 warn("Explicit blessing to '' (assuming package main)");
522 stash = gv_stashpvn(ptr, len, TRUE);
525 (void)sv_bless(TOPs, stash);
542 switch (elem ? *elem : '\0')
545 if (strEQ(elem, "ARRAY"))
546 tmpRef = (SV*)GvAV(gv);
549 if (strEQ(elem, "CODE"))
550 tmpRef = (SV*)GvCVu(gv);
553 if (strEQ(elem, "FILEHANDLE")) /* XXX deprecate in 5.005 */
554 tmpRef = (SV*)GvIOp(gv);
557 if (strEQ(elem, "GLOB"))
561 if (strEQ(elem, "HASH"))
562 tmpRef = (SV*)GvHV(gv);
565 if (strEQ(elem, "IO"))
566 tmpRef = (SV*)GvIOp(gv);
569 if (strEQ(elem, "NAME"))
570 sv = newSVpv(GvNAME(gv), GvNAMELEN(gv));
573 if (strEQ(elem, "PACKAGE"))
574 sv = newSVpv(HvNAME(GvSTASH(gv)), 0);
577 if (strEQ(elem, "SCALAR"))
591 /* Pattern matching */
596 register UNOP *unop = cUNOP;
597 register unsigned char *s;
600 register I32 *sfirst;
604 if (sv == lastscream) {
610 SvSCREAM_off(lastscream);
611 SvREFCNT_dec(lastscream);
613 lastscream = SvREFCNT_inc(sv);
616 s = (unsigned char*)(SvPV(sv, len));
620 if (pos > maxscream) {
622 maxscream = pos + 80;
623 New(301, screamfirst, 256, I32);
624 New(302, screamnext, maxscream, I32);
627 maxscream = pos + pos / 4;
628 Renew(screamnext, maxscream, I32);
632 sfirst = screamfirst;
635 if (!sfirst || !snext)
636 DIE("do_study: out of memory");
638 for (ch = 256; ch; --ch)
645 snext[pos] = sfirst[ch] - pos;
652 sv_magic(sv, Nullsv, 'g', Nullch, 0); /* piggyback on m//g magic */
661 if (op->op_flags & OPf_STACKED)
667 TARG = sv_newmortal();
668 PUSHi(do_trans(sv, op));
672 /* Lvalue operators. */
684 djSP; dMARK; dTARGET;
694 SETi(do_chomp(TOPs));
700 djSP; dMARK; dTARGET;
701 register I32 count = 0;
704 count += do_chomp(POPs);
715 if (!sv || !SvANY(sv))
717 switch (SvTYPE(sv)) {
719 if (AvMAX(sv) >= 0 || SvGMAGICAL(sv))
723 if (HvARRAY(sv) || SvGMAGICAL(sv))
727 if (CvROOT(sv) || CvXSUB(sv))
744 if (!op->op_private) {
753 if (SvTHINKFIRST(sv)) {
760 switch (SvTYPE(sv)) {
770 if (dowarn && cv_const_sv((CV*)sv))
771 warn("Constant subroutine %s undefined",
772 CvANON((CV*)sv) ? "(anonymous)" : GvENAME(CvGV((CV*)sv)));
775 { GV* gv = (GV*)SvREFCNT_inc(CvGV((CV*)sv));
777 CvGV((CV*)sv) = gv; } /* let user-undef'd sub keep its identity */
781 SvSetMagicSV(sv, &sv_undef);
785 Newz(602, gp, 1, GP);
786 GvGP(sv) = gp_ref(gp);
787 GvSV(sv) = NEWSV(72,0);
788 GvLINE(sv) = curcop->cop_line;
794 if (SvTYPE(sv) >= SVt_PV && SvPVX(sv) && SvLEN(sv)) {
797 SvPV_set(sv, Nullch);
810 if (SvREADONLY(TOPs) || SvTYPE(TOPs) > SVt_PVLV)
812 if (SvIOK(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs) &&
813 SvIVX(TOPs) != IV_MIN)
816 SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
827 if (SvREADONLY(TOPs) || SvTYPE(TOPs) > SVt_PVLV)
829 sv_setsv(TARG, TOPs);
830 if (SvIOK(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs) &&
831 SvIVX(TOPs) != IV_MAX)
834 SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
848 if(SvREADONLY(TOPs) || SvTYPE(TOPs) > SVt_PVLV)
850 sv_setsv(TARG, TOPs);
851 if (SvIOK(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs) &&
852 SvIVX(TOPs) != IV_MIN)
855 SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
864 /* Ordinary operators. */
868 djSP; dATARGET; tryAMAGICbin(pow,opASSIGN);
871 SETn( pow( left, right) );
878 djSP; dATARGET; tryAMAGICbin(mult,opASSIGN);
881 SETn( left * right );
888 djSP; dATARGET; tryAMAGICbin(div,opASSIGN);
893 DIE("Illegal division by zero");
895 /* insure that 20./5. == 4. */
898 if ((double)I_V(left) == left &&
899 (double)I_V(right) == right &&
900 (k = I_V(left)/I_V(right))*I_V(right) == I_V(left)) {
903 value = left / right;
907 value = left / right;
916 djSP; dATARGET; tryAMAGICbin(modulo,opASSIGN);
924 if (SvIOK(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs)) {
926 right = (right_neg = (i < 0)) ? -i : i;
930 right = U_V((right_neg = (n < 0)) ? -n : n);
933 if (SvIOK(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs)) {
935 left = (left_neg = (i < 0)) ? -i : i;
939 left = U_V((left_neg = (n < 0)) ? -n : n);
943 DIE("Illegal modulus zero");
946 if ((left_neg != right_neg) && ans)
949 /* XXX may warn: unary minus operator applied to unsigned type */
950 /* could change -foo to be (~foo)+1 instead */
951 if (ans <= ~((UV)IV_MAX)+1)
952 sv_setiv(TARG, ~ans+1);
954 sv_setnv(TARG, -(double)ans);
965 djSP; dATARGET; tryAMAGICbin(repeat,opASSIGN);
967 register I32 count = POPi;
968 if (GIMME == G_ARRAY && op->op_private & OPpREPEAT_DOLIST) {
970 I32 items = SP - MARK;
982 repeatcpy((char*)(MARK + items), (char*)MARK,
983 items * sizeof(SV*), count - 1);
989 else { /* Note: mark already snarfed by pp_list */
994 if (TARG == tmpstr && SvTHINKFIRST(tmpstr)) {
995 if (SvREADONLY(tmpstr) && curcop != &compiling)
996 DIE("Can't x= to readonly value");
1000 SvSetSV(TARG, tmpstr);
1001 SvPV_force(TARG, len);
1006 SvGROW(TARG, (count * len) + 1);
1007 repeatcpy(SvPVX(TARG) + len, SvPVX(TARG), len, count - 1);
1008 SvCUR(TARG) *= count;
1010 *SvEND(TARG) = '\0';
1012 (void)SvPOK_only(TARG);
1021 djSP; dATARGET; tryAMAGICbin(subtr,opASSIGN);
1024 SETn( left - right );
1031 djSP; dATARGET; tryAMAGICbin(lshift,opASSIGN);
1034 if (op->op_private & HINT_INTEGER) {
1036 i = BWi(i) << shift;
1050 djSP; dATARGET; tryAMAGICbin(rshift,opASSIGN);
1053 if (op->op_private & HINT_INTEGER) {
1055 i = BWi(i) >> shift;
1069 djSP; tryAMAGICbinSET(lt,0);
1072 SETs(boolSV(TOPn < value));
1079 djSP; tryAMAGICbinSET(gt,0);
1082 SETs(boolSV(TOPn > value));
1089 djSP; tryAMAGICbinSET(le,0);
1092 SETs(boolSV(TOPn <= value));
1099 djSP; tryAMAGICbinSET(ge,0);
1102 SETs(boolSV(TOPn >= value));
1109 djSP; tryAMAGICbinSET(ne,0);
1112 SETs(boolSV(TOPn != value));
1119 djSP; dTARGET; tryAMAGICbin(ncmp,0);
1126 else if (left < right)
1128 else if (left > right)
1141 djSP; tryAMAGICbinSET(slt,0);
1144 int cmp = ((op->op_private & OPpLOCALE)
1145 ? sv_cmp_locale(left, right)
1146 : sv_cmp(left, right));
1147 SETs(boolSV(cmp < 0));
1154 djSP; tryAMAGICbinSET(sgt,0);
1157 int cmp = ((op->op_private & OPpLOCALE)
1158 ? sv_cmp_locale(left, right)
1159 : sv_cmp(left, right));
1160 SETs(boolSV(cmp > 0));
1167 djSP; tryAMAGICbinSET(sle,0);
1170 int cmp = ((op->op_private & OPpLOCALE)
1171 ? sv_cmp_locale(left, right)
1172 : sv_cmp(left, right));
1173 SETs(boolSV(cmp <= 0));
1180 djSP; tryAMAGICbinSET(sge,0);
1183 int cmp = ((op->op_private & OPpLOCALE)
1184 ? sv_cmp_locale(left, right)
1185 : sv_cmp(left, right));
1186 SETs(boolSV(cmp >= 0));
1193 djSP; tryAMAGICbinSET(seq,0);
1196 SETs(boolSV(sv_eq(left, right)));
1203 djSP; tryAMAGICbinSET(sne,0);
1206 SETs(boolSV(!sv_eq(left, right)));
1213 djSP; dTARGET; tryAMAGICbin(scmp,0);
1216 int cmp = ((op->op_private & OPpLOCALE)
1217 ? sv_cmp_locale(left, right)
1218 : sv_cmp(left, right));
1226 djSP; dATARGET; tryAMAGICbin(band,opASSIGN);
1229 if (SvNIOKp(left) || SvNIOKp(right)) {
1230 if (op->op_private & HINT_INTEGER) {
1231 IBW value = SvIV(left) & SvIV(right);
1235 UBW value = SvUV(left) & SvUV(right);
1240 do_vop(op->op_type, TARG, left, right);
1249 djSP; dATARGET; tryAMAGICbin(bxor,opASSIGN);
1252 if (SvNIOKp(left) || SvNIOKp(right)) {
1253 if (op->op_private & HINT_INTEGER) {
1254 IBW value = (USE_LEFT(left) ? SvIV(left) : 0) ^ SvIV(right);
1258 UBW value = (USE_LEFT(left) ? SvUV(left) : 0) ^ SvUV(right);
1263 do_vop(op->op_type, TARG, left, right);
1272 djSP; dATARGET; tryAMAGICbin(bor,opASSIGN);
1275 if (SvNIOKp(left) || SvNIOKp(right)) {
1276 if (op->op_private & HINT_INTEGER) {
1277 IBW value = (USE_LEFT(left) ? SvIV(left) : 0) | SvIV(right);
1281 UBW value = (USE_LEFT(left) ? SvUV(left) : 0) | SvUV(right);
1286 do_vop(op->op_type, TARG, left, right);
1295 djSP; dTARGET; tryAMAGICun(neg);
1300 if (SvIOKp(sv) && !SvNOKp(sv) && !SvPOKp(sv) && SvIVX(sv) != IV_MIN)
1302 else if (SvNIOKp(sv))
1304 else if (SvPOKp(sv)) {
1306 char *s = SvPV(sv, len);
1307 if (isIDFIRST(*s)) {
1308 sv_setpvn(TARG, "-", 1);
1311 else if (*s == '+' || *s == '-') {
1313 *SvPV_force(TARG, len) = *s == '-' ? '+' : '-';
1316 sv_setnv(TARG, -SvNV(sv));
1328 djSP; tryAMAGICunSET(not);
1329 #endif /* OVERLOAD */
1330 *stack_sp = boolSV(!SvTRUE(*stack_sp));
1336 djSP; dTARGET; tryAMAGICun(compl);
1340 if (op->op_private & HINT_INTEGER) {
1341 IBW value = ~SvIV(sv);
1345 UBW value = ~SvUV(sv);
1350 register char *tmps;
1351 register long *tmpl;
1356 tmps = SvPV_force(TARG, len);
1359 for ( ; anum && (unsigned long)tmps % sizeof(long); anum--, tmps++)
1362 for ( ; anum >= sizeof(long); anum -= sizeof(long), tmpl++)
1366 for ( ; anum > 0; anum--, tmps++)
1375 /* integer versions of some of the above */
1379 djSP; dATARGET; tryAMAGICbin(mult,opASSIGN);
1382 SETi( left * right );
1389 djSP; dATARGET; tryAMAGICbin(div,opASSIGN);
1393 DIE("Illegal division by zero");
1394 value = POPi / value;
1402 djSP; dATARGET; tryAMAGICbin(modulo,opASSIGN);
1406 DIE("Illegal modulus zero");
1407 SETi( left % right );
1414 djSP; dATARGET; tryAMAGICbin(add,opASSIGN);
1417 SETi( left + right );
1424 djSP; dATARGET; tryAMAGICbin(subtr,opASSIGN);
1427 SETi( left - right );
1434 djSP; tryAMAGICbinSET(lt,0);
1437 SETs(boolSV(left < right));
1444 djSP; tryAMAGICbinSET(gt,0);
1447 SETs(boolSV(left > right));
1454 djSP; tryAMAGICbinSET(le,0);
1457 SETs(boolSV(left <= right));
1464 djSP; tryAMAGICbinSET(ge,0);
1467 SETs(boolSV(left >= right));
1474 djSP; tryAMAGICbinSET(eq,0);
1477 SETs(boolSV(left == right));
1484 djSP; tryAMAGICbinSET(ne,0);
1487 SETs(boolSV(left != right));
1494 djSP; dTARGET; tryAMAGICbin(ncmp,0);
1501 else if (left < right)
1512 djSP; dTARGET; tryAMAGICun(neg);
1517 /* High falutin' math. */
1521 djSP; dTARGET; tryAMAGICbin(atan2,0);
1524 SETn(atan2(left, right));
1531 djSP; dTARGET; tryAMAGICun(sin);
1543 djSP; dTARGET; tryAMAGICun(cos);
1563 if (!srand_called) {
1564 (void)srand((unsigned)seed());
1565 srand_called = TRUE;
1568 value = rand() * value / 2147483648.0;
1571 value = rand() * value / 65536.0;
1574 value = rand() * value / 32768.0;
1576 value = rand() * value / (double)(((unsigned long)1) << RANDBITS);
1592 (void)srand((unsigned)anum);
1593 srand_called = TRUE;
1602 * This is really just a quick hack which grabs various garbage
1603 * values. It really should be a real hash algorithm which
1604 * spreads the effect of every input bit onto every output bit,
1605 * if someone who knows about such tings would bother to write it.
1606 * Might be a good idea to add that function to CORE as well.
1607 * No numbers below come from careful analysis or anyting here,
1608 * except they are primes and SEED_C1 > 1E6 to get a full-width
1609 * value from (tv_sec * SEED_C1 + tv_usec). The multipliers should
1610 * probably be bigger too.
1613 # define SEED_C1 1000003
1614 #define SEED_C4 73819
1616 # define SEED_C1 25747
1617 #define SEED_C4 20639
1621 #define SEED_C5 26107
1626 # include <starlet.h>
1627 /* when[] = (low 32 bits, high 32 bits) of time since epoch
1628 * in 100-ns units, typically incremented ever 10 ms. */
1629 unsigned int when[2];
1630 _ckvmssts(sys$gettim(when));
1631 u = (U32)SEED_C1 * when[0] + (U32)SEED_C2 * when[1];
1633 # ifdef HAS_GETTIMEOFDAY
1634 struct timeval when;
1635 gettimeofday(&when,(struct timezone *) 0);
1636 u = (U32)SEED_C1 * when.tv_sec + (U32)SEED_C2 * when.tv_usec;
1640 u = (U32)SEED_C1 * when;
1643 u += SEED_C3 * (U32)getpid();
1644 u += SEED_C4 * (U32)(UV)stack_sp;
1645 #ifndef PLAN9 /* XXX Plan9 assembler chokes on this; fix needed */
1646 u += SEED_C5 * (U32)(UV)&when;
1653 djSP; dTARGET; tryAMAGICun(exp);
1665 djSP; dTARGET; tryAMAGICun(log);
1670 SET_NUMERIC_STANDARD();
1671 DIE("Can't take log of %g", value);
1681 djSP; dTARGET; tryAMAGICun(sqrt);
1686 SET_NUMERIC_STANDARD();
1687 DIE("Can't take sqrt of %g", value);
1689 value = sqrt(value);
1699 double value = TOPn;
1702 if (SvIOKp(TOPs) && !SvNOKp(TOPs) && !SvPOKp(TOPs)) {
1708 (void)modf(value, &value);
1710 (void)modf(-value, &value);
1725 djSP; dTARGET; tryAMAGICun(abs);
1727 double value = TOPn;
1730 if (SvIOKp(TOPs) && !SvNOKp(TOPs) && !SvPOKp(TOPs) &&
1731 (iv = SvIVX(TOPs)) != IV_MIN) {
1752 XPUSHu(scan_hex(tmps, 99, &argtype));
1764 while (*tmps && isSPACE(*tmps))
1769 value = scan_hex(++tmps, 99, &argtype);
1771 value = scan_oct(tmps, 99, &argtype);
1781 SETi( sv_len(TOPs) );
1794 I32 lvalue = op->op_flags & OPf_MOD;
1796 I32 arybase = curcop->cop_arybase;
1800 SvTAINTED_off(TARG); /* decontaminate */
1804 repl = SvPV(sv, repl_len);
1811 tmps = SvPV(sv, curlen);
1812 if (pos >= arybase) {
1830 else if (len >= 0) {
1832 if (rem > (I32)curlen)
1846 if (dowarn || lvalue || repl)
1847 warn("substr outside of string");
1852 sv_setpvn(TARG, tmps, rem);
1853 if (lvalue) { /* it's an lvalue! */
1854 if (!SvGMAGICAL(sv)) {
1858 warn("Attempt to use reference as lvalue in substr");
1860 if (SvOK(sv)) /* is it defined ? */
1861 (void)SvPOK_only(sv);
1863 sv_setpvn(sv,"",0); /* avoid lexical reincarnation */
1866 if (SvTYPE(TARG) < SVt_PVLV) {
1867 sv_upgrade(TARG, SVt_PVLV);
1868 sv_magic(TARG, Nullsv, 'x', Nullch, 0);
1872 if (LvTARG(TARG) != sv) {
1874 SvREFCNT_dec(LvTARG(TARG));
1875 LvTARG(TARG) = SvREFCNT_inc(sv);
1877 LvTARGOFF(TARG) = pos;
1878 LvTARGLEN(TARG) = rem;
1881 sv_insert(sv, pos, rem, repl, repl_len);
1884 PUSHs(TARG); /* avoid SvSETMAGIC here */
1891 register I32 size = POPi;
1892 register I32 offset = POPi;
1893 register SV *src = POPs;
1894 I32 lvalue = op->op_flags & OPf_MOD;
1896 unsigned char *s = (unsigned char*)SvPV(src, srclen);
1897 unsigned long retnum;
1900 SvTAINTED_off(TARG); /* decontaminate */
1901 offset *= size; /* turn into bit offset */
1902 len = (offset + size + 7) / 8;
1903 if (offset < 0 || size < 1)
1906 if (lvalue) { /* it's an lvalue! */
1907 if (SvTYPE(TARG) < SVt_PVLV) {
1908 sv_upgrade(TARG, SVt_PVLV);
1909 sv_magic(TARG, Nullsv, 'v', Nullch, 0);
1913 if (LvTARG(TARG) != src) {
1915 SvREFCNT_dec(LvTARG(TARG));
1916 LvTARG(TARG) = SvREFCNT_inc(src);
1918 LvTARGOFF(TARG) = offset;
1919 LvTARGLEN(TARG) = size;
1927 if (offset >= srclen)
1930 retnum = (unsigned long) s[offset] << 8;
1932 else if (size == 32) {
1933 if (offset >= srclen)
1935 else if (offset + 1 >= srclen)
1936 retnum = (unsigned long) s[offset] << 24;
1937 else if (offset + 2 >= srclen)
1938 retnum = ((unsigned long) s[offset] << 24) +
1939 ((unsigned long) s[offset + 1] << 16);
1941 retnum = ((unsigned long) s[offset] << 24) +
1942 ((unsigned long) s[offset + 1] << 16) +
1943 (s[offset + 2] << 8);
1948 retnum = (s[offset >> 3] >> (offset & 7)) & ((1 << size) - 1);
1953 else if (size == 16)
1954 retnum = ((unsigned long) s[offset] << 8) + s[offset+1];
1955 else if (size == 32)
1956 retnum = ((unsigned long) s[offset] << 24) +
1957 ((unsigned long) s[offset + 1] << 16) +
1958 (s[offset + 2] << 8) + s[offset+3];
1962 sv_setuv(TARG, (UV)retnum);
1977 I32 arybase = curcop->cop_arybase;
1982 offset = POPi - arybase;
1985 tmps = SvPV(big, biglen);
1988 else if (offset > biglen)
1990 if (!(tmps2 = fbm_instr((unsigned char*)tmps + offset,
1991 (unsigned char*)tmps + biglen, little, 0)))
1992 retval = -1 + arybase;
1994 retval = tmps2 - tmps + arybase;
2011 I32 arybase = curcop->cop_arybase;
2017 tmps2 = SvPV(little, llen);
2018 tmps = SvPV(big, blen);
2022 offset = SvIV(offstr) - arybase + llen;
2025 else if (offset > blen)
2027 if (!(tmps2 = rninstr(tmps, tmps + offset,
2028 tmps2, tmps2 + llen)))
2029 retval = -1 + arybase;
2031 retval = tmps2 - tmps + arybase;
2038 djSP; dMARK; dORIGMARK; dTARGET;
2039 #ifdef USE_LOCALE_NUMERIC
2040 if (op->op_private & OPpLOCALE)
2041 SET_NUMERIC_LOCAL();
2043 SET_NUMERIC_STANDARD();
2045 do_sprintf(TARG, SP-MARK, MARK+1);
2046 TAINT_IF(SvTAINTED(TARG));
2060 value = (I32) (*tmps & 255);
2065 value = (I32) (anum & 255);
2076 (void)SvUPGRADE(TARG,SVt_PV);
2082 (void)SvPOK_only(TARG);
2089 djSP; dTARGET; dPOPTOPssrl;
2091 char *tmps = SvPV(left, na);
2093 sv_setpv(TARG, fcrypt(tmps, SvPV(right, na)));
2095 sv_setpv(TARG, crypt(tmps, SvPV(right, na)));
2099 "The crypt() function is unimplemented due to excessive paranoia.");
2111 if (!SvPADTMP(sv)) {
2117 s = SvPV_force(sv, na);
2119 if (op->op_private & OPpLOCALE) {
2122 *s = toUPPER_LC(*s);
2137 if (!SvPADTMP(sv)) {
2143 s = SvPV_force(sv, na);
2145 if (op->op_private & OPpLOCALE) {
2148 *s = toLOWER_LC(*s);
2165 if (!SvPADTMP(sv)) {
2172 s = SvPV_force(sv, len);
2174 register char *send = s + len;
2176 if (op->op_private & OPpLOCALE) {
2179 for (; s < send; s++)
2180 *s = toUPPER_LC(*s);
2183 for (; s < send; s++)
2197 if (!SvPADTMP(sv)) {
2204 s = SvPV_force(sv, len);
2206 register char *send = s + len;
2208 if (op->op_private & OPpLOCALE) {
2211 for (; s < send; s++)
2212 *s = toLOWER_LC(*s);
2215 for (; s < send; s++)
2227 register char *s = SvPV(sv,len);
2231 (void)SvUPGRADE(TARG, SVt_PV);
2232 SvGROW(TARG, (len * 2) + 1);
2240 SvCUR_set(TARG, d - SvPVX(TARG));
2241 (void)SvPOK_only(TARG);
2244 sv_setpvn(TARG, s, len);
2253 djSP; dMARK; dORIGMARK;
2255 register AV* av = (AV*)POPs;
2256 register I32 lval = op->op_flags & OPf_MOD;
2257 I32 arybase = curcop->cop_arybase;
2260 if (SvTYPE(av) == SVt_PVAV) {
2261 if (lval && op->op_private & OPpLVAL_INTRO) {
2263 for (svp = MARK + 1; svp <= SP; svp++) {
2268 if (max > AvMAX(av))
2271 while (++MARK <= SP) {
2272 elem = SvIVx(*MARK);
2276 svp = av_fetch(av, elem, lval);
2278 if (!svp || *svp == &sv_undef)
2279 DIE(no_aelem, elem);
2280 if (op->op_private & OPpLVAL_INTRO)
2281 save_aelem(av, elem, svp);
2283 *MARK = svp ? *svp : &sv_undef;
2286 if (GIMME != G_ARRAY) {
2294 /* Associative arrays. */
2299 HV *hash = (HV*)POPs;
2301 I32 gimme = GIMME_V;
2302 I32 realhv = (SvTYPE(hash) == SVt_PVHV);
2305 /* might clobber stack_sp */
2306 entry = realhv ? hv_iternext(hash) : avhv_iternext((AV*)hash);
2311 PUSHs(hv_iterkeysv(entry)); /* won't clobber stack_sp */
2312 if (gimme == G_ARRAY) {
2314 /* might clobber stack_sp */
2315 sv_setsv(TARG, realhv ?
2316 hv_iterval(hash, entry) : avhv_iterval((AV*)hash, entry));
2321 else if (gimme == G_SCALAR)
2340 I32 gimme = GIMME_V;
2341 I32 discard = (gimme == G_VOID) ? G_DISCARD : 0;
2345 if (op->op_private & OPpSLICE) {
2349 hvtype = SvTYPE(hv);
2350 while (++MARK <= SP) {
2351 if (hvtype == SVt_PVHV)
2352 sv = hv_delete_ent(hv, *MARK, discard, 0);
2354 DIE("Not a HASH reference");
2355 *MARK = sv ? sv : &sv_undef;
2359 else if (gimme == G_SCALAR) {
2368 if (SvTYPE(hv) == SVt_PVHV)
2369 sv = hv_delete_ent(hv, keysv, discard, 0);
2371 DIE("Not a HASH reference");
2385 if (SvTYPE(hv) == SVt_PVHV) {
2386 if (hv_exists_ent(hv, tmpsv, 0))
2388 } else if (SvTYPE(hv) == SVt_PVAV) {
2389 if (avhv_exists_ent((AV*)hv, tmpsv, 0))
2392 DIE("Not a HASH reference");
2399 djSP; dMARK; dORIGMARK;
2400 register HV *hv = (HV*)POPs;
2401 register I32 lval = op->op_flags & OPf_MOD;
2402 I32 realhv = (SvTYPE(hv) == SVt_PVHV);
2404 if (realhv || SvTYPE(hv) == SVt_PVAV) {
2405 while (++MARK <= SP) {
2409 HE *he = hv_fetch_ent(hv, keysv, lval, 0);
2410 svp = he ? &HeVAL(he) : 0;
2412 svp = avhv_fetch_ent((AV*)hv, keysv, lval, 0);
2415 if (!svp || *svp == &sv_undef)
2416 DIE(no_helem, SvPV(keysv, na));
2417 if (op->op_private & OPpLVAL_INTRO)
2418 save_helem(hv, keysv, svp);
2420 *MARK = svp ? *svp : &sv_undef;
2423 if (GIMME != G_ARRAY) {
2431 /* List operators. */
2436 if (GIMME != G_ARRAY) {
2438 *MARK = *SP; /* unwanted list, return last item */
2449 SV **lastrelem = stack_sp;
2450 SV **lastlelem = stack_base + POPMARK;
2451 SV **firstlelem = stack_base + POPMARK + 1;
2452 register SV **firstrelem = lastlelem + 1;
2453 I32 arybase = curcop->cop_arybase;
2454 I32 lval = op->op_flags & OPf_MOD;
2455 I32 is_something_there = lval;
2457 register I32 max = lastrelem - lastlelem;
2458 register SV **lelem;
2461 if (GIMME != G_ARRAY) {
2462 ix = SvIVx(*lastlelem);
2467 if (ix < 0 || ix >= max)
2468 *firstlelem = &sv_undef;
2470 *firstlelem = firstrelem[ix];
2476 SP = firstlelem - 1;
2480 for (lelem = firstlelem; lelem <= lastlelem; lelem++) {
2486 else if (!(*lelem = firstrelem[ix]))
2491 if (ix >= max || !(*lelem = firstrelem[ix]))
2494 if (!is_something_there && (SvOK(*lelem) || SvGMAGICAL(*lelem)))
2495 is_something_there = TRUE;
2497 if (is_something_there)
2500 SP = firstlelem - 1;
2506 djSP; dMARK; dORIGMARK;
2507 I32 items = SP - MARK;
2508 SV *av = sv_2mortal((SV*)av_make(items, MARK+1));
2509 SP = ORIGMARK; /* av_make() might realloc stack_sp */
2516 djSP; dMARK; dORIGMARK;
2517 HV* hv = (HV*)sv_2mortal((SV*)newHV());
2521 SV *val = NEWSV(46, 0);
2523 sv_setsv(val, *++MARK);
2525 warn("Odd number of elements in hash assignment");
2526 (void)hv_store_ent(hv,key,val,0);
2535 djSP; dMARK; dORIGMARK;
2536 register AV *ary = (AV*)*++MARK;
2540 register I32 offset;
2541 register I32 length;
2548 if (SvRMAGICAL(ary) && (mg = mg_find((SV*)ary,'P'))) {
2549 *MARK-- = mg->mg_obj;
2553 perl_call_method("SPLICE",GIMME_V);
2562 offset = i = SvIVx(*MARK);
2564 offset += AvFILLp(ary) + 1;
2566 offset -= curcop->cop_arybase;
2570 length = SvIVx(*MARK++);
2572 length += AvFILLp(ary) - offset + 1;
2578 length = AvMAX(ary) + 1; /* close enough to infinity */
2582 length = AvMAX(ary) + 1;
2584 if (offset > AvFILLp(ary) + 1)
2585 offset = AvFILLp(ary) + 1;
2586 after = AvFILLp(ary) + 1 - (offset + length);
2587 if (after < 0) { /* not that much array */
2588 length += after; /* offset+length now in array */
2594 /* At this point, MARK .. SP-1 is our new LIST */
2597 diff = newlen - length;
2598 if (newlen && !AvREAL(ary)) {
2602 assert(AvREAL(ary)); /* would leak, so croak */
2605 if (diff < 0) { /* shrinking the area */
2607 New(451, tmparyval, newlen, SV*); /* so remember insertion */
2608 Copy(MARK, tmparyval, newlen, SV*);
2611 MARK = ORIGMARK + 1;
2612 if (GIMME == G_ARRAY) { /* copy return vals to stack */
2613 MEXTEND(MARK, length);
2614 Copy(AvARRAY(ary)+offset, MARK, length, SV*);
2616 EXTEND_MORTAL(length);
2617 for (i = length, dst = MARK; i; i--) {
2618 sv_2mortal(*dst); /* free them eventualy */
2625 *MARK = AvARRAY(ary)[offset+length-1];
2628 for (i = length - 1, dst = &AvARRAY(ary)[offset]; i > 0; i--)
2629 SvREFCNT_dec(*dst++); /* free them now */
2632 AvFILLp(ary) += diff;
2634 /* pull up or down? */
2636 if (offset < after) { /* easier to pull up */
2637 if (offset) { /* esp. if nothing to pull */
2638 src = &AvARRAY(ary)[offset-1];
2639 dst = src - diff; /* diff is negative */
2640 for (i = offset; i > 0; i--) /* can't trust Copy */
2644 SvPVX(ary) = (char*)(AvARRAY(ary) - diff); /* diff is negative */
2648 if (after) { /* anything to pull down? */
2649 src = AvARRAY(ary) + offset + length;
2650 dst = src + diff; /* diff is negative */
2651 Move(src, dst, after, SV*);
2653 dst = &AvARRAY(ary)[AvFILLp(ary)+1];
2654 /* avoid later double free */
2658 dst[--i] = &sv_undef;
2661 for (src = tmparyval, dst = AvARRAY(ary) + offset;
2663 *dst = NEWSV(46, 0);
2664 sv_setsv(*dst++, *src++);
2666 Safefree(tmparyval);
2669 else { /* no, expanding (or same) */
2671 New(452, tmparyval, length, SV*); /* so remember deletion */
2672 Copy(AvARRAY(ary)+offset, tmparyval, length, SV*);
2675 if (diff > 0) { /* expanding */
2677 /* push up or down? */
2679 if (offset < after && diff <= AvARRAY(ary) - AvALLOC(ary)) {
2683 Move(src, dst, offset, SV*);
2685 SvPVX(ary) = (char*)(AvARRAY(ary) - diff);/* diff is positive */
2687 AvFILLp(ary) += diff;
2690 if (AvFILLp(ary) + diff >= AvMAX(ary)) /* oh, well */
2691 av_extend(ary, AvFILLp(ary) + diff);
2692 AvFILLp(ary) += diff;
2695 dst = AvARRAY(ary) + AvFILLp(ary);
2697 for (i = after; i; i--) {
2704 for (src = MARK, dst = AvARRAY(ary) + offset; newlen; newlen--) {
2705 *dst = NEWSV(46, 0);
2706 sv_setsv(*dst++, *src++);
2708 MARK = ORIGMARK + 1;
2709 if (GIMME == G_ARRAY) { /* copy return vals to stack */
2711 Copy(tmparyval, MARK, length, SV*);
2713 EXTEND_MORTAL(length);
2714 for (i = length, dst = MARK; i; i--) {
2715 sv_2mortal(*dst); /* free them eventualy */
2719 Safefree(tmparyval);
2723 else if (length--) {
2724 *MARK = tmparyval[length];
2727 while (length-- > 0)
2728 SvREFCNT_dec(tmparyval[length]);
2730 Safefree(tmparyval);
2741 djSP; dMARK; dORIGMARK; dTARGET;
2742 register AV *ary = (AV*)*++MARK;
2743 register SV *sv = &sv_undef;
2746 if (SvRMAGICAL(ary) && (mg = mg_find((SV*)ary,'P'))) {
2747 *MARK-- = mg->mg_obj;
2751 perl_call_method("PUSH",G_SCALAR|G_DISCARD);
2756 /* Why no pre-extend of ary here ? */
2757 for (++MARK; MARK <= SP; MARK++) {
2760 sv_setsv(sv, *MARK);
2765 PUSHi( AvFILL(ary) + 1 );
2773 SV *sv = av_pop(av);
2775 (void)sv_2mortal(sv);
2784 SV *sv = av_shift(av);
2789 (void)sv_2mortal(sv);
2796 djSP; dMARK; dORIGMARK; dTARGET;
2797 register AV *ary = (AV*)*++MARK;
2802 if (SvRMAGICAL(ary) && (mg = mg_find((SV*)ary,'P'))) {
2803 *MARK-- = mg->mg_obj;
2807 perl_call_method("UNSHIFT",G_SCALAR|G_DISCARD);
2812 av_unshift(ary, SP - MARK);
2815 sv_setsv(sv, *++MARK);
2816 (void)av_store(ary, i++, sv);
2820 PUSHi( AvFILL(ary) + 1 );
2830 if (GIMME == G_ARRAY) {
2841 register char *down;
2847 do_join(TARG, &sv_no, MARK, SP);
2849 sv_setsv(TARG, (SP > MARK) ? *SP : DEFSV);
2850 up = SvPV_force(TARG, len);
2852 down = SvPVX(TARG) + len - 1;
2858 (void)SvPOK_only(TARG);
2867 mul128(SV *sv, U8 m)
2870 char *s = SvPV(sv, len);
2874 if (!strnEQ(s, "0000", 4)) { /* need to grow sv */
2875 SV *tmpNew = newSVpv("0000000000", 10);
2877 sv_catsv(tmpNew, sv);
2878 SvREFCNT_dec(sv); /* free old sv */
2883 while (!*t) /* trailing '\0'? */
2886 i = ((*t - '0') << 7) + m;
2887 *(t--) = '0' + (i % 10);
2893 /* Explosives and implosives. */
2900 I32 gimme = GIMME_V;
2904 register char *pat = SvPV(left, llen);
2905 register char *s = SvPV(right, rlen);
2906 char *strend = s + rlen;
2908 register char *patend = pat + llen;
2913 /* These must not be in registers: */
2924 unsigned Quad_t auquad;
2930 register U32 culong;
2932 static char* bitcount = 0;
2935 if (gimme != G_ARRAY) { /* arrange to do first one only */
2937 for (patend = pat; !isALPHA(*patend) || *patend == 'x'; patend++) ;
2938 if (strchr("aAbBhHP", *patend) || *pat == '%') {
2940 while (isDIGIT(*patend) || *patend == '*')
2946 while (pat < patend) {
2948 datumtype = *pat++ & 0xFF;
2949 if (isSPACE(datumtype))
2953 else if (*pat == '*') {
2954 len = strend - strbeg; /* long enough */
2957 else if (isDIGIT(*pat)) {
2959 while (isDIGIT(*pat))
2960 len = (len * 10) + (*pat++ - '0');
2963 len = (datumtype != '@');
2966 croak("Invalid type in unpack: '%c'", (int)datumtype);
2967 case ',': /* grandfather in commas but with a warning */
2968 if (commas++ == 0 && dowarn)
2969 warn("Invalid type in unpack: '%c'", (int)datumtype);
2972 if (len == 1 && pat[-1] != '1')
2981 if (len > strend - strbeg)
2982 DIE("@ outside of string");
2986 if (len > s - strbeg)
2987 DIE("X outside of string");
2991 if (len > strend - s)
2992 DIE("x outside of string");
2997 if (len > strend - s)
3000 goto uchar_checksum;
3001 sv = NEWSV(35, len);
3002 sv_setpvn(sv, s, len);
3004 if (datumtype == 'A') {
3005 aptr = s; /* borrow register */
3006 s = SvPVX(sv) + len - 1;
3007 while (s >= SvPVX(sv) && (!*s || isSPACE(*s)))
3010 SvCUR_set(sv, s - SvPVX(sv));
3011 s = aptr; /* unborrow register */
3013 XPUSHs(sv_2mortal(sv));
3017 if (pat[-1] == '*' || len > (strend - s) * 8)
3018 len = (strend - s) * 8;
3021 Newz(601, bitcount, 256, char);
3022 for (bits = 1; bits < 256; bits++) {
3023 if (bits & 1) bitcount[bits]++;
3024 if (bits & 2) bitcount[bits]++;
3025 if (bits & 4) bitcount[bits]++;
3026 if (bits & 8) bitcount[bits]++;
3027 if (bits & 16) bitcount[bits]++;
3028 if (bits & 32) bitcount[bits]++;
3029 if (bits & 64) bitcount[bits]++;
3030 if (bits & 128) bitcount[bits]++;
3034 culong += bitcount[*(unsigned char*)s++];
3039 if (datumtype == 'b') {
3041 if (bits & 1) culong++;
3047 if (bits & 128) culong++;
3054 sv = NEWSV(35, len + 1);
3057 aptr = pat; /* borrow register */
3059 if (datumtype == 'b') {
3061 for (len = 0; len < aint; len++) {
3062 if (len & 7) /*SUPPRESS 595*/
3066 *pat++ = '0' + (bits & 1);
3071 for (len = 0; len < aint; len++) {
3076 *pat++ = '0' + ((bits & 128) != 0);
3080 pat = aptr; /* unborrow register */
3081 XPUSHs(sv_2mortal(sv));
3085 if (pat[-1] == '*' || len > (strend - s) * 2)
3086 len = (strend - s) * 2;
3087 sv = NEWSV(35, len + 1);
3090 aptr = pat; /* borrow register */
3092 if (datumtype == 'h') {
3094 for (len = 0; len < aint; len++) {
3099 *pat++ = hexdigit[bits & 15];
3104 for (len = 0; len < aint; len++) {
3109 *pat++ = hexdigit[(bits >> 4) & 15];
3113 pat = aptr; /* unborrow register */
3114 XPUSHs(sv_2mortal(sv));
3117 if (len > strend - s)
3122 if (aint >= 128) /* fake up signed chars */
3132 if (aint >= 128) /* fake up signed chars */
3135 sv_setiv(sv, (IV)aint);
3136 PUSHs(sv_2mortal(sv));
3141 if (len > strend - s)
3156 sv_setiv(sv, (IV)auint);
3157 PUSHs(sv_2mortal(sv));
3162 along = (strend - s) / SIZE16;
3179 sv_setiv(sv, (IV)ashort);
3180 PUSHs(sv_2mortal(sv));
3187 along = (strend - s) / SIZE16;
3192 COPY16(s, &aushort);
3195 if (datumtype == 'n')
3196 aushort = PerlSock_ntohs(aushort);
3199 if (datumtype == 'v')
3200 aushort = vtohs(aushort);
3209 COPY16(s, &aushort);
3213 if (datumtype == 'n')
3214 aushort = PerlSock_ntohs(aushort);
3217 if (datumtype == 'v')
3218 aushort = vtohs(aushort);
3220 sv_setiv(sv, (IV)aushort);
3221 PUSHs(sv_2mortal(sv));
3226 along = (strend - s) / sizeof(int);
3231 Copy(s, &aint, 1, int);
3234 cdouble += (double)aint;
3243 Copy(s, &aint, 1, int);
3247 /* Without the dummy below unpack("i", pack("i",-1))
3248 * return 0xFFffFFff instead of -1 for Digital Unix V4.0
3249 * cc with optimization turned on */
3251 sv_setiv(sv, (IV)aint) :
3253 sv_setiv(sv, (IV)aint);
3254 PUSHs(sv_2mortal(sv));
3259 along = (strend - s) / sizeof(unsigned int);
3264 Copy(s, &auint, 1, unsigned int);
3265 s += sizeof(unsigned int);
3267 cdouble += (double)auint;
3276 Copy(s, &auint, 1, unsigned int);
3277 s += sizeof(unsigned int);
3279 sv_setuv(sv, (UV)auint);
3280 PUSHs(sv_2mortal(sv));
3285 along = (strend - s) / SIZE32;
3293 cdouble += (double)along;
3305 sv_setiv(sv, (IV)along);
3306 PUSHs(sv_2mortal(sv));
3313 along = (strend - s) / SIZE32;
3321 if (datumtype == 'N')
3322 aulong = PerlSock_ntohl(aulong);
3325 if (datumtype == 'V')
3326 aulong = vtohl(aulong);
3329 cdouble += (double)aulong;
3341 if (datumtype == 'N')
3342 aulong = PerlSock_ntohl(aulong);
3345 if (datumtype == 'V')
3346 aulong = vtohl(aulong);
3349 sv_setuv(sv, (UV)aulong);
3350 PUSHs(sv_2mortal(sv));
3355 along = (strend - s) / sizeof(char*);
3361 if (sizeof(char*) > strend - s)
3364 Copy(s, &aptr, 1, char*);
3370 PUSHs(sv_2mortal(sv));
3380 while ((len > 0) && (s < strend)) {
3381 auv = (auv << 7) | (*s & 0x7f);
3382 if (!(*s++ & 0x80)) {
3386 PUSHs(sv_2mortal(sv));
3390 else if (++bytes >= sizeof(UV)) { /* promote to string */
3393 sv = newSVpvf("%.*Vu", (int)TYPE_DIGITS(UV), auv);
3394 while (s < strend) {
3395 sv = mul128(sv, *s & 0x7f);
3396 if (!(*s++ & 0x80)) {
3405 PUSHs(sv_2mortal(sv));
3410 if ((s >= strend) && bytes)
3411 croak("Unterminated compressed integer");
3416 if (sizeof(char*) > strend - s)
3419 Copy(s, &aptr, 1, char*);
3424 sv_setpvn(sv, aptr, len);
3425 PUSHs(sv_2mortal(sv));
3429 along = (strend - s) / sizeof(Quad_t);
3435 if (s + sizeof(Quad_t) > strend)
3438 Copy(s, &aquad, 1, Quad_t);
3439 s += sizeof(Quad_t);
3442 if (aquad >= IV_MIN && aquad <= IV_MAX)
3443 sv_setiv(sv, (IV)aquad);
3445 sv_setnv(sv, (double)aquad);
3446 PUSHs(sv_2mortal(sv));
3450 along = (strend - s) / sizeof(Quad_t);
3456 if (s + sizeof(unsigned Quad_t) > strend)
3459 Copy(s, &auquad, 1, unsigned Quad_t);
3460 s += sizeof(unsigned Quad_t);
3463 if (auquad <= UV_MAX)
3464 sv_setuv(sv, (UV)auquad);
3466 sv_setnv(sv, (double)auquad);
3467 PUSHs(sv_2mortal(sv));
3471 /* float and double added gnb@melba.bby.oz.au 22/11/89 */
3474 along = (strend - s) / sizeof(float);
3479 Copy(s, &afloat, 1, float);
3488 Copy(s, &afloat, 1, float);
3491 sv_setnv(sv, (double)afloat);
3492 PUSHs(sv_2mortal(sv));
3498 along = (strend - s) / sizeof(double);
3503 Copy(s, &adouble, 1, double);
3504 s += sizeof(double);
3512 Copy(s, &adouble, 1, double);
3513 s += sizeof(double);
3515 sv_setnv(sv, (double)adouble);
3516 PUSHs(sv_2mortal(sv));
3521 along = (strend - s) * 3 / 4;
3522 sv = NEWSV(42, along);
3525 while (s < strend && *s > ' ' && *s < 'a') {
3530 len = (*s++ - ' ') & 077;
3532 if (s < strend && *s >= ' ')
3533 a = (*s++ - ' ') & 077;
3536 if (s < strend && *s >= ' ')
3537 b = (*s++ - ' ') & 077;
3540 if (s < strend && *s >= ' ')
3541 c = (*s++ - ' ') & 077;
3544 if (s < strend && *s >= ' ')
3545 d = (*s++ - ' ') & 077;
3548 hunk[0] = (a << 2) | (b >> 4);
3549 hunk[1] = (b << 4) | (c >> 2);
3550 hunk[2] = (c << 6) | d;
3551 sv_catpvn(sv, hunk, (len > 3) ? 3 : len);
3556 else if (s[1] == '\n') /* possible checksum byte */
3559 XPUSHs(sv_2mortal(sv));
3564 if (strchr("fFdD", datumtype) ||
3565 (checksum > 32 && strchr("iIlLN", datumtype)) ) {
3569 while (checksum >= 16) {
3573 while (checksum >= 4) {
3579 along = (1 << checksum) - 1;
3580 while (cdouble < 0.0)
3582 cdouble = modf(cdouble / adouble, &trouble) * adouble;
3583 sv_setnv(sv, cdouble);
3586 if (checksum < 32) {
3587 aulong = (1 << checksum) - 1;
3590 sv_setuv(sv, (UV)culong);
3592 XPUSHs(sv_2mortal(sv));
3596 if (SP == oldsp && gimme == G_SCALAR)
3602 doencodes(register SV *sv, register char *s, register I32 len)
3607 sv_catpvn(sv, hunk, 1);
3610 hunk[0] = ' ' + (077 & (*s >> 2));
3611 hunk[1] = ' ' + (077 & (((*s << 4) & 060) | ((s[1] >> 4) & 017)));
3612 hunk[2] = ' ' + (077 & (((s[1] << 2) & 074) | ((s[2] >> 6) & 03)));
3613 hunk[3] = ' ' + (077 & (s[2] & 077));
3614 sv_catpvn(sv, hunk, 4);
3618 for (s = SvPVX(sv); *s; s++) {
3622 sv_catpvn(sv, "\n", 1);
3626 is_an_int(char *s, STRLEN l)
3628 SV *result = newSVpv("", l);
3629 char *result_c = SvPV(result, na); /* convenience */
3630 char *out = result_c;
3640 SvREFCNT_dec(result);
3663 SvREFCNT_dec(result);
3669 SvCUR_set(result, out - result_c);
3674 div128(SV *pnum, bool *done)
3675 /* must be '\0' terminated */
3679 char *s = SvPV(pnum, len);
3688 i = m * 10 + (*t - '0');
3690 r = (i >> 7); /* r < 10 */
3697 SvCUR_set(pnum, (STRLEN) (t - s));
3704 djSP; dMARK; dORIGMARK; dTARGET;
3705 register SV *cat = TARG;
3708 register char *pat = SvPVx(*++MARK, fromlen);
3709 register char *patend = pat + fromlen;
3714 static char null10[] = {0,0,0,0,0,0,0,0,0,0};
3715 static char *space10 = " ";
3717 /* These must not be in registers: */
3726 unsigned Quad_t auquad;
3735 sv_setpvn(cat, "", 0);
3736 while (pat < patend) {
3737 #define NEXTFROM (items-- > 0 ? *MARK++ : &sv_no)
3738 datumtype = *pat++ & 0xFF;
3739 if (isSPACE(datumtype))
3742 len = strchr("@Xxu", datumtype) ? 0 : items;
3745 else if (isDIGIT(*pat)) {
3747 while (isDIGIT(*pat))
3748 len = (len * 10) + (*pat++ - '0');
3754 croak("Invalid type in pack: '%c'", (int)datumtype);
3755 case ',': /* grandfather in commas but with a warning */
3756 if (commas++ == 0 && dowarn)
3757 warn("Invalid type in pack: '%c'", (int)datumtype);
3760 DIE("%% may only be used in unpack");
3771 if (SvCUR(cat) < len)
3772 DIE("X outside of string");
3779 sv_catpvn(cat, null10, 10);
3782 sv_catpvn(cat, null10, len);
3787 aptr = SvPV(fromstr, fromlen);
3791 sv_catpvn(cat, aptr, len);
3793 sv_catpvn(cat, aptr, fromlen);
3795 if (datumtype == 'A') {
3797 sv_catpvn(cat, space10, 10);
3800 sv_catpvn(cat, space10, len);
3804 sv_catpvn(cat, null10, 10);
3807 sv_catpvn(cat, null10, len);
3814 char *savepat = pat;
3819 aptr = SvPV(fromstr, fromlen);
3824 SvCUR(cat) += (len+7)/8;
3825 SvGROW(cat, SvCUR(cat) + 1);
3826 aptr = SvPVX(cat) + aint;
3831 if (datumtype == 'B') {
3832 for (len = 0; len++ < aint;) {
3833 items |= *pat++ & 1;
3837 *aptr++ = items & 0xff;
3843 for (len = 0; len++ < aint;) {
3849 *aptr++ = items & 0xff;
3855 if (datumtype == 'B')
3856 items <<= 7 - (aint & 7);
3858 items >>= 7 - (aint & 7);
3859 *aptr++ = items & 0xff;
3861 pat = SvPVX(cat) + SvCUR(cat);
3872 char *savepat = pat;
3877 aptr = SvPV(fromstr, fromlen);
3882 SvCUR(cat) += (len+1)/2;
3883 SvGROW(cat, SvCUR(cat) + 1);
3884 aptr = SvPVX(cat) + aint;
3889 if (datumtype == 'H') {
3890 for (len = 0; len++ < aint;) {
3892 items |= ((*pat++ & 15) + 9) & 15;
3894 items |= *pat++ & 15;
3898 *aptr++ = items & 0xff;
3904 for (len = 0; len++ < aint;) {
3906 items |= (((*pat++ & 15) + 9) & 15) << 4;
3908 items |= (*pat++ & 15) << 4;
3912 *aptr++ = items & 0xff;
3918 *aptr++ = items & 0xff;
3919 pat = SvPVX(cat) + SvCUR(cat);
3931 aint = SvIV(fromstr);
3933 sv_catpvn(cat, &achar, sizeof(char));
3936 /* Float and double added by gnb@melba.bby.oz.au 22/11/89 */
3941 afloat = (float)SvNV(fromstr);
3942 sv_catpvn(cat, (char *)&afloat, sizeof (float));
3949 adouble = (double)SvNV(fromstr);
3950 sv_catpvn(cat, (char *)&adouble, sizeof (double));
3956 ashort = (I16)SvIV(fromstr);
3958 ashort = PerlSock_htons(ashort);
3960 CAT16(cat, &ashort);
3966 ashort = (I16)SvIV(fromstr);
3968 ashort = htovs(ashort);
3970 CAT16(cat, &ashort);
3977 ashort = (I16)SvIV(fromstr);
3978 CAT16(cat, &ashort);
3984 auint = SvUV(fromstr);
3985 sv_catpvn(cat, (char*)&auint, sizeof(unsigned int));
3991 adouble = floor(SvNV(fromstr));
3994 croak("Cannot compress negative numbers");
4000 #ifdef CXUX_BROKEN_CONSTANT_CONVERT
4001 adouble <= UV_MAX_cxux
4008 char buf[1 + sizeof(UV)];
4009 char *in = buf + sizeof(buf);
4010 UV auv = U_V(adouble);;
4013 *--in = (auv & 0x7f) | 0x80;
4016 buf[sizeof(buf) - 1] &= 0x7f; /* clear continue bit */
4017 sv_catpvn(cat, in, (buf + sizeof(buf)) - in);
4019 else if (SvPOKp(fromstr)) { /* decimal string arithmetics */
4020 char *from, *result, *in;
4025 /* Copy string and check for compliance */
4026 from = SvPV(fromstr, len);
4027 if ((norm = is_an_int(from, len)) == NULL)
4028 croak("can compress only unsigned integer");
4030 New('w', result, len, char);
4034 *--in = div128(norm, &done) | 0x80;
4035 result[len - 1] &= 0x7F; /* clear continue bit */
4036 sv_catpvn(cat, in, (result + len) - in);
4038 SvREFCNT_dec(norm); /* free norm */
4040 else if (SvNOKp(fromstr)) {
4041 char buf[sizeof(double) * 2]; /* 8/7 <= 2 */
4042 char *in = buf + sizeof(buf);
4045 double next = floor(adouble / 128);
4046 *--in = (unsigned char)(adouble - (next * 128)) | 0x80;
4047 if (--in < buf) /* this cannot happen ;-) */
4048 croak ("Cannot compress integer");
4050 } while (adouble > 0);
4051 buf[sizeof(buf) - 1] &= 0x7f; /* clear continue bit */
4052 sv_catpvn(cat, in, (buf + sizeof(buf)) - in);
4055 croak("Cannot compress non integer");
4061 aint = SvIV(fromstr);
4062 sv_catpvn(cat, (char*)&aint, sizeof(int));
4068 aulong = SvUV(fromstr);
4070 aulong = PerlSock_htonl(aulong);
4072 CAT32(cat, &aulong);
4078 aulong = SvUV(fromstr);
4080 aulong = htovl(aulong);
4082 CAT32(cat, &aulong);
4088 aulong = SvUV(fromstr);
4089 CAT32(cat, &aulong);
4095 along = SvIV(fromstr);
4103 auquad = (unsigned Quad_t)SvIV(fromstr);
4104 sv_catpvn(cat, (char*)&auquad, sizeof(unsigned Quad_t));
4110 aquad = (Quad_t)SvIV(fromstr);
4111 sv_catpvn(cat, (char*)&aquad, sizeof(Quad_t));
4114 #endif /* HAS_QUAD */
4116 len = 1; /* assume SV is correct length */
4121 if (fromstr == &sv_undef)
4124 /* XXX better yet, could spirit away the string to
4125 * a safe spot and hang on to it until the result
4126 * of pack() (and all copies of the result) are
4129 if (dowarn && (SvTEMP(fromstr) || SvPADTMP(fromstr)))
4130 warn("Attempt to pack pointer to temporary value");
4131 if (SvPOK(fromstr) || SvNIOK(fromstr))
4132 aptr = SvPV(fromstr,na);
4134 aptr = SvPV_force(fromstr,na);
4136 sv_catpvn(cat, (char*)&aptr, sizeof(char*));
4141 aptr = SvPV(fromstr, fromlen);
4142 SvGROW(cat, fromlen * 4 / 3);
4147 while (fromlen > 0) {
4154 doencodes(cat, aptr, todo);
4173 register I32 limit = POPi; /* note, negative is forever */
4176 register char *s = SvPV(sv, len);
4177 char *strend = s + len;
4179 register REGEXP *rx;
4183 I32 maxiters = (strend - s) + 10;
4186 I32 origlimit = limit;
4189 AV *oldstack = curstack;
4190 I32 gimme = GIMME_V;
4191 I32 oldsave = savestack_ix;
4192 I32 make_mortal = 1;
4193 MAGIC *mg = (MAGIC *) NULL;
4196 Copy(&LvTARGOFF(POPs), &pm, 1, PMOP*);
4201 DIE("panic: do_split");
4202 rx = pm->op_pmregexp;
4204 TAINT_IF((pm->op_pmflags & PMf_LOCALE) &&
4205 (pm->op_pmflags & (PMf_WHITE | PMf_SKIPWHITE)));
4207 if (pm->op_pmreplroot)
4208 ary = GvAVn((GV*)pm->op_pmreplroot);
4209 else if (gimme != G_ARRAY)
4211 ary = (AV*)curpad[0];
4214 #endif /* USE_THREADS */
4217 if (ary && (gimme != G_ARRAY || (pm->op_pmflags & PMf_ONCE))) {
4223 if (SvRMAGICAL(ary) && (mg = mg_find((SV *) ary, 'P'))) {
4230 for (i = AvFILLp(ary); i >= 0; i--)
4231 AvARRAY(ary)[i] = &sv_undef; /* don't free mere refs */
4233 /* temporarily switch stacks */
4234 SWITCHSTACK(curstack, ary);
4238 base = SP - stack_base;
4240 if (pm->op_pmflags & PMf_SKIPWHITE) {
4241 if (pm->op_pmflags & PMf_LOCALE) {
4242 while (isSPACE_LC(*s))
4250 if (pm->op_pmflags & (PMf_MULTILINE|PMf_SINGLELINE)) {
4252 multiline = pm->op_pmflags & PMf_MULTILINE;
4256 limit = maxiters + 2;
4257 if (pm->op_pmflags & PMf_WHITE) {
4260 while (m < strend &&
4261 !((pm->op_pmflags & PMf_LOCALE)
4262 ? isSPACE_LC(*m) : isSPACE(*m)))
4267 dstr = NEWSV(30, m-s);
4268 sv_setpvn(dstr, s, m-s);
4274 while (s < strend &&
4275 ((pm->op_pmflags & PMf_LOCALE)
4276 ? isSPACE_LC(*s) : isSPACE(*s)))
4280 else if (strEQ("^", rx->precomp)) {
4283 for (m = s; m < strend && *m != '\n'; m++) ;
4287 dstr = NEWSV(30, m-s);
4288 sv_setpvn(dstr, s, m-s);
4295 else if (rx->check_substr && !rx->nparens
4296 && (rx->reganch & ROPT_CHECK_ALL)
4297 && !(rx->reganch & ROPT_ANCH)) {
4298 i = SvCUR(rx->check_substr);
4299 if (i == 1 && !SvTAIL(rx->check_substr)) {
4300 i = *SvPVX(rx->check_substr);
4303 for (m = s; m < strend && *m != i; m++) ;
4306 dstr = NEWSV(30, m-s);
4307 sv_setpvn(dstr, s, m-s);
4316 while (s < strend && --limit &&
4317 (m=fbm_instr((unsigned char*)s, (unsigned char*)strend,
4318 rx->check_substr, 0)) )
4321 dstr = NEWSV(31, m-s);
4322 sv_setpvn(dstr, s, m-s);
4331 maxiters += (strend - s) * rx->nparens;
4332 while (s < strend && --limit &&
4333 CALLREGEXEC(rx, s, strend, orig, 1, Nullsv, NULL, 0))
4335 TAINT_IF(RX_MATCH_TAINTED(rx));
4337 && rx->subbase != orig) {
4342 strend = s + (strend - m);
4345 dstr = NEWSV(32, m-s);
4346 sv_setpvn(dstr, s, m-s);
4351 for (i = 1; i <= rx->nparens; i++) {
4355 dstr = NEWSV(33, m-s);
4356 sv_setpvn(dstr, s, m-s);
4359 dstr = NEWSV(33, 0);
4369 LEAVE_SCOPE(oldsave);
4370 iters = (SP - stack_base) - base;
4371 if (iters > maxiters)
4374 /* keep field after final delim? */
4375 if (s < strend || (iters && origlimit)) {
4376 dstr = NEWSV(34, strend-s);
4377 sv_setpvn(dstr, s, strend-s);
4383 else if (!origlimit) {
4384 while (iters > 0 && (!TOPs || !SvANY(TOPs) || SvCUR(TOPs) == 0))
4390 SWITCHSTACK(ary, oldstack);
4391 if (SvSMAGICAL(ary)) {
4396 if (gimme == G_ARRAY) {
4398 Copy(AvARRAY(ary), SP + 1, iters, SV*);
4406 perl_call_method("PUSH",G_SCALAR|G_DISCARD);
4409 if (gimme == G_ARRAY) {
4410 /* EXTEND should not be needed - we just popped them */
4412 for (i=0; i < iters; i++) {
4413 SV **svp = av_fetch(ary, i, FALSE);
4414 PUSHs((svp) ? *svp : &sv_undef);
4421 if (gimme == G_ARRAY)
4424 if (iters || !pm->op_pmreplroot) {
4434 unlock_condpair(void *svv)
4437 MAGIC *mg = mg_find((SV*)svv, 'm');
4440 croak("panic: unlock_condpair unlocking non-mutex");
4441 MUTEX_LOCK(MgMUTEXP(mg));
4442 if (MgOWNER(mg) != thr)
4443 croak("panic: unlock_condpair unlocking mutex that we don't own");
4445 COND_SIGNAL(MgOWNERCONDP(mg));
4446 DEBUG_L(PerlIO_printf(PerlIO_stderr(), "0x%lx: unlock 0x%lx\n",
4447 (unsigned long)thr, (unsigned long)svv);)
4448 MUTEX_UNLOCK(MgMUTEXP(mg));
4450 #endif /* USE_THREADS */
4463 mg = condpair_magic(sv);
4464 MUTEX_LOCK(MgMUTEXP(mg));
4465 if (MgOWNER(mg) == thr)
4466 MUTEX_UNLOCK(MgMUTEXP(mg));
4469 COND_WAIT(MgOWNERCONDP(mg), MgMUTEXP(mg));
4471 DEBUG_L(PerlIO_printf(PerlIO_stderr(), "0x%lx: pp_lock lock 0x%lx\n",
4472 (unsigned long)thr, (unsigned long)sv);)
4473 MUTEX_UNLOCK(MgMUTEXP(mg));
4474 SvREFCNT_inc(sv); /* keep alive until magic_mutexfree */
4475 save_destructor(unlock_condpair, sv);
4477 #endif /* USE_THREADS */
4478 if (SvTYPE(retsv) == SVt_PVAV || SvTYPE(retsv) == SVt_PVHV
4479 || SvTYPE(retsv) == SVt_PVCV) {
4480 retsv = refto(retsv);
4491 if (op->op_private & OPpLVAL_INTRO)
4492 PUSHs(*save_threadsv(op->op_targ));
4494 PUSHs(THREADSV(op->op_targ));
4497 DIE("tried to access per-thread data in non-threaded perl");
4498 #endif /* USE_THREADS */