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)
104 static void doencodes _((SV* sv, char* s, I32 len));
105 static SV* refto _((SV* sv));
106 static U32 seed _((void));
108 static bool srand_called = FALSE;
110 /* variations on pp_null */
116 /* XXX I can't imagine anyone who doesn't have this actually _needs_
117 it, since pid_t is an integral type.
120 #ifdef NEED_GETPID_PROTO
121 extern Pid_t getpid (void);
127 if (GIMME_V == G_SCALAR)
142 if (op->op_private & OPpLVAL_INTRO)
143 SAVECLEARSV(curpad[op->op_targ]);
145 if (op->op_flags & OPf_REF) {
149 if (GIMME == G_ARRAY) {
150 I32 maxarg = AvFILL((AV*)TARG) + 1;
152 if (SvMAGICAL(TARG)) {
154 for (i=0; i < maxarg; i++) {
155 SV **svp = av_fetch((AV*)TARG, i, FALSE);
156 SP[i+1] = (svp) ? *svp : &sv_undef;
160 Copy(AvARRAY((AV*)TARG), SP+1, maxarg, SV*);
165 SV* sv = sv_newmortal();
166 I32 maxarg = AvFILL((AV*)TARG) + 1;
167 sv_setiv(sv, maxarg);
179 if (op->op_private & OPpLVAL_INTRO)
180 SAVECLEARSV(curpad[op->op_targ]);
181 if (op->op_flags & OPf_REF)
184 if (gimme == G_ARRAY) {
185 RETURNOP(do_kv(ARGS));
187 else if (gimme == G_SCALAR) {
188 SV* sv = sv_newmortal();
189 if (HvFILL((HV*)TARG))
190 sv_setpvf(sv, "%ld/%ld",
191 (long)HvFILL((HV*)TARG), (long)HvMAX((HV*)TARG) + 1);
201 DIE("NOT IMPL LINE %d",__LINE__);
213 if (SvTYPE(sv) == SVt_PVIO) {
214 GV *gv = (GV*) sv_newmortal();
215 gv_init(gv, 0, "", 0, 0);
216 GvIOp(gv) = (IO *)sv;
217 (void)SvREFCNT_inc(sv);
219 } else if (SvTYPE(sv) != SVt_PVGV)
220 DIE("Not a GLOB reference");
223 if (SvTYPE(sv) != SVt_PVGV) {
226 if (SvGMAGICAL(sv)) {
232 if (op->op_flags & OPf_REF ||
233 op->op_private & HINT_STRICT_REFS)
234 DIE(no_usym, "a symbol");
240 if (op->op_private & HINT_STRICT_REFS)
241 DIE(no_symref, sym, "a symbol");
242 sv = (SV*)gv_fetchpv(sym, TRUE, SVt_PVGV);
245 if (op->op_private & OPpLVAL_INTRO)
246 save_gp((GV*)sv, !(op->op_flags & OPf_SPECIAL));
258 switch (SvTYPE(sv)) {
262 DIE("Not a SCALAR reference");
269 if (SvTYPE(gv) != SVt_PVGV) {
270 if (SvGMAGICAL(sv)) {
276 if (op->op_flags & OPf_REF ||
277 op->op_private & HINT_STRICT_REFS)
278 DIE(no_usym, "a SCALAR");
284 if (op->op_private & HINT_STRICT_REFS)
285 DIE(no_symref, sym, "a SCALAR");
286 gv = (GV*)gv_fetchpv(sym, TRUE, SVt_PV);
290 if (op->op_flags & OPf_MOD) {
291 if (op->op_private & OPpLVAL_INTRO)
292 sv = save_scalar((GV*)TOPs);
293 else if (op->op_private & OPpDEREF)
294 vivify_ref(sv, op->op_private & OPpDEREF);
304 SV *sv = AvARYLEN(av);
306 AvARYLEN(av) = sv = NEWSV(0,0);
307 sv_upgrade(sv, SVt_IV);
308 sv_magic(sv, (SV*)av, '#', Nullch, 0);
316 djSP; dTARGET; dPOPss;
318 if (op->op_flags & OPf_MOD) {
319 if (SvTYPE(TARG) < SVt_PVLV) {
320 sv_upgrade(TARG, SVt_PVLV);
321 sv_magic(TARG, Nullsv, '.', Nullch, 0);
326 PUSHs(TARG); /* no SvSETMAGIC */
332 if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv)) {
333 mg = mg_find(sv, 'g');
334 if (mg && mg->mg_len >= 0) {
335 PUSHi(mg->mg_len + curcop->cop_arybase);
349 /* We usually try to add a non-existent subroutine in case of AUTOLOAD. */
350 /* (But not in defined().) */
351 CV *cv = sv_2cv(TOPs, &stash, &gv, !(op->op_flags & OPf_SPECIAL));
354 cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
371 if (SvPOK(TOPs) && SvCUR(TOPs) >= 7) {
372 char *s = SvPVX(TOPs);
373 if (strnEQ(s, "CORE::", 6)) {
376 code = keyword(s + 6, SvCUR(TOPs) - 6);
377 if (code < 0) { /* Overridable. */
378 #define MAX_ARGS_OP ((sizeof(I32) - 1) * 2)
379 int i = 0, n = 0, seen_question = 0;
381 char str[ MAX_ARGS_OP * 2 + 2 ]; /* One ';', one '\0' */
383 while (i < MAXO) { /* The slow way. */
384 if (strEQ(s + 6, op_name[i]) || strEQ(s + 6, op_desc[i]))
388 goto nonesuch; /* Should not happen... */
390 oa = opargs[i] >> OASHIFT;
392 if (oa & OA_OPTIONAL) {
395 } else if (seen_question)
396 goto set; /* XXXX system, exec */
397 if ((oa & (OA_OPTIONAL - 1)) >= OA_AVREF
398 && (oa & (OA_OPTIONAL - 1)) <= OA_HVREF) {
401 /* What to do with R ((un)tie, tied, (sys)read, recv)? */
402 str[n++] = ("?$@@%&*$")[oa & (OA_OPTIONAL - 1)];
406 ret = sv_2mortal(newSVpv(str, n - 1));
407 } else if (code) /* Non-Overridable */
409 else { /* None such */
411 croak("Cannot find an opnumber for \"%s\"", s+6);
415 cv = sv_2cv(TOPs, &stash, &gv, FALSE);
417 ret = sv_2mortal(newSVpv(SvPVX(cv), SvCUR(cv)));
426 CV* cv = (CV*)curpad[op->op_targ];
428 cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
444 if (GIMME != G_ARRAY) {
449 *MARK = refto(*MARK);
453 EXTEND_MORTAL(SP - MARK);
455 *MARK = refto(*MARK);
464 if (SvTYPE(sv) == SVt_PVLV && LvTYPE(sv) == 'y') {
467 if (!(sv = LvTARG(sv)))
470 else if (SvPADTMP(sv))
474 (void)SvREFCNT_inc(sv);
477 sv_upgrade(rv, SVt_RV);
491 if (sv && SvGMAGICAL(sv))
494 if (!sv || !SvROK(sv))
498 pv = sv_reftype(sv,TRUE);
499 PUSHp(pv, strlen(pv));
509 stash = curcop->cop_stash;
511 stash = gv_stashsv(POPs, TRUE);
513 (void)sv_bless(TOPs, stash);
530 switch (elem ? *elem : '\0')
533 if (strEQ(elem, "ARRAY"))
537 if (strEQ(elem, "CODE"))
538 ref = (SV*)GvCVu(gv);
541 if (strEQ(elem, "FILEHANDLE")) /* XXX deprecate in 5.005 */
542 ref = (SV*)GvIOp(gv);
545 if (strEQ(elem, "GLOB"))
549 if (strEQ(elem, "HASH"))
553 if (strEQ(elem, "IO"))
554 ref = (SV*)GvIOp(gv);
557 if (strEQ(elem, "NAME"))
558 sv = newSVpv(GvNAME(gv), GvNAMELEN(gv));
561 if (strEQ(elem, "PACKAGE"))
562 sv = newSVpv(HvNAME(GvSTASH(gv)), 0);
565 if (strEQ(elem, "SCALAR"))
579 /* Pattern matching */
584 register UNOP *unop = cUNOP;
585 register unsigned char *s;
588 register I32 *sfirst;
592 if(unop->op_first && unop->op_first->op_type == OP_PUSHRE) {
593 PMOP *pm = (PMOP *)unop->op_first;
594 SV *rv = sv_newmortal();
595 sv = newSVrv(rv, "Regexp");
596 sv_magic(sv,(SV*)ReREFCNT_inc(pm->op_pmregexp),'r',0,0);
600 if (sv == lastscream) {
606 SvSCREAM_off(lastscream);
607 SvREFCNT_dec(lastscream);
609 lastscream = SvREFCNT_inc(sv);
612 s = (unsigned char*)(SvPV(sv, len));
616 if (pos > maxscream) {
618 maxscream = pos + 80;
619 New(301, screamfirst, 256, I32);
620 New(302, screamnext, maxscream, I32);
623 maxscream = pos + pos / 4;
624 Renew(screamnext, maxscream, I32);
628 sfirst = screamfirst;
631 if (!sfirst || !snext)
632 DIE("do_study: out of memory");
634 for (ch = 256; ch; --ch)
641 snext[pos] = sfirst[ch] - pos;
648 sv_magic(sv, Nullsv, 'g', Nullch, 0); /* piggyback on m//g magic */
657 if (op->op_flags & OPf_STACKED)
663 TARG = sv_newmortal();
664 PUSHi(do_trans(sv, op));
668 /* Lvalue operators. */
680 djSP; dMARK; dTARGET;
690 SETi(do_chomp(TOPs));
696 djSP; dMARK; dTARGET;
697 register I32 count = 0;
700 count += do_chomp(POPs);
711 if (!sv || !SvANY(sv))
713 switch (SvTYPE(sv)) {
715 if (AvMAX(sv) >= 0 || SvGMAGICAL(sv))
719 if (HvARRAY(sv) || SvGMAGICAL(sv))
723 if (CvROOT(sv) || CvXSUB(sv))
740 if (!op->op_private) {
749 if (SvTHINKFIRST(sv)) {
756 switch (SvTYPE(sv)) {
766 if (cv_const_sv((CV*)sv))
767 warn("Constant subroutine %s undefined",
768 CvANON((CV*)sv) ? "(anonymous)" : GvENAME(CvGV((CV*)sv)));
771 { GV* gv = (GV*)SvREFCNT_inc(CvGV((CV*)sv));
773 CvGV((CV*)sv) = gv; } /* let user-undef'd sub keep its identity */
777 SvSetMagicSV(sv, &sv_undef);
781 Newz(602, gp, 1, GP);
782 GvGP(sv) = gp_ref(gp);
783 GvSV(sv) = NEWSV(72,0);
784 GvLINE(sv) = curcop->cop_line;
790 if (SvTYPE(sv) >= SVt_PV && SvPVX(sv) && SvLEN(sv)) {
793 SvPV_set(sv, Nullch);
806 if (SvREADONLY(TOPs) || SvTYPE(TOPs) > SVt_PVLV)
808 if (SvIOK(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs) &&
809 SvIVX(TOPs) != IV_MIN)
812 SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
823 if (SvREADONLY(TOPs) || SvTYPE(TOPs) > SVt_PVLV)
825 sv_setsv(TARG, TOPs);
826 if (SvIOK(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs) &&
827 SvIVX(TOPs) != IV_MAX)
830 SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
844 if(SvREADONLY(TOPs) || SvTYPE(TOPs) > SVt_PVLV)
846 sv_setsv(TARG, TOPs);
847 if (SvIOK(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs) &&
848 SvIVX(TOPs) != IV_MIN)
851 SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
860 /* Ordinary operators. */
864 djSP; dATARGET; tryAMAGICbin(pow,opASSIGN);
867 SETn( pow( left, right) );
874 djSP; dATARGET; tryAMAGICbin(mult,opASSIGN);
877 SETn( left * right );
884 djSP; dATARGET; tryAMAGICbin(div,opASSIGN);
889 DIE("Illegal division by zero");
891 /* insure that 20./5. == 4. */
894 if ((double)I_V(left) == left &&
895 (double)I_V(right) == right &&
896 (k = I_V(left)/I_V(right))*I_V(right) == I_V(left)) {
899 value = left / right;
903 value = left / right;
912 djSP; dATARGET; tryAMAGICbin(mod,opASSIGN);
920 if (SvIOK(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs)) {
922 right = (right_neg = (i < 0)) ? -i : i;
926 right = U_V((right_neg = (n < 0)) ? -n : n);
929 if (SvIOK(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs)) {
931 left = (left_neg = (i < 0)) ? -i : i;
935 left = U_V((left_neg = (n < 0)) ? -n : n);
939 DIE("Illegal modulus zero");
942 if ((left_neg != right_neg) && ans)
945 /* XXX may warn: unary minus operator applied to unsigned type */
946 /* could change -foo to be (~foo)+1 instead */
947 if (ans <= ~((UV)IV_MAX)+1)
948 sv_setiv(TARG, ~ans+1);
950 sv_setnv(TARG, -(double)ans);
961 djSP; dATARGET; tryAMAGICbin(repeat,opASSIGN);
963 register I32 count = POPi;
964 if (GIMME == G_ARRAY && op->op_private & OPpREPEAT_DOLIST) {
966 I32 items = SP - MARK;
978 repeatcpy((char*)(MARK + items), (char*)MARK,
979 items * sizeof(SV*), count - 1);
985 else { /* Note: mark already snarfed by pp_list */
990 if (TARG == tmpstr && SvTHINKFIRST(tmpstr)) {
991 if (SvREADONLY(tmpstr) && curcop != &compiling)
992 DIE("Can't x= to readonly value");
996 SvSetSV(TARG, tmpstr);
997 SvPV_force(TARG, len);
1002 SvGROW(TARG, (count * len) + 1);
1003 repeatcpy(SvPVX(TARG) + len, SvPVX(TARG), len, count - 1);
1004 SvCUR(TARG) *= count;
1006 *SvEND(TARG) = '\0';
1008 (void)SvPOK_only(TARG);
1017 djSP; dATARGET; tryAMAGICbin(subtr,opASSIGN);
1020 SETn( left - right );
1027 djSP; dATARGET; tryAMAGICbin(lshift,opASSIGN);
1030 if (op->op_private & HINT_INTEGER) {
1032 i = BWi(i) << shift;
1046 djSP; dATARGET; tryAMAGICbin(rshift,opASSIGN);
1049 if (op->op_private & HINT_INTEGER) {
1051 i = BWi(i) >> shift;
1065 djSP; tryAMAGICbinSET(lt,0);
1068 SETs(boolSV(TOPn < value));
1075 djSP; tryAMAGICbinSET(gt,0);
1078 SETs(boolSV(TOPn > value));
1085 djSP; tryAMAGICbinSET(le,0);
1088 SETs(boolSV(TOPn <= value));
1095 djSP; tryAMAGICbinSET(ge,0);
1098 SETs(boolSV(TOPn >= value));
1105 djSP; tryAMAGICbinSET(ne,0);
1108 SETs(boolSV(TOPn != value));
1115 djSP; dTARGET; tryAMAGICbin(ncmp,0);
1122 else if (left < right)
1124 else if (left > right)
1137 djSP; tryAMAGICbinSET(slt,0);
1140 int cmp = ((op->op_private & OPpLOCALE)
1141 ? sv_cmp_locale(left, right)
1142 : sv_cmp(left, right));
1143 SETs(boolSV(cmp < 0));
1150 djSP; tryAMAGICbinSET(sgt,0);
1153 int cmp = ((op->op_private & OPpLOCALE)
1154 ? sv_cmp_locale(left, right)
1155 : sv_cmp(left, right));
1156 SETs(boolSV(cmp > 0));
1163 djSP; tryAMAGICbinSET(sle,0);
1166 int cmp = ((op->op_private & OPpLOCALE)
1167 ? sv_cmp_locale(left, right)
1168 : sv_cmp(left, right));
1169 SETs(boolSV(cmp <= 0));
1176 djSP; tryAMAGICbinSET(sge,0);
1179 int cmp = ((op->op_private & OPpLOCALE)
1180 ? sv_cmp_locale(left, right)
1181 : sv_cmp(left, right));
1182 SETs(boolSV(cmp >= 0));
1189 djSP; tryAMAGICbinSET(seq,0);
1192 SETs(boolSV(sv_eq(left, right)));
1199 djSP; tryAMAGICbinSET(sne,0);
1202 SETs(boolSV(!sv_eq(left, right)));
1209 djSP; dTARGET; tryAMAGICbin(scmp,0);
1212 int cmp = ((op->op_private & OPpLOCALE)
1213 ? sv_cmp_locale(left, right)
1214 : sv_cmp(left, right));
1222 djSP; dATARGET; tryAMAGICbin(band,opASSIGN);
1225 if (SvNIOKp(left) || SvNIOKp(right)) {
1226 if (op->op_private & HINT_INTEGER) {
1227 IBW value = SvIV(left) & SvIV(right);
1231 UBW value = SvUV(left) & SvUV(right);
1236 do_vop(op->op_type, TARG, left, right);
1245 djSP; dATARGET; tryAMAGICbin(bxor,opASSIGN);
1248 if (SvNIOKp(left) || SvNIOKp(right)) {
1249 if (op->op_private & HINT_INTEGER) {
1250 IBW value = (USE_LEFT(left) ? SvIV(left) : 0) ^ SvIV(right);
1254 UBW value = (USE_LEFT(left) ? SvUV(left) : 0) ^ SvUV(right);
1259 do_vop(op->op_type, TARG, left, right);
1268 djSP; dATARGET; tryAMAGICbin(bor,opASSIGN);
1271 if (SvNIOKp(left) || SvNIOKp(right)) {
1272 if (op->op_private & HINT_INTEGER) {
1273 IBW value = (USE_LEFT(left) ? SvIV(left) : 0) | SvIV(right);
1277 UBW value = (USE_LEFT(left) ? SvUV(left) : 0) | SvUV(right);
1282 do_vop(op->op_type, TARG, left, right);
1291 djSP; dTARGET; tryAMAGICun(neg);
1296 if (SvIOKp(sv) && !SvNOKp(sv) && !SvPOKp(sv) && SvIVX(sv) != IV_MIN)
1298 else if (SvNIOKp(sv))
1300 else if (SvPOKp(sv)) {
1302 char *s = SvPV(sv, len);
1303 if (isIDFIRST(*s)) {
1304 sv_setpvn(TARG, "-", 1);
1307 else if (*s == '+' || *s == '-') {
1309 *SvPV_force(TARG, len) = *s == '-' ? '+' : '-';
1312 sv_setnv(TARG, -SvNV(sv));
1324 djSP; tryAMAGICunSET(not);
1325 #endif /* OVERLOAD */
1326 *stack_sp = boolSV(!SvTRUE(*stack_sp));
1332 djSP; dTARGET; tryAMAGICun(compl);
1336 if (op->op_private & HINT_INTEGER) {
1337 IBW value = ~SvIV(sv);
1341 UBW value = ~SvUV(sv);
1346 register char *tmps;
1347 register long *tmpl;
1352 tmps = SvPV_force(TARG, len);
1355 for ( ; anum && (unsigned long)tmps % sizeof(long); anum--, tmps++)
1358 for ( ; anum >= sizeof(long); anum -= sizeof(long), tmpl++)
1362 for ( ; anum > 0; anum--, tmps++)
1371 /* integer versions of some of the above */
1375 djSP; dATARGET; tryAMAGICbin(mult,opASSIGN);
1378 SETi( left * right );
1385 djSP; dATARGET; tryAMAGICbin(div,opASSIGN);
1389 DIE("Illegal division by zero");
1390 value = POPi / value;
1398 djSP; dATARGET; tryAMAGICbin(mod,opASSIGN);
1402 DIE("Illegal modulus zero");
1403 SETi( left % right );
1410 djSP; dATARGET; tryAMAGICbin(add,opASSIGN);
1413 SETi( left + right );
1420 djSP; dATARGET; tryAMAGICbin(subtr,opASSIGN);
1423 SETi( left - right );
1430 djSP; tryAMAGICbinSET(lt,0);
1433 SETs(boolSV(left < right));
1440 djSP; tryAMAGICbinSET(gt,0);
1443 SETs(boolSV(left > right));
1450 djSP; tryAMAGICbinSET(le,0);
1453 SETs(boolSV(left <= right));
1460 djSP; tryAMAGICbinSET(ge,0);
1463 SETs(boolSV(left >= right));
1470 djSP; tryAMAGICbinSET(eq,0);
1473 SETs(boolSV(left == right));
1480 djSP; tryAMAGICbinSET(ne,0);
1483 SETs(boolSV(left != right));
1490 djSP; dTARGET; tryAMAGICbin(ncmp,0);
1497 else if (left < right)
1508 djSP; dTARGET; tryAMAGICun(neg);
1513 /* High falutin' math. */
1517 djSP; dTARGET; tryAMAGICbin(atan2,0);
1520 SETn(atan2(left, right));
1527 djSP; dTARGET; tryAMAGICun(sin);
1539 djSP; dTARGET; tryAMAGICun(cos);
1559 if (!srand_called) {
1560 (void)srand((unsigned)seed());
1561 srand_called = TRUE;
1564 value = rand() * value / 2147483648.0;
1567 value = rand() * value / 65536.0;
1570 value = rand() * value / 32768.0;
1572 value = rand() * value / (double)(((unsigned long)1) << RANDBITS);
1588 (void)srand((unsigned)anum);
1589 srand_called = TRUE;
1598 * This is really just a quick hack which grabs various garbage
1599 * values. It really should be a real hash algorithm which
1600 * spreads the effect of every input bit onto every output bit,
1601 * if someone who knows about such tings would bother to write it.
1602 * Might be a good idea to add that function to CORE as well.
1603 * No numbers below come from careful analysis or anyting here,
1604 * except they are primes and SEED_C1 > 1E6 to get a full-width
1605 * value from (tv_sec * SEED_C1 + tv_usec). The multipliers should
1606 * probably be bigger too.
1609 # define SEED_C1 1000003
1610 #define SEED_C4 73819
1612 # define SEED_C1 25747
1613 #define SEED_C4 20639
1617 #define SEED_C5 26107
1622 # include <starlet.h>
1623 /* when[] = (low 32 bits, high 32 bits) of time since epoch
1624 * in 100-ns units, typically incremented ever 10 ms. */
1625 unsigned int when[2];
1626 _ckvmssts(sys$gettim(when));
1627 u = (U32)SEED_C1 * when[0] + (U32)SEED_C2 * when[1];
1629 # ifdef HAS_GETTIMEOFDAY
1630 struct timeval when;
1631 gettimeofday(&when,(struct timezone *) 0);
1632 u = (U32)SEED_C1 * when.tv_sec + (U32)SEED_C2 * when.tv_usec;
1636 u = (U32)SEED_C1 * when;
1639 u += SEED_C3 * (U32)getpid();
1640 u += SEED_C4 * (U32)(UV)stack_sp;
1641 #ifndef PLAN9 /* XXX Plan9 assembler chokes on this; fix needed */
1642 u += SEED_C5 * (U32)(UV)&when;
1649 djSP; dTARGET; tryAMAGICun(exp);
1661 djSP; dTARGET; tryAMAGICun(log);
1666 SET_NUMERIC_STANDARD();
1667 DIE("Can't take log of %g", value);
1677 djSP; dTARGET; tryAMAGICun(sqrt);
1682 SET_NUMERIC_STANDARD();
1683 DIE("Can't take sqrt of %g", value);
1685 value = sqrt(value);
1695 double value = TOPn;
1698 if (SvIOKp(TOPs) && !SvNOKp(TOPs) && !SvPOKp(TOPs)) {
1704 (void)modf(value, &value);
1706 (void)modf(-value, &value);
1721 djSP; dTARGET; tryAMAGICun(abs);
1723 double value = TOPn;
1726 if (SvIOKp(TOPs) && !SvNOKp(TOPs) && !SvPOKp(TOPs) &&
1727 (iv = SvIVX(TOPs)) != IV_MIN) {
1748 XPUSHu(scan_hex(tmps, 99, &argtype));
1760 while (*tmps && isSPACE(*tmps))
1765 value = scan_hex(++tmps, 99, &argtype);
1767 value = scan_oct(tmps, 99, &argtype);
1777 SETi( sv_len(TOPs) );
1790 I32 lvalue = op->op_flags & OPf_MOD;
1792 I32 arybase = curcop->cop_arybase;
1794 SvTAINTED_off(TARG); /* decontaminate */
1800 tmps = SvPV(sv, curlen);
1801 if (pos >= arybase) {
1819 else if (len >= 0) {
1821 if (rem > (I32)curlen)
1835 if (dowarn || lvalue)
1836 warn("substr outside of string");
1841 sv_setpvn(TARG, tmps, rem);
1842 if (lvalue) { /* it's an lvalue! */
1843 if (!SvGMAGICAL(sv)) {
1847 warn("Attempt to use reference as lvalue in substr");
1849 if (SvOK(sv)) /* is it defined ? */
1850 (void)SvPOK_only(sv);
1852 sv_setpvn(sv,"",0); /* avoid lexical reincarnation */
1855 if (SvTYPE(TARG) < SVt_PVLV) {
1856 sv_upgrade(TARG, SVt_PVLV);
1857 sv_magic(TARG, Nullsv, 'x', Nullch, 0);
1862 LvTARGOFF(TARG) = pos;
1863 LvTARGLEN(TARG) = rem;
1867 PUSHs(TARG); /* avoid SvSETMAGIC here */
1874 register I32 size = POPi;
1875 register I32 offset = POPi;
1876 register SV *src = POPs;
1877 I32 lvalue = op->op_flags & OPf_MOD;
1879 unsigned char *s = (unsigned char*)SvPV(src, srclen);
1880 unsigned long retnum;
1883 SvTAINTED_off(TARG); /* decontaminate */
1884 offset *= size; /* turn into bit offset */
1885 len = (offset + size + 7) / 8;
1886 if (offset < 0 || size < 1)
1889 if (lvalue) { /* it's an lvalue! */
1890 if (SvTYPE(TARG) < SVt_PVLV) {
1891 sv_upgrade(TARG, SVt_PVLV);
1892 sv_magic(TARG, Nullsv, 'v', Nullch, 0);
1897 LvTARGOFF(TARG) = offset;
1898 LvTARGLEN(TARG) = size;
1906 if (offset >= srclen)
1909 retnum = (unsigned long) s[offset] << 8;
1911 else if (size == 32) {
1912 if (offset >= srclen)
1914 else if (offset + 1 >= srclen)
1915 retnum = (unsigned long) s[offset] << 24;
1916 else if (offset + 2 >= srclen)
1917 retnum = ((unsigned long) s[offset] << 24) +
1918 ((unsigned long) s[offset + 1] << 16);
1920 retnum = ((unsigned long) s[offset] << 24) +
1921 ((unsigned long) s[offset + 1] << 16) +
1922 (s[offset + 2] << 8);
1927 retnum = (s[offset >> 3] >> (offset & 7)) & ((1 << size) - 1);
1932 else if (size == 16)
1933 retnum = ((unsigned long) s[offset] << 8) + s[offset+1];
1934 else if (size == 32)
1935 retnum = ((unsigned long) s[offset] << 24) +
1936 ((unsigned long) s[offset + 1] << 16) +
1937 (s[offset + 2] << 8) + s[offset+3];
1941 sv_setuv(TARG, (UV)retnum);
1956 I32 arybase = curcop->cop_arybase;
1961 offset = POPi - arybase;
1964 tmps = SvPV(big, biglen);
1967 else if (offset > biglen)
1969 if (!(tmps2 = fbm_instr((unsigned char*)tmps + offset,
1970 (unsigned char*)tmps + biglen, little)))
1971 retval = -1 + arybase;
1973 retval = tmps2 - tmps + arybase;
1990 I32 arybase = curcop->cop_arybase;
1996 tmps2 = SvPV(little, llen);
1997 tmps = SvPV(big, blen);
2001 offset = SvIV(offstr) - arybase + llen;
2004 else if (offset > blen)
2006 if (!(tmps2 = rninstr(tmps, tmps + offset,
2007 tmps2, tmps2 + llen)))
2008 retval = -1 + arybase;
2010 retval = tmps2 - tmps + arybase;
2017 djSP; dMARK; dORIGMARK; dTARGET;
2018 #ifdef USE_LOCALE_NUMERIC
2019 if (op->op_private & OPpLOCALE)
2020 SET_NUMERIC_LOCAL();
2022 SET_NUMERIC_STANDARD();
2024 do_sprintf(TARG, SP-MARK, MARK+1);
2025 TAINT_IF(SvTAINTED(TARG));
2039 value = (I32) (*tmps & 255);
2044 value = (I32) (anum & 255);
2055 (void)SvUPGRADE(TARG,SVt_PV);
2061 (void)SvPOK_only(TARG);
2068 djSP; dTARGET; dPOPTOPssrl;
2070 char *tmps = SvPV(left, na);
2072 sv_setpv(TARG, fcrypt(tmps, SvPV(right, na)));
2074 sv_setpv(TARG, crypt(tmps, SvPV(right, na)));
2078 "The crypt() function is unimplemented due to excessive paranoia.");
2090 if (!SvPADTMP(sv)) {
2096 s = SvPV_force(sv, na);
2098 if (op->op_private & OPpLOCALE) {
2101 *s = toUPPER_LC(*s);
2116 if (!SvPADTMP(sv)) {
2122 s = SvPV_force(sv, na);
2124 if (op->op_private & OPpLOCALE) {
2127 *s = toLOWER_LC(*s);
2144 if (!SvPADTMP(sv)) {
2151 s = SvPV_force(sv, len);
2153 register char *send = s + len;
2155 if (op->op_private & OPpLOCALE) {
2158 for (; s < send; s++)
2159 *s = toUPPER_LC(*s);
2162 for (; s < send; s++)
2176 if (!SvPADTMP(sv)) {
2183 s = SvPV_force(sv, len);
2185 register char *send = s + len;
2187 if (op->op_private & OPpLOCALE) {
2190 for (; s < send; s++)
2191 *s = toLOWER_LC(*s);
2194 for (; s < send; s++)
2206 register char *s = SvPV(sv,len);
2210 (void)SvUPGRADE(TARG, SVt_PV);
2211 SvGROW(TARG, (len * 2) + 1);
2219 SvCUR_set(TARG, d - SvPVX(TARG));
2220 (void)SvPOK_only(TARG);
2223 sv_setpvn(TARG, s, len);
2232 djSP; dMARK; dORIGMARK;
2234 register AV* av = (AV*)POPs;
2235 register I32 lval = op->op_flags & OPf_MOD;
2236 I32 arybase = curcop->cop_arybase;
2239 if (SvTYPE(av) == SVt_PVAV) {
2240 if (lval && op->op_private & OPpLVAL_INTRO) {
2242 for (svp = MARK + 1; svp <= SP; svp++) {
2247 if (max > AvMAX(av))
2250 while (++MARK <= SP) {
2251 elem = SvIVx(*MARK);
2255 svp = av_fetch(av, elem, lval);
2257 if (!svp || *svp == &sv_undef)
2258 DIE(no_aelem, elem);
2259 if (op->op_private & OPpLVAL_INTRO)
2260 save_aelem(av, elem, svp);
2262 *MARK = svp ? *svp : &sv_undef;
2265 if (GIMME != G_ARRAY) {
2273 /* Associative arrays. */
2278 HV *hash = (HV*)POPs;
2280 I32 gimme = GIMME_V;
2281 I32 realhv = (SvTYPE(hash) == SVt_PVHV);
2284 /* might clobber stack_sp */
2285 entry = realhv ? hv_iternext(hash) : avhv_iternext((AV*)hash);
2290 PUSHs(hv_iterkeysv(entry)); /* won't clobber stack_sp */
2291 if (gimme == G_ARRAY) {
2293 /* might clobber stack_sp */
2294 sv_setsv(TARG, realhv ?
2295 hv_iterval(hash, entry) : avhv_iterval((AV*)hash, entry));
2300 else if (gimme == G_SCALAR)
2319 I32 gimme = GIMME_V;
2320 I32 discard = (gimme == G_VOID) ? G_DISCARD : 0;
2324 if (op->op_private & OPpSLICE) {
2328 hvtype = SvTYPE(hv);
2329 while (++MARK <= SP) {
2330 if (hvtype == SVt_PVHV)
2331 sv = hv_delete_ent(hv, *MARK, discard, 0);
2332 else if (hvtype == SVt_PVAV)
2333 sv = avhv_delete_ent((AV*)hv, *MARK, discard, 0);
2335 DIE("Not a HASH reference");
2336 *MARK = sv ? sv : &sv_undef;
2340 else if (gimme == G_SCALAR) {
2349 if (SvTYPE(hv) == SVt_PVHV)
2350 sv = hv_delete_ent(hv, keysv, discard, 0);
2351 else if (SvTYPE(hv) == SVt_PVAV)
2352 sv = avhv_delete_ent((AV*)hv, keysv, discard, 0);
2354 DIE("Not a HASH reference");
2368 if (SvTYPE(hv) == SVt_PVHV) {
2369 if (hv_exists_ent(hv, tmpsv, 0))
2371 } else if (SvTYPE(hv) == SVt_PVAV) {
2372 if (avhv_exists_ent((AV*)hv, tmpsv, 0))
2375 DIE("Not a HASH reference");
2382 djSP; dMARK; dORIGMARK;
2384 register HV *hv = (HV*)POPs;
2385 register I32 lval = op->op_flags & OPf_MOD;
2386 I32 realhv = (SvTYPE(hv) == SVt_PVHV);
2388 if (realhv || SvTYPE(hv) == SVt_PVAV) {
2389 while (++MARK <= SP) {
2393 he = hv_fetch_ent(hv, keysv, lval, 0);
2394 svp = he ? &HeVAL(he) : 0;
2396 svp = avhv_fetch_ent((AV*)hv, keysv, lval, 0);
2399 if (!he || HeVAL(he) == &sv_undef)
2400 DIE(no_helem, SvPV(keysv, na));
2401 if (op->op_private & OPpLVAL_INTRO)
2402 save_helem(hv, keysv, &HeVAL(he));
2404 *MARK = he ? HeVAL(he) : &sv_undef;
2407 if (GIMME != G_ARRAY) {
2415 /* List operators. */
2420 if (GIMME != G_ARRAY) {
2422 *MARK = *SP; /* unwanted list, return last item */
2433 SV **lastrelem = stack_sp;
2434 SV **lastlelem = stack_base + POPMARK;
2435 SV **firstlelem = stack_base + POPMARK + 1;
2436 register SV **firstrelem = lastlelem + 1;
2437 I32 arybase = curcop->cop_arybase;
2438 I32 lval = op->op_flags & OPf_MOD;
2439 I32 is_something_there = lval;
2441 register I32 max = lastrelem - lastlelem;
2442 register SV **lelem;
2445 if (GIMME != G_ARRAY) {
2446 ix = SvIVx(*lastlelem);
2451 if (ix < 0 || ix >= max)
2452 *firstlelem = &sv_undef;
2454 *firstlelem = firstrelem[ix];
2460 SP = firstlelem - 1;
2464 for (lelem = firstlelem; lelem <= lastlelem; lelem++) {
2470 else if (!(*lelem = firstrelem[ix]))
2475 if (ix >= max || !(*lelem = firstrelem[ix]))
2478 if (!is_something_there && (SvOK(*lelem) || SvGMAGICAL(*lelem)))
2479 is_something_there = TRUE;
2481 if (is_something_there)
2484 SP = firstlelem - 1;
2490 djSP; dMARK; dORIGMARK;
2491 I32 items = SP - MARK;
2492 SV *av = sv_2mortal((SV*)av_make(items, MARK+1));
2493 SP = ORIGMARK; /* av_make() might realloc stack_sp */
2500 djSP; dMARK; dORIGMARK;
2501 HV* hv = (HV*)sv_2mortal((SV*)newHV());
2505 SV *val = NEWSV(46, 0);
2507 sv_setsv(val, *++MARK);
2509 warn("Odd number of elements in hash assignment");
2510 (void)hv_store_ent(hv,key,val,0);
2519 djSP; dMARK; dORIGMARK;
2520 register AV *ary = (AV*)*++MARK;
2524 register I32 offset;
2525 register I32 length;
2532 if (SvRMAGICAL(ary) && (mg = mg_find((SV*)ary,'P'))) {
2533 *MARK-- = mg->mg_obj;
2537 perl_call_method("SPLICE",GIMME_V);
2546 offset = i = SvIVx(*MARK);
2548 offset += AvFILLp(ary) + 1;
2550 offset -= curcop->cop_arybase;
2554 length = SvIVx(*MARK++);
2559 length = AvMAX(ary) + 1; /* close enough to infinity */
2563 length = AvMAX(ary) + 1;
2565 if (offset > AvFILLp(ary) + 1)
2566 offset = AvFILLp(ary) + 1;
2567 after = AvFILLp(ary) + 1 - (offset + length);
2568 if (after < 0) { /* not that much array */
2569 length += after; /* offset+length now in array */
2575 /* At this point, MARK .. SP-1 is our new LIST */
2578 diff = newlen - length;
2579 if (newlen && !AvREAL(ary)) {
2583 assert(AvREAL(ary)); /* would leak, so croak */
2586 if (diff < 0) { /* shrinking the area */
2588 New(451, tmparyval, newlen, SV*); /* so remember insertion */
2589 Copy(MARK, tmparyval, newlen, SV*);
2592 MARK = ORIGMARK + 1;
2593 if (GIMME == G_ARRAY) { /* copy return vals to stack */
2594 MEXTEND(MARK, length);
2595 Copy(AvARRAY(ary)+offset, MARK, length, SV*);
2597 EXTEND_MORTAL(length);
2598 for (i = length, dst = MARK; i; i--) {
2599 if (!SvIMMORTAL(*dst))
2600 sv_2mortal(*dst); /* free them eventualy */
2607 *MARK = AvARRAY(ary)[offset+length-1];
2609 if (!SvIMMORTAL(*MARK))
2611 for (i = length - 1, dst = &AvARRAY(ary)[offset]; i > 0; i--)
2612 SvREFCNT_dec(*dst++); /* free them now */
2615 AvFILLp(ary) += diff;
2617 /* pull up or down? */
2619 if (offset < after) { /* easier to pull up */
2620 if (offset) { /* esp. if nothing to pull */
2621 src = &AvARRAY(ary)[offset-1];
2622 dst = src - diff; /* diff is negative */
2623 for (i = offset; i > 0; i--) /* can't trust Copy */
2627 SvPVX(ary) = (char*)(AvARRAY(ary) - diff); /* diff is negative */
2631 if (after) { /* anything to pull down? */
2632 src = AvARRAY(ary) + offset + length;
2633 dst = src + diff; /* diff is negative */
2634 Move(src, dst, after, SV*);
2636 dst = &AvARRAY(ary)[AvFILLp(ary)+1];
2637 /* avoid later double free */
2641 dst[--i] = &sv_undef;
2644 for (src = tmparyval, dst = AvARRAY(ary) + offset;
2646 *dst = NEWSV(46, 0);
2647 sv_setsv(*dst++, *src++);
2649 Safefree(tmparyval);
2652 else { /* no, expanding (or same) */
2654 New(452, tmparyval, length, SV*); /* so remember deletion */
2655 Copy(AvARRAY(ary)+offset, tmparyval, length, SV*);
2658 if (diff > 0) { /* expanding */
2660 /* push up or down? */
2662 if (offset < after && diff <= AvARRAY(ary) - AvALLOC(ary)) {
2666 Move(src, dst, offset, SV*);
2668 SvPVX(ary) = (char*)(AvARRAY(ary) - diff);/* diff is positive */
2670 AvFILLp(ary) += diff;
2673 if (AvFILLp(ary) + diff >= AvMAX(ary)) /* oh, well */
2674 av_extend(ary, AvFILLp(ary) + diff);
2675 AvFILLp(ary) += diff;
2678 dst = AvARRAY(ary) + AvFILLp(ary);
2680 for (i = after; i; i--) {
2687 for (src = MARK, dst = AvARRAY(ary) + offset; newlen; newlen--) {
2688 *dst = NEWSV(46, 0);
2689 sv_setsv(*dst++, *src++);
2691 MARK = ORIGMARK + 1;
2692 if (GIMME == G_ARRAY) { /* copy return vals to stack */
2694 Copy(tmparyval, MARK, length, SV*);
2696 EXTEND_MORTAL(length);
2697 for (i = length, dst = MARK; i; i--) {
2698 if (!SvIMMORTAL(*dst))
2699 sv_2mortal(*dst); /* free them eventualy */
2703 Safefree(tmparyval);
2707 else if (length--) {
2708 *MARK = tmparyval[length];
2710 if (!SvIMMORTAL(*MARK))
2712 while (length-- > 0)
2713 SvREFCNT_dec(tmparyval[length]);
2715 Safefree(tmparyval);
2726 djSP; dMARK; dORIGMARK; dTARGET;
2727 register AV *ary = (AV*)*++MARK;
2728 register SV *sv = &sv_undef;
2731 if (SvRMAGICAL(ary) && (mg = mg_find((SV*)ary,'P'))) {
2732 *MARK-- = mg->mg_obj;
2736 perl_call_method("PUSH",G_SCALAR|G_DISCARD);
2741 /* Why no pre-extend of ary here ? */
2742 for (++MARK; MARK <= SP; MARK++) {
2745 sv_setsv(sv, *MARK);
2750 PUSHi( AvFILL(ary) + 1 );
2758 SV *sv = av_pop(av);
2759 if (!SvIMMORTAL(sv) && AvREAL(av))
2760 (void)sv_2mortal(sv);
2769 SV *sv = av_shift(av);
2773 if (!SvIMMORTAL(sv) && AvREAL(av))
2774 (void)sv_2mortal(sv);
2781 djSP; dMARK; dORIGMARK; dTARGET;
2782 register AV *ary = (AV*)*++MARK;
2787 if (SvRMAGICAL(ary) && (mg = mg_find((SV*)ary,'P'))) {
2788 *MARK-- = mg->mg_obj;
2792 perl_call_method("UNSHIFT",G_SCALAR|G_DISCARD);
2797 av_unshift(ary, SP - MARK);
2800 sv_setsv(sv, *++MARK);
2801 (void)av_store(ary, i++, sv);
2805 PUSHi( AvFILL(ary) + 1 );
2815 if (GIMME == G_ARRAY) {
2826 register char *down;
2832 do_join(TARG, &sv_no, MARK, SP);
2834 sv_setsv(TARG, (SP > MARK) ? *SP : DEFSV);
2835 up = SvPV_force(TARG, len);
2837 down = SvPVX(TARG) + len - 1;
2843 (void)SvPOK_only(TARG);
2852 mul128(SV *sv, U8 m)
2855 char *s = SvPV(sv, len);
2859 if (!strnEQ(s, "0000", 4)) { /* need to grow sv */
2860 SV *tmpNew = newSVpv("0000000000", 10);
2862 sv_catsv(tmpNew, sv);
2863 SvREFCNT_dec(sv); /* free old sv */
2868 while (!*t) /* trailing '\0'? */
2871 i = ((*t - '0') << 7) + m;
2872 *(t--) = '0' + (i % 10);
2878 /* Explosives and implosives. */
2885 I32 gimme = GIMME_V;
2889 register char *pat = SvPV(left, llen);
2890 register char *s = SvPV(right, rlen);
2891 char *strend = s + rlen;
2893 register char *patend = pat + llen;
2898 /* These must not be in registers: */
2909 unsigned Quad_t auquad;
2915 register U32 culong;
2917 static char* bitcount = 0;
2920 if (gimme != G_ARRAY) { /* arrange to do first one only */
2922 for (patend = pat; !isALPHA(*patend) || *patend == 'x'; patend++) ;
2923 if (strchr("aAbBhHP", *patend) || *pat == '%') {
2925 while (isDIGIT(*patend) || *patend == '*')
2931 while (pat < patend) {
2933 datumtype = *pat++ & 0xFF;
2934 if (isSPACE(datumtype))
2938 else if (*pat == '*') {
2939 len = strend - strbeg; /* long enough */
2942 else if (isDIGIT(*pat)) {
2944 while (isDIGIT(*pat))
2945 len = (len * 10) + (*pat++ - '0');
2948 len = (datumtype != '@');
2951 croak("Invalid type in unpack: '%c'", (int)datumtype);
2952 case ',': /* grandfather in commas but with a warning */
2953 if (commas++ == 0 && dowarn)
2954 warn("Invalid type in unpack: '%c'", (int)datumtype);
2957 if (len == 1 && pat[-1] != '1')
2966 if (len > strend - strbeg)
2967 DIE("@ outside of string");
2971 if (len > s - strbeg)
2972 DIE("X outside of string");
2976 if (len > strend - s)
2977 DIE("x outside of string");
2982 if (len > strend - s)
2985 goto uchar_checksum;
2986 sv = NEWSV(35, len);
2987 sv_setpvn(sv, s, len);
2989 if (datumtype == 'A') {
2990 aptr = s; /* borrow register */
2991 s = SvPVX(sv) + len - 1;
2992 while (s >= SvPVX(sv) && (!*s || isSPACE(*s)))
2995 SvCUR_set(sv, s - SvPVX(sv));
2996 s = aptr; /* unborrow register */
2998 XPUSHs(sv_2mortal(sv));
3002 if (pat[-1] == '*' || len > (strend - s) * 8)
3003 len = (strend - s) * 8;
3006 Newz(601, bitcount, 256, char);
3007 for (bits = 1; bits < 256; bits++) {
3008 if (bits & 1) bitcount[bits]++;
3009 if (bits & 2) bitcount[bits]++;
3010 if (bits & 4) bitcount[bits]++;
3011 if (bits & 8) bitcount[bits]++;
3012 if (bits & 16) bitcount[bits]++;
3013 if (bits & 32) bitcount[bits]++;
3014 if (bits & 64) bitcount[bits]++;
3015 if (bits & 128) bitcount[bits]++;
3019 culong += bitcount[*(unsigned char*)s++];
3024 if (datumtype == 'b') {
3026 if (bits & 1) culong++;
3032 if (bits & 128) culong++;
3039 sv = NEWSV(35, len + 1);
3042 aptr = pat; /* borrow register */
3044 if (datumtype == 'b') {
3046 for (len = 0; len < aint; len++) {
3047 if (len & 7) /*SUPPRESS 595*/
3051 *pat++ = '0' + (bits & 1);
3056 for (len = 0; len < aint; len++) {
3061 *pat++ = '0' + ((bits & 128) != 0);
3065 pat = aptr; /* unborrow register */
3066 XPUSHs(sv_2mortal(sv));
3070 if (pat[-1] == '*' || len > (strend - s) * 2)
3071 len = (strend - s) * 2;
3072 sv = NEWSV(35, len + 1);
3075 aptr = pat; /* borrow register */
3077 if (datumtype == 'h') {
3079 for (len = 0; len < aint; len++) {
3084 *pat++ = hexdigit[bits & 15];
3089 for (len = 0; len < aint; len++) {
3094 *pat++ = hexdigit[(bits >> 4) & 15];
3098 pat = aptr; /* unborrow register */
3099 XPUSHs(sv_2mortal(sv));
3102 if (len > strend - s)
3107 if (aint >= 128) /* fake up signed chars */
3117 if (aint >= 128) /* fake up signed chars */
3120 sv_setiv(sv, (IV)aint);
3121 PUSHs(sv_2mortal(sv));
3126 if (len > strend - s)
3141 sv_setiv(sv, (IV)auint);
3142 PUSHs(sv_2mortal(sv));
3147 along = (strend - s) / SIZE16;
3164 sv_setiv(sv, (IV)ashort);
3165 PUSHs(sv_2mortal(sv));
3172 along = (strend - s) / SIZE16;
3177 COPY16(s, &aushort);
3180 if (datumtype == 'n')
3181 aushort = PerlSock_ntohs(aushort);
3184 if (datumtype == 'v')
3185 aushort = vtohs(aushort);
3194 COPY16(s, &aushort);
3198 if (datumtype == 'n')
3199 aushort = PerlSock_ntohs(aushort);
3202 if (datumtype == 'v')
3203 aushort = vtohs(aushort);
3205 sv_setiv(sv, (IV)aushort);
3206 PUSHs(sv_2mortal(sv));
3211 along = (strend - s) / sizeof(int);
3216 Copy(s, &aint, 1, int);
3219 cdouble += (double)aint;
3228 Copy(s, &aint, 1, int);
3232 /* Without the dummy below unpack("i", pack("i",-1))
3233 * return 0xFFffFFff instead of -1 for Digital Unix V4.0
3234 * cc with optimization turned on */
3236 sv_setiv(sv, (IV)aint) :
3238 sv_setiv(sv, (IV)aint);
3239 PUSHs(sv_2mortal(sv));
3244 along = (strend - s) / sizeof(unsigned int);
3249 Copy(s, &auint, 1, unsigned int);
3250 s += sizeof(unsigned int);
3252 cdouble += (double)auint;
3261 Copy(s, &auint, 1, unsigned int);
3262 s += sizeof(unsigned int);
3264 sv_setuv(sv, (UV)auint);
3265 PUSHs(sv_2mortal(sv));
3270 along = (strend - s) / SIZE32;
3278 cdouble += (double)along;
3290 sv_setiv(sv, (IV)along);
3291 PUSHs(sv_2mortal(sv));
3298 along = (strend - s) / SIZE32;
3306 if (datumtype == 'N')
3307 aulong = PerlSock_ntohl(aulong);
3310 if (datumtype == 'V')
3311 aulong = vtohl(aulong);
3314 cdouble += (double)aulong;
3326 if (datumtype == 'N')
3327 aulong = PerlSock_ntohl(aulong);
3330 if (datumtype == 'V')
3331 aulong = vtohl(aulong);
3334 sv_setuv(sv, (UV)aulong);
3335 PUSHs(sv_2mortal(sv));
3340 along = (strend - s) / sizeof(char*);
3346 if (sizeof(char*) > strend - s)
3349 Copy(s, &aptr, 1, char*);
3355 PUSHs(sv_2mortal(sv));
3365 while ((len > 0) && (s < strend)) {
3366 auv = (auv << 7) | (*s & 0x7f);
3367 if (!(*s++ & 0x80)) {
3371 PUSHs(sv_2mortal(sv));
3375 else if (++bytes >= sizeof(UV)) { /* promote to string */
3378 sv = newSVpvf("%.*Vu", (int)TYPE_DIGITS(UV), auv);
3379 while (s < strend) {
3380 sv = mul128(sv, *s & 0x7f);
3381 if (!(*s++ & 0x80)) {
3390 PUSHs(sv_2mortal(sv));
3395 if ((s >= strend) && bytes)
3396 croak("Unterminated compressed integer");
3401 if (sizeof(char*) > strend - s)
3404 Copy(s, &aptr, 1, char*);
3409 sv_setpvn(sv, aptr, len);
3410 PUSHs(sv_2mortal(sv));
3417 if (s + sizeof(Quad_t) > strend)
3420 Copy(s, &aquad, 1, Quad_t);
3421 s += sizeof(Quad_t);
3424 if (aquad >= IV_MIN && aquad <= IV_MAX)
3425 sv_setiv(sv, (IV)aquad);
3427 sv_setnv(sv, (double)aquad);
3428 PUSHs(sv_2mortal(sv));
3435 if (s + sizeof(unsigned Quad_t) > strend)
3438 Copy(s, &auquad, 1, unsigned Quad_t);
3439 s += sizeof(unsigned Quad_t);
3442 if (aquad <= UV_MAX)
3443 sv_setuv(sv, (UV)auquad);
3445 sv_setnv(sv, (double)auquad);
3446 PUSHs(sv_2mortal(sv));
3450 /* float and double added gnb@melba.bby.oz.au 22/11/89 */
3453 along = (strend - s) / sizeof(float);
3458 Copy(s, &afloat, 1, float);
3467 Copy(s, &afloat, 1, float);
3470 sv_setnv(sv, (double)afloat);
3471 PUSHs(sv_2mortal(sv));
3477 along = (strend - s) / sizeof(double);
3482 Copy(s, &adouble, 1, double);
3483 s += sizeof(double);
3491 Copy(s, &adouble, 1, double);
3492 s += sizeof(double);
3494 sv_setnv(sv, (double)adouble);
3495 PUSHs(sv_2mortal(sv));
3500 along = (strend - s) * 3 / 4;
3501 sv = NEWSV(42, along);
3504 while (s < strend && *s > ' ' && *s < 'a') {
3509 len = (*s++ - ' ') & 077;
3511 if (s < strend && *s >= ' ')
3512 a = (*s++ - ' ') & 077;
3515 if (s < strend && *s >= ' ')
3516 b = (*s++ - ' ') & 077;
3519 if (s < strend && *s >= ' ')
3520 c = (*s++ - ' ') & 077;
3523 if (s < strend && *s >= ' ')
3524 d = (*s++ - ' ') & 077;
3527 hunk[0] = (a << 2) | (b >> 4);
3528 hunk[1] = (b << 4) | (c >> 2);
3529 hunk[2] = (c << 6) | d;
3530 sv_catpvn(sv, hunk, (len > 3) ? 3 : len);
3535 else if (s[1] == '\n') /* possible checksum byte */
3538 XPUSHs(sv_2mortal(sv));
3543 if (strchr("fFdD", datumtype) ||
3544 (checksum > 32 && strchr("iIlLN", datumtype)) ) {
3548 while (checksum >= 16) {
3552 while (checksum >= 4) {
3558 along = (1 << checksum) - 1;
3559 while (cdouble < 0.0)
3561 cdouble = modf(cdouble / adouble, &trouble) * adouble;
3562 sv_setnv(sv, cdouble);
3565 if (checksum < 32) {
3566 aulong = (1 << checksum) - 1;
3569 sv_setuv(sv, (UV)culong);
3571 XPUSHs(sv_2mortal(sv));
3575 if (SP == oldsp && gimme == G_SCALAR)
3581 doencodes(register SV *sv, register char *s, register I32 len)
3586 sv_catpvn(sv, hunk, 1);
3589 hunk[0] = ' ' + (077 & (*s >> 2));
3590 hunk[1] = ' ' + (077 & (((*s << 4) & 060) | ((s[1] >> 4) & 017)));
3591 hunk[2] = ' ' + (077 & (((s[1] << 2) & 074) | ((s[2] >> 6) & 03)));
3592 hunk[3] = ' ' + (077 & (s[2] & 077));
3593 sv_catpvn(sv, hunk, 4);
3597 for (s = SvPVX(sv); *s; s++) {
3601 sv_catpvn(sv, "\n", 1);
3605 is_an_int(char *s, STRLEN l)
3607 SV *result = newSVpv("", l);
3608 char *result_c = SvPV(result, na); /* convenience */
3609 char *out = result_c;
3619 SvREFCNT_dec(result);
3642 SvREFCNT_dec(result);
3648 SvCUR_set(result, out - result_c);
3653 div128(SV *pnum, bool *done)
3654 /* must be '\0' terminated */
3658 char *s = SvPV(pnum, len);
3667 i = m * 10 + (*t - '0');
3669 r = (i >> 7); /* r < 10 */
3676 SvCUR_set(pnum, (STRLEN) (t - s));
3683 djSP; dMARK; dORIGMARK; dTARGET;
3684 register SV *cat = TARG;
3687 register char *pat = SvPVx(*++MARK, fromlen);
3688 register char *patend = pat + fromlen;
3693 static char null10[] = {0,0,0,0,0,0,0,0,0,0};
3694 static char *space10 = " ";
3696 /* These must not be in registers: */
3705 unsigned Quad_t auquad;
3714 sv_setpvn(cat, "", 0);
3715 while (pat < patend) {
3716 #define NEXTFROM (items-- > 0 ? *MARK++ : &sv_no)
3717 datumtype = *pat++ & 0xFF;
3718 if (isSPACE(datumtype))
3721 len = strchr("@Xxu", datumtype) ? 0 : items;
3724 else if (isDIGIT(*pat)) {
3726 while (isDIGIT(*pat))
3727 len = (len * 10) + (*pat++ - '0');
3733 croak("Invalid type in pack: '%c'", (int)datumtype);
3734 case ',': /* grandfather in commas but with a warning */
3735 if (commas++ == 0 && dowarn)
3736 warn("Invalid type in pack: '%c'", (int)datumtype);
3739 DIE("%% may only be used in unpack");
3750 if (SvCUR(cat) < len)
3751 DIE("X outside of string");
3758 sv_catpvn(cat, null10, 10);
3761 sv_catpvn(cat, null10, len);
3766 aptr = SvPV(fromstr, fromlen);
3770 sv_catpvn(cat, aptr, len);
3772 sv_catpvn(cat, aptr, fromlen);
3774 if (datumtype == 'A') {
3776 sv_catpvn(cat, space10, 10);
3779 sv_catpvn(cat, space10, len);
3783 sv_catpvn(cat, null10, 10);
3786 sv_catpvn(cat, null10, len);
3793 char *savepat = pat;
3798 aptr = SvPV(fromstr, fromlen);
3803 SvCUR(cat) += (len+7)/8;
3804 SvGROW(cat, SvCUR(cat) + 1);
3805 aptr = SvPVX(cat) + aint;
3810 if (datumtype == 'B') {
3811 for (len = 0; len++ < aint;) {
3812 items |= *pat++ & 1;
3816 *aptr++ = items & 0xff;
3822 for (len = 0; len++ < aint;) {
3828 *aptr++ = items & 0xff;
3834 if (datumtype == 'B')
3835 items <<= 7 - (aint & 7);
3837 items >>= 7 - (aint & 7);
3838 *aptr++ = items & 0xff;
3840 pat = SvPVX(cat) + SvCUR(cat);
3851 char *savepat = pat;
3856 aptr = SvPV(fromstr, fromlen);
3861 SvCUR(cat) += (len+1)/2;
3862 SvGROW(cat, SvCUR(cat) + 1);
3863 aptr = SvPVX(cat) + aint;
3868 if (datumtype == 'H') {
3869 for (len = 0; len++ < aint;) {
3871 items |= ((*pat++ & 15) + 9) & 15;
3873 items |= *pat++ & 15;
3877 *aptr++ = items & 0xff;
3883 for (len = 0; len++ < aint;) {
3885 items |= (((*pat++ & 15) + 9) & 15) << 4;
3887 items |= (*pat++ & 15) << 4;
3891 *aptr++ = items & 0xff;
3897 *aptr++ = items & 0xff;
3898 pat = SvPVX(cat) + SvCUR(cat);
3910 aint = SvIV(fromstr);
3912 sv_catpvn(cat, &achar, sizeof(char));
3915 /* Float and double added by gnb@melba.bby.oz.au 22/11/89 */
3920 afloat = (float)SvNV(fromstr);
3921 sv_catpvn(cat, (char *)&afloat, sizeof (float));
3928 adouble = (double)SvNV(fromstr);
3929 sv_catpvn(cat, (char *)&adouble, sizeof (double));
3935 ashort = (I16)SvIV(fromstr);
3937 ashort = PerlSock_htons(ashort);
3939 CAT16(cat, &ashort);
3945 ashort = (I16)SvIV(fromstr);
3947 ashort = htovs(ashort);
3949 CAT16(cat, &ashort);
3956 ashort = (I16)SvIV(fromstr);
3957 CAT16(cat, &ashort);
3963 auint = SvUV(fromstr);
3964 sv_catpvn(cat, (char*)&auint, sizeof(unsigned int));
3970 adouble = floor(SvNV(fromstr));
3973 croak("Cannot compress negative numbers");
3979 #ifdef CXUX_BROKEN_CONSTANT_CONVERT
3980 adouble <= UV_MAX_cxux
3987 char buf[1 + sizeof(UV)];
3988 char *in = buf + sizeof(buf);
3989 UV auv = U_V(adouble);;
3992 *--in = (auv & 0x7f) | 0x80;
3995 buf[sizeof(buf) - 1] &= 0x7f; /* clear continue bit */
3996 sv_catpvn(cat, in, (buf + sizeof(buf)) - in);
3998 else if (SvPOKp(fromstr)) { /* decimal string arithmetics */
3999 char *from, *result, *in;
4004 /* Copy string and check for compliance */
4005 from = SvPV(fromstr, len);
4006 if ((norm = is_an_int(from, len)) == NULL)
4007 croak("can compress only unsigned integer");
4009 New('w', result, len, char);
4013 *--in = div128(norm, &done) | 0x80;
4014 result[len - 1] &= 0x7F; /* clear continue bit */
4015 sv_catpvn(cat, in, (result + len) - in);
4017 SvREFCNT_dec(norm); /* free norm */
4019 else if (SvNOKp(fromstr)) {
4020 char buf[sizeof(double) * 2]; /* 8/7 <= 2 */
4021 char *in = buf + sizeof(buf);
4024 double next = floor(adouble / 128);
4025 *--in = (unsigned char)(adouble - (next * 128)) | 0x80;
4026 if (--in < buf) /* this cannot happen ;-) */
4027 croak ("Cannot compress integer");
4029 } while (adouble > 0);
4030 buf[sizeof(buf) - 1] &= 0x7f; /* clear continue bit */
4031 sv_catpvn(cat, in, (buf + sizeof(buf)) - in);
4034 croak("Cannot compress non integer");
4040 aint = SvIV(fromstr);
4041 sv_catpvn(cat, (char*)&aint, sizeof(int));
4047 aulong = SvUV(fromstr);
4049 aulong = PerlSock_htonl(aulong);
4051 CAT32(cat, &aulong);
4057 aulong = SvUV(fromstr);
4059 aulong = htovl(aulong);
4061 CAT32(cat, &aulong);
4067 aulong = SvUV(fromstr);
4068 CAT32(cat, &aulong);
4074 along = SvIV(fromstr);
4082 auquad = (unsigned Quad_t)SvIV(fromstr);
4083 sv_catpvn(cat, (char*)&auquad, sizeof(unsigned Quad_t));
4089 aquad = (Quad_t)SvIV(fromstr);
4090 sv_catpvn(cat, (char*)&aquad, sizeof(Quad_t));
4093 #endif /* HAS_QUAD */
4095 len = 1; /* assume SV is correct length */
4100 if (fromstr == &sv_undef)
4103 /* XXX better yet, could spirit away the string to
4104 * a safe spot and hang on to it until the result
4105 * of pack() (and all copies of the result) are
4108 if (dowarn && (SvTEMP(fromstr) || SvPADTMP(fromstr)))
4109 warn("Attempt to pack pointer to temporary value");
4110 if (SvPOK(fromstr) || SvNIOK(fromstr))
4111 aptr = SvPV(fromstr,na);
4113 aptr = SvPV_force(fromstr,na);
4115 sv_catpvn(cat, (char*)&aptr, sizeof(char*));
4120 aptr = SvPV(fromstr, fromlen);
4121 SvGROW(cat, fromlen * 4 / 3);
4126 while (fromlen > 0) {
4133 doencodes(cat, aptr, todo);
4152 register I32 limit = POPi; /* note, negative is forever */
4155 register char *s = SvPV(sv, len);
4156 char *strend = s + len;
4158 register REGEXP *rx;
4162 I32 maxiters = (strend - s) + 10;
4165 I32 origlimit = limit;
4168 AV *oldstack = curstack;
4169 I32 gimme = GIMME_V;
4170 I32 oldsave = savestack_ix;
4171 I32 make_mortal = 1;
4172 MAGIC *mg = (MAGIC *) NULL;
4175 Copy(&LvTARGOFF(POPs), &pm, 1, PMOP*);
4180 DIE("panic: do_split");
4181 rx = pm->op_pmregexp;
4183 TAINT_IF((pm->op_pmflags & PMf_LOCALE) &&
4184 (pm->op_pmflags & (PMf_WHITE | PMf_SKIPWHITE)));
4186 if (pm->op_pmreplroot)
4187 ary = GvAVn((GV*)pm->op_pmreplroot);
4188 else if (gimme != G_ARRAY)
4190 ary = (AV*)curpad[0];
4193 #endif /* USE_THREADS */
4196 if (ary && (gimme != G_ARRAY || (pm->op_pmflags & PMf_ONCE))) {
4202 if (SvRMAGICAL(ary) && (mg = mg_find((SV *) ary, 'P'))) {
4209 for (i = AvFILLp(ary); i >= 0; i--)
4210 AvARRAY(ary)[i] = &sv_undef; /* don't free mere refs */
4212 /* temporarily switch stacks */
4213 SWITCHSTACK(curstack, ary);
4217 base = SP - stack_base;
4219 if (pm->op_pmflags & PMf_SKIPWHITE) {
4220 if (pm->op_pmflags & PMf_LOCALE) {
4221 while (isSPACE_LC(*s))
4229 if (pm->op_pmflags & (PMf_MULTILINE|PMf_SINGLELINE)) {
4231 multiline = pm->op_pmflags & PMf_MULTILINE;
4235 limit = maxiters + 2;
4236 if (pm->op_pmflags & PMf_WHITE) {
4239 while (m < strend &&
4240 !((pm->op_pmflags & PMf_LOCALE)
4241 ? isSPACE_LC(*m) : isSPACE(*m)))
4246 dstr = NEWSV(30, m-s);
4247 sv_setpvn(dstr, s, m-s);
4253 while (s < strend &&
4254 ((pm->op_pmflags & PMf_LOCALE)
4255 ? isSPACE_LC(*s) : isSPACE(*s)))
4259 else if (strEQ("^", rx->precomp)) {
4262 for (m = s; m < strend && *m != '\n'; m++) ;
4266 dstr = NEWSV(30, m-s);
4267 sv_setpvn(dstr, s, m-s);
4274 else if (rx->check_substr && !rx->nparens
4275 && (rx->reganch & ROPT_CHECK_ALL)
4276 && !(rx->reganch & ROPT_ANCH)) {
4277 i = SvCUR(rx->check_substr);
4278 if (i == 1 && !SvTAIL(rx->check_substr)) {
4279 i = *SvPVX(rx->check_substr);
4282 for (m = s; m < strend && *m != i; m++) ;
4285 dstr = NEWSV(30, m-s);
4286 sv_setpvn(dstr, s, m-s);
4295 while (s < strend && --limit &&
4296 (m=fbm_instr((unsigned char*)s, (unsigned char*)strend,
4297 rx->check_substr)) )
4300 dstr = NEWSV(31, m-s);
4301 sv_setpvn(dstr, s, m-s);
4310 maxiters += (strend - s) * rx->nparens;
4311 while (s < strend && --limit &&
4312 regexec_flags(rx, s, strend, orig, 1, Nullsv, NULL, 0))
4314 TAINT_IF(RX_MATCH_TAINTED(rx));
4316 && rx->subbase != orig) {
4321 strend = s + (strend - m);
4324 dstr = NEWSV(32, m-s);
4325 sv_setpvn(dstr, s, m-s);
4330 for (i = 1; i <= rx->nparens; i++) {
4334 dstr = NEWSV(33, m-s);
4335 sv_setpvn(dstr, s, m-s);
4338 dstr = NEWSV(33, 0);
4348 LEAVE_SCOPE(oldsave);
4349 iters = (SP - stack_base) - base;
4350 if (iters > maxiters)
4353 /* keep field after final delim? */
4354 if (s < strend || (iters && origlimit)) {
4355 dstr = NEWSV(34, strend-s);
4356 sv_setpvn(dstr, s, strend-s);
4362 else if (!origlimit) {
4363 while (iters > 0 && (!TOPs || !SvANY(TOPs) || SvCUR(TOPs) == 0))
4369 SWITCHSTACK(ary, oldstack);
4370 if (SvSMAGICAL(ary)) {
4375 if (gimme == G_ARRAY) {
4377 Copy(AvARRAY(ary), SP + 1, iters, SV*);
4385 perl_call_method("PUSH",G_SCALAR|G_DISCARD);
4388 if (gimme == G_ARRAY) {
4389 /* EXTEND should not be needed - we just popped them */
4391 for (i=0; i < iters; i++) {
4392 SV **svp = av_fetch(ary, i, FALSE);
4393 PUSHs((svp) ? *svp : &sv_undef);
4400 if (gimme == G_ARRAY)
4403 if (iters || !pm->op_pmreplroot) {
4413 unlock_condpair(void *svv)
4416 MAGIC *mg = mg_find((SV*)svv, 'm');
4419 croak("panic: unlock_condpair unlocking non-mutex");
4420 MUTEX_LOCK(MgMUTEXP(mg));
4421 if (MgOWNER(mg) != thr)
4422 croak("panic: unlock_condpair unlocking mutex that we don't own");
4424 COND_SIGNAL(MgOWNERCONDP(mg));
4425 DEBUG_L(PerlIO_printf(PerlIO_stderr(), "0x%lx: unlock 0x%lx\n",
4426 (unsigned long)thr, (unsigned long)svv);)
4427 MUTEX_UNLOCK(MgMUTEXP(mg));
4429 #endif /* USE_THREADS */
4442 mg = condpair_magic(sv);
4443 MUTEX_LOCK(MgMUTEXP(mg));
4444 if (MgOWNER(mg) == thr)
4445 MUTEX_UNLOCK(MgMUTEXP(mg));
4448 COND_WAIT(MgOWNERCONDP(mg), MgMUTEXP(mg));
4450 DEBUG_L(PerlIO_printf(PerlIO_stderr(), "0x%lx: pp_lock lock 0x%lx\n",
4451 (unsigned long)thr, (unsigned long)sv);)
4452 MUTEX_UNLOCK(MgMUTEXP(mg));
4453 SvREFCNT_inc(sv); /* keep alive until magic_mutexfree */
4454 save_destructor(unlock_condpair, sv);
4456 #endif /* USE_THREADS */
4457 if (SvTYPE(retsv) == SVt_PVAV || SvTYPE(retsv) == SVt_PVHV
4458 || SvTYPE(retsv) == SVt_PVCV) {
4459 retsv = refto(retsv);
4470 if (op->op_private & OPpLVAL_INTRO)
4471 PUSHs(*save_threadsv(op->op_targ));
4473 PUSHs(THREADSV(op->op_targ));
4476 DIE("tried to access per-thread data in non-threaded perl");
4477 #endif /* USE_THREADS */