3 * Copyright (c) 1991-1999, 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 * "Sam sat on the ground and put his head in his hands. 'I wish I had never
12 * come here, and I don't want to see no more magic,' he said, and fell silent."
18 /* XXX If this causes problems, set i_unistd=undef in the hint file. */
23 #if defined(HAS_GETGROUPS) || defined(HAS_SETGROUPS)
30 # define VTBL this->*vtbl
33 static void restore_magic _((void *p));
34 static int magic_methcall(SV *sv, MAGIC *mg, char *meth, I32 f, int n, SV *val);
38 * Use the "DESTRUCTOR" scope cleanup to reinstate magic.
46 /* MGS is typedef'ed to struct magic_state in perl.h */
49 save_magic(I32 mgs_ix, SV *sv)
53 assert(SvMAGICAL(sv));
55 SAVEDESTRUCTOR(restore_magic, (void*)mgs_ix);
57 mgs = SSPTR(mgs_ix, MGS*);
59 mgs->mgs_flags = SvMAGICAL(sv) | SvREADONLY(sv);
60 mgs->mgs_ss_ix = PL_savestack_ix; /* points after the saved destructor */
64 SvFLAGS(sv) |= (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT;
68 restore_magic(void *p)
71 MGS* mgs = SSPTR((I32)p, MGS*);
77 if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv))
80 SvFLAGS(sv) |= mgs->mgs_flags;
84 SvFLAGS(sv) &= ~(SVf_IOK|SVf_NOK|SVf_POK);
87 mgs->mgs_sv = NULL; /* mark the MGS structure as restored */
89 /* If we're still on top of the stack, pop us off. (That condition
90 * will be satisfied if restore_magic was called explicitly, but *not*
91 * if it's being called via leave_scope.)
92 * The reason for doing this is that otherwise, things like sv_2cv()
93 * may leave alloc gunk on the savestack, and some code
94 * (e.g. sighandler) doesn't expect that...
96 if (PL_savestack_ix == mgs->mgs_ss_ix)
98 I32 popval = SSPOPINT;
99 assert(popval == SAVEt_DESTRUCTOR);
100 PL_savestack_ix -= 2;
102 assert(popval == SAVEt_ALLOC);
104 PL_savestack_ix -= popval;
113 for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
114 MGVTBL* vtbl = mg->mg_virtual;
116 if ((vtbl->svt_get != NULL) && !(mg->mg_flags & MGf_GSKIP))
120 if (!(SvFLAGS(sv) & (SVs_GMG|SVs_SMG)) || (vtbl->svt_clear != NULL))
135 mgs_ix = SSNEW(sizeof(MGS));
136 save_magic(mgs_ix, sv);
139 while ((mg = *mgp) != 0) {
140 MGVTBL* vtbl = mg->mg_virtual;
141 if (!(mg->mg_flags & MGf_GSKIP) && vtbl && (vtbl->svt_get != NULL)) {
142 (VTBL->svt_get)(sv, mg);
143 /* Ignore this magic if it's been deleted */
144 if ((mg == (mgp_valid ? *mgp : SvMAGIC(sv))) &&
145 (mg->mg_flags & MGf_GSKIP))
146 (SSPTR(mgs_ix, MGS*))->mgs_flags = 0;
148 /* Advance to next magic (complicated by possible deletion) */
149 if (mg == (mgp_valid ? *mgp : SvMAGIC(sv))) {
150 mgp = &mg->mg_moremagic;
154 mgp = &SvMAGIC(sv); /* Re-establish pointer after sv_upgrade */
157 restore_magic((void*)mgs_ix);
169 mgs_ix = SSNEW(sizeof(MGS));
170 save_magic(mgs_ix, sv);
172 for (mg = SvMAGIC(sv); mg; mg = nextmg) {
173 MGVTBL* vtbl = mg->mg_virtual;
174 nextmg = mg->mg_moremagic; /* it may delete itself */
175 if (mg->mg_flags & MGf_GSKIP) {
176 mg->mg_flags &= ~MGf_GSKIP; /* setting requires another read */
177 (SSPTR(mgs_ix, MGS*))->mgs_flags = 0;
179 if (vtbl && (vtbl->svt_set != NULL))
180 (VTBL->svt_set)(sv, mg);
183 restore_magic((void*)mgs_ix);
194 for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
195 MGVTBL* vtbl = mg->mg_virtual;
196 if (vtbl && (vtbl->svt_len != NULL)) {
199 mgs_ix = SSNEW(sizeof(MGS));
200 save_magic(mgs_ix, sv);
201 /* omit MGf_GSKIP -- not changed here */
202 len = (VTBL->svt_len)(sv, mg);
203 restore_magic((void*)mgs_ix);
208 junk = SvPV(sv, len);
218 for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
219 MGVTBL* vtbl = mg->mg_virtual;
220 if (vtbl && (vtbl->svt_len != NULL)) {
223 mgs_ix = SSNEW(sizeof(MGS));
224 save_magic(mgs_ix, sv);
225 /* omit MGf_GSKIP -- not changed here */
226 len = (VTBL->svt_len)(sv, mg);
227 restore_magic((void*)mgs_ix);
234 len = AvFILLp((AV *) sv); /* Fallback to non-tied array */
239 croak("Size magic not implemented");
251 mgs_ix = SSNEW(sizeof(MGS));
252 save_magic(mgs_ix, sv);
254 for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
255 MGVTBL* vtbl = mg->mg_virtual;
256 /* omit GSKIP -- never set here */
258 if (vtbl && (vtbl->svt_clear != NULL))
259 (VTBL->svt_clear)(sv, mg);
262 restore_magic((void*)mgs_ix);
267 mg_find(SV *sv, int type)
270 for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
271 if (mg->mg_type == type)
278 mg_copy(SV *sv, SV *nsv, const char *key, I32 klen)
282 for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
283 if (isUPPER(mg->mg_type)) {
285 mg->mg_type == 'P' ? SvTIED_obj(sv, mg) : mg->mg_obj,
286 toLOWER(mg->mg_type), key, klen);
298 for (mg = SvMAGIC(sv); mg; mg = moremagic) {
299 MGVTBL* vtbl = mg->mg_virtual;
300 moremagic = mg->mg_moremagic;
301 if (vtbl && (vtbl->svt_free != NULL))
302 (VTBL->svt_free)(sv, mg);
303 if (mg->mg_ptr && mg->mg_type != 'g')
305 Safefree(mg->mg_ptr);
306 else if (mg->mg_len == HEf_SVKEY)
307 SvREFCNT_dec((SV*)mg->mg_ptr);
308 if (mg->mg_flags & MGf_REFCOUNTED)
309 SvREFCNT_dec(mg->mg_obj);
316 #if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX)
321 magic_regdata_cnt(SV *sv, MAGIC *mg)
329 if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
330 if (mg->mg_obj) /* @+ */
333 return rx->lastparen;
340 magic_regdatum_get(SV *sv, MAGIC *mg)
349 if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
353 if (paren <= rx->nparens &&
354 (s = rx->startp[paren]) &&
355 (t = rx->endp[paren]))
357 if (mg->mg_obj) /* @+ */
368 magic_len(SV *sv, MAGIC *mg)
377 switch (*mg->mg_ptr) {
378 case '1': case '2': case '3': case '4':
379 case '5': case '6': case '7': case '8': case '9': case '&':
380 if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
381 paren = atoi(mg->mg_ptr);
383 if (paren <= rx->nparens &&
384 (s = rx->startp[paren]) &&
385 (t = rx->endp[paren]))
394 if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
395 paren = rx->lastparen;
401 if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
402 if ((s = rx->subbeg) && rx->startp[0]) {
403 i = rx->startp[0] - s;
410 if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
411 if (rx->subend && (s = rx->endp[0])) {
419 return (STRLEN)PL_ofslen;
421 return (STRLEN)PL_orslen;
424 if (!SvPOK(sv) && SvNIOK(sv)) {
443 static char buffer[50] ;
448 sprintf(buffer, "Buffer %d, Length = %d - ", sv, SvCUR(sv)) ;
450 for (i = 0; i < SvCUR(sv) ; ++ i) {
451 sprintf (buf1, " %x [%x]", (p+i), *(p+i)) ;
452 strcat(buffer, buf1) ;
462 magic_get(SV *sv, MAGIC *mg)
471 switch (*mg->mg_ptr) {
472 case '\001': /* ^A */
473 sv_setsv(sv, PL_bodytarget);
475 case '\002': /* ^B */
476 /* printf("magic_get $^B: ") ; */
477 if (PL_curcop->cop_warnings == WARN_NONE)
478 /* printf("WARN_NONE\n"), */
479 sv_setpvn(sv, WARN_NONEstring, WARNsize) ;
480 else if (PL_curcop->cop_warnings == WARN_ALL)
481 /* printf("WARN_ALL\n"), */
482 sv_setpvn(sv, WARN_ALLstring, WARNsize) ;
484 /* printf("some %s\n", printW(PL_curcop->cop_warnings)), */
485 sv_setsv(sv, PL_curcop->cop_warnings);
487 case '\003': /* ^C */
488 sv_setiv(sv, (IV)PL_minus_c);
491 case '\004': /* ^D */
492 sv_setiv(sv, (IV)(PL_debug & 32767));
494 case '\005': /* ^E */
497 # include <descrip.h>
498 # include <starlet.h>
500 $DESCRIPTOR(msgdsc,msg);
501 sv_setnv(sv,(double) vaxc$errno);
502 if (sys$getmsg(vaxc$errno,&msgdsc.dsc$w_length,&msgdsc,0,0) & 1)
503 sv_setpvn(sv,msgdsc.dsc$a_pointer,msgdsc.dsc$w_length);
509 if (!(_emx_env & 0x200)) { /* Under DOS */
510 sv_setnv(sv, (double)errno);
511 sv_setpv(sv, errno ? Strerror(errno) : "");
513 if (errno != errno_isOS2) {
514 int tmp = _syserrno();
515 if (tmp) /* 2nd call to _syserrno() makes it 0 */
518 sv_setnv(sv, (double)Perl_rc);
519 sv_setpv(sv, os2error(Perl_rc));
524 DWORD dwErr = GetLastError();
525 sv_setnv(sv, (double)dwErr);
531 PerlProc_GetSysMsg(sMsg, dwLen, dwErr);
532 sv_setpvn(sv, sMsg, dwLen);
533 PerlProc_FreeBuf(sMsg);
535 win32_str_os_error(sv, dwErr);
543 sv_setnv(sv, (double)errno);
544 sv_setpv(sv, errno ? Strerror(errno) : "");
548 SvNOK_on(sv); /* what a wonderful hack! */
550 case '\006': /* ^F */
551 sv_setiv(sv, (IV)PL_maxsysfd);
553 case '\010': /* ^H */
554 sv_setiv(sv, (IV)PL_hints);
556 case '\011': /* ^I */ /* NOT \t in EBCDIC */
558 sv_setpv(sv, PL_inplace);
560 sv_setsv(sv, &PL_sv_undef);
562 case '\017': /* ^O */
563 sv_setpv(sv, PL_osname);
565 case '\020': /* ^P */
566 sv_setiv(sv, (IV)PL_perldb);
568 case '\023': /* ^S */
571 if (PL_lex_state != LEX_NOTPARSING)
579 case '\024': /* ^T */
581 sv_setnv(sv, PL_basetime);
583 sv_setiv(sv, (IV)PL_basetime);
586 case '\027': /* ^W */
587 sv_setiv(sv, (IV)((PL_dowarn & G_WARN_ON) == G_WARN_ON));
589 case '1': case '2': case '3': case '4':
590 case '5': case '6': case '7': case '8': case '9': case '&':
591 if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
593 * Pre-threads, this was paren = atoi(GvENAME((GV*)mg->mg_obj));
594 * XXX Does the new way break anything?
596 paren = atoi(mg->mg_ptr);
598 if (paren <= rx->nparens &&
599 (s = rx->startp[paren]) &&
600 (t = rx->endp[paren]))
607 was_tainted = PL_tainted;
612 PL_tainted = (was_tainted || RX_MATCH_TAINTED(rx));
617 sv_setsv(sv,&PL_sv_undef);
620 if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
621 paren = rx->lastparen;
625 sv_setsv(sv,&PL_sv_undef);
628 if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
629 if ((s = rx->subbeg) && rx->startp[0]) {
630 i = rx->startp[0] - s;
634 sv_setsv(sv,&PL_sv_undef);
637 if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
638 if (rx->subend && (s = rx->endp[0])) {
643 sv_setsv(sv,&PL_sv_undef);
647 if (GvIO(PL_last_in_gv)) {
648 sv_setiv(sv, (IV)IoLINES(GvIO(PL_last_in_gv)));
654 sv_setiv(sv, (IV)STATUS_CURRENT);
655 #ifdef COMPLEX_STATUS
656 LvTARGOFF(sv) = PL_statusvalue;
657 LvTARGLEN(sv) = PL_statusvalue_vms;
662 s = IoTOP_NAME(GvIOp(PL_defoutgv));
666 sv_setpv(sv,GvENAME(PL_defoutgv));
671 s = IoFMT_NAME(GvIOp(PL_defoutgv));
673 s = GvENAME(PL_defoutgv);
678 sv_setiv(sv, (IV)IoPAGE_LEN(GvIOp(PL_defoutgv)));
681 sv_setiv(sv, (IV)IoLINES_LEFT(GvIOp(PL_defoutgv)));
684 sv_setiv(sv, (IV)IoPAGE(GvIOp(PL_defoutgv)));
692 WITH_THR(sv_setiv(sv, (IV)PL_curcop->cop_arybase));
695 sv_setiv(sv, (IV)(IoFLAGS(GvIOp(PL_defoutgv)) & IOf_FLUSH) != 0 );
698 sv_setpvn(sv,PL_ofs,PL_ofslen);
701 sv_setpvn(sv,PL_ors,PL_orslen);
704 sv_setpv(sv,PL_ofmt);
708 sv_setnv(sv, (double)((errno == EVMSERR) ? vaxc$errno : errno));
709 sv_setpv(sv, errno ? Strerror(errno) : "");
712 int saveerrno = errno;
713 sv_setnv(sv, (double)errno);
715 if (errno == errno_isOS2) sv_setpv(sv, os2error(Perl_rc));
718 sv_setpv(sv, errno ? Strerror(errno) : "");
722 SvNOK_on(sv); /* what a wonderful hack! */
725 sv_setiv(sv, (IV)PL_uid);
728 sv_setiv(sv, (IV)PL_euid);
731 sv_setiv(sv, (IV)PL_gid);
732 sv_setpvf(sv, "%Vd", (IV)PL_gid);
735 sv_setiv(sv, (IV)PL_egid);
736 sv_setpvf(sv, "%Vd", (IV)PL_egid);
740 Groups_t gary[NGROUPS];
741 i = getgroups(NGROUPS,gary);
743 sv_catpvf(sv, " %Vd", (IV)gary[i]);
746 SvIOK_on(sv); /* what a wonderful hack! */
754 sv_setsv(sv, thr->errsv);
756 #endif /* USE_THREADS */
762 magic_getuvar(SV *sv, MAGIC *mg)
764 struct ufuncs *uf = (struct ufuncs *)mg->mg_ptr;
766 if (uf && uf->uf_val)
767 (*uf->uf_val)(uf->uf_index, sv);
772 magic_setenv(SV *sv, MAGIC *mg)
783 #ifdef DYNAMIC_ENV_FETCH
784 /* We just undefd an environment var. Is a replacement */
785 /* waiting in the wings? */
788 if ((valp = hv_fetch(GvHVn(PL_envgv), ptr, klen, FALSE)))
789 s = SvPV(*valp, len);
793 #if !defined(OS2) && !defined(AMIGAOS) && !defined(WIN32) && !defined(MSDOS)
794 /* And you'll never guess what the dog had */
795 /* in its mouth... */
797 MgTAINTEDDIR_off(mg);
799 if (s && klen == 8 && strEQ(ptr, "DCL$PATH")) {
800 char pathbuf[256], eltbuf[256], *cp, *elt = s;
804 do { /* DCL$PATH may be a search list */
805 while (1) { /* as may dev portion of any element */
806 if ( ((cp = strchr(elt,'[')) || (cp = strchr(elt,'<'))) ) {
807 if ( *(cp+1) == '.' || *(cp+1) == '-' ||
808 cando_by_name(S_IWUSR,0,elt) ) {
813 if ((cp = strchr(elt, ':')) != Nullch)
815 if (my_trnlnm(elt, eltbuf, j++))
821 } while (my_trnlnm(s, pathbuf, i++) && (elt = pathbuf));
824 if (s && klen == 4 && strEQ(ptr,"PATH")) {
825 char *strend = s + len;
830 s = delimcpy(tmpbuf, tmpbuf + sizeof tmpbuf,
833 if (i >= sizeof tmpbuf /* too long -- assume the worst */
835 || (PerlLIO_stat(tmpbuf, &st) == 0 && (st.st_mode & 2)) ) {
842 #endif /* neither OS2 nor AMIGAOS nor WIN32 nor MSDOS */
848 magic_clearenv(SV *sv, MAGIC *mg)
851 my_setenv(MgPV(mg,n_a),Nullch);
856 magic_set_all_env(SV *sv, MAGIC *mg)
859 die("Can't make list assignment to %%ENV on this system");
865 magic_clear_all_env(sv,mg);
866 hv_iterinit((HV*)sv);
867 while (entry = hv_iternext((HV*)sv)) {
869 my_setenv(hv_iterkey(entry, &keylen),
870 SvPV(hv_iterval((HV*)sv, entry), n_a));
878 magic_clear_all_env(SV *sv, MAGIC *mg)
881 die("Can't make list assignment to %%ENV on this system");
884 char *envv = GetEnvironmentStrings();
888 char *end = strchr(cur,'=');
889 if (end && end != cur) {
891 my_setenv(cur,Nullch);
893 cur = end + strlen(end+1)+2;
895 else if ((len = strlen(cur)))
898 FreeEnvironmentStrings(envv);
900 # ifndef PERL_USE_SAFE_PUTENV
903 if (environ == PL_origenviron)
904 environ = (char**)safesysmalloc(sizeof(char*));
906 for (i = 0; environ[i]; i++)
907 safesysfree(environ[i]);
908 # endif /* PERL_USE_SAFE_PUTENV */
918 magic_getsig(SV *sv, MAGIC *mg)
922 /* Are we fetching a signal entry? */
923 i = whichsig(MgPV(mg,n_a));
926 sv_setsv(sv,PL_psig_ptr[i]);
928 Sighandler_t sigstate = rsignal_state(i);
930 /* cache state so we don't fetch it again */
931 if(sigstate == SIG_IGN)
932 sv_setpv(sv,"IGNORE");
934 sv_setsv(sv,&PL_sv_undef);
935 PL_psig_ptr[i] = SvREFCNT_inc(sv);
942 magic_clearsig(SV *sv, MAGIC *mg)
946 /* Are we clearing a signal entry? */
947 i = whichsig(MgPV(mg,n_a));
950 SvREFCNT_dec(PL_psig_ptr[i]);
953 if(PL_psig_name[i]) {
954 SvREFCNT_dec(PL_psig_name[i]);
962 magic_setsig(SV *sv, MAGIC *mg)
972 if (strEQ(s,"__DIE__"))
974 else if (strEQ(s,"__WARN__"))
976 else if (strEQ(s,"__PARSE__"))
979 croak("No such hook: %s", s);
987 i = whichsig(s); /* ...no, a brick */
989 if (ckWARN(WARN_SIGNAL) || strEQ(s,"ALARM"))
990 warner(WARN_SIGNAL, "No such signal: SIG%s", s);
993 SvREFCNT_dec(PL_psig_name[i]);
994 SvREFCNT_dec(PL_psig_ptr[i]);
995 PL_psig_ptr[i] = SvREFCNT_inc(sv);
996 SvTEMP_off(sv); /* Make sure it doesn't go away on us */
997 PL_psig_name[i] = newSVpvn(s, len);
998 SvREADONLY_on(PL_psig_name[i]);
1000 if (SvTYPE(sv) == SVt_PVGV || SvROK(sv)) {
1002 (void)rsignal(i, PL_sighandlerp);
1004 *svp = SvREFCNT_inc(sv);
1007 s = SvPV_force(sv,len);
1008 if (strEQ(s,"IGNORE")) {
1010 (void)rsignal(i, SIG_IGN);
1014 else if (strEQ(s,"DEFAULT") || !*s) {
1016 (void)rsignal(i, SIG_DFL);
1022 * We should warn if HINT_STRICT_REFS, but without
1023 * access to a known hint bit in a known OP, we can't
1024 * tell whether HINT_STRICT_REFS is in force or not.
1026 if (!strchr(s,':') && !strchr(s,'\''))
1027 sv_insert(sv, 0, 0, "main::", 6);
1029 (void)rsignal(i, PL_sighandlerp);
1031 *svp = SvREFCNT_inc(sv);
1037 magic_setisa(SV *sv, MAGIC *mg)
1039 PL_sub_generation++;
1044 magic_setamagic(SV *sv, MAGIC *mg)
1046 /* HV_badAMAGIC_on(Sv_STASH(sv)); */
1047 PL_amagic_generation++;
1053 magic_getnkeys(SV *sv, MAGIC *mg)
1055 HV *hv = (HV*)LvTARG(sv);
1060 (void) hv_iterinit(hv);
1061 if (! SvTIED_mg((SV*)hv, 'P'))
1065 while (entry = hv_iternext(hv)) {
1071 sv_setiv(sv, (IV)i);
1076 magic_setnkeys(SV *sv, MAGIC *mg)
1079 hv_ksplit((HV*)LvTARG(sv), SvIV(sv));
1084 /* caller is responsible for stack switching/cleanup */
1086 magic_methcall(SV *sv, MAGIC *mg, char *meth, I32 flags, int n, SV *val)
1092 PUSHs(SvTIED_obj(sv, mg));
1095 if (mg->mg_len >= 0)
1096 PUSHs(sv_2mortal(newSVpvn(mg->mg_ptr, mg->mg_len)));
1097 else if (mg->mg_len == HEf_SVKEY)
1098 PUSHs((SV*)mg->mg_ptr);
1100 else if (mg->mg_type == 'p') {
1101 PUSHs(sv_2mortal(newSViv(mg->mg_len)));
1109 return perl_call_method(meth, flags);
1113 magic_methpack(SV *sv, MAGIC *mg, char *meth)
1119 PUSHSTACKi(PERLSI_MAGIC);
1121 if (magic_methcall(sv, mg, meth, G_SCALAR, 2, NULL)) {
1122 sv_setsv(sv, *PL_stack_sp--);
1132 magic_getpack(SV *sv, MAGIC *mg)
1134 magic_methpack(sv,mg,"FETCH");
1136 mg->mg_flags |= MGf_GSKIP;
1141 magic_setpack(SV *sv, MAGIC *mg)
1145 PUSHSTACKi(PERLSI_MAGIC);
1146 magic_methcall(sv, mg, "STORE", G_SCALAR|G_DISCARD, 3, sv);
1153 magic_clearpack(SV *sv, MAGIC *mg)
1155 return magic_methpack(sv,mg,"DELETE");
1160 magic_sizepack(SV *sv, MAGIC *mg)
1167 PUSHSTACKi(PERLSI_MAGIC);
1168 if (magic_methcall(sv, mg, "FETCHSIZE", G_SCALAR, 2, NULL)) {
1169 sv = *PL_stack_sp--;
1170 retval = (U32) SvIV(sv)-1;
1178 int magic_wipepack(SV *sv, MAGIC *mg)
1183 PUSHSTACKi(PERLSI_MAGIC);
1185 XPUSHs(SvTIED_obj(sv, mg));
1187 perl_call_method("CLEAR", G_SCALAR|G_DISCARD);
1194 magic_nextpack(SV *sv, MAGIC *mg, SV *key)
1197 char *meth = SvOK(key) ? "NEXTKEY" : "FIRSTKEY";
1201 PUSHSTACKi(PERLSI_MAGIC);
1204 PUSHs(SvTIED_obj(sv, mg));
1209 if (perl_call_method(meth, G_SCALAR))
1210 sv_setsv(key, *PL_stack_sp--);
1219 magic_existspack(SV *sv, MAGIC *mg)
1221 return magic_methpack(sv,mg,"EXISTS");
1225 magic_setdbline(SV *sv, MAGIC *mg)
1236 svp = av_fetch(GvAV(gv),
1237 atoi(MgPV(mg,n_a)), FALSE);
1238 if (svp && SvIOKp(*svp) && (o = (OP*)SvSTASH(*svp)))
1241 warn("Can't break at that line\n");
1246 magic_getarylen(SV *sv, MAGIC *mg)
1249 sv_setiv(sv, AvFILL((AV*)mg->mg_obj) + PL_curcop->cop_arybase);
1254 magic_setarylen(SV *sv, MAGIC *mg)
1257 av_fill((AV*)mg->mg_obj, SvIV(sv) - PL_curcop->cop_arybase);
1262 magic_getpos(SV *sv, MAGIC *mg)
1264 SV* lsv = LvTARG(sv);
1266 if (SvTYPE(lsv) >= SVt_PVMG && SvMAGIC(lsv)) {
1267 mg = mg_find(lsv, 'g');
1268 if (mg && mg->mg_len >= 0) {
1272 sv_pos_b2u(lsv, &i);
1273 sv_setiv(sv, i + PL_curcop->cop_arybase);
1282 magic_setpos(SV *sv, MAGIC *mg)
1284 SV* lsv = LvTARG(sv);
1292 if (SvTYPE(lsv) >= SVt_PVMG && SvMAGIC(lsv))
1293 mg = mg_find(lsv, 'g');
1297 sv_magic(lsv, (SV*)0, 'g', Nullch, 0);
1298 mg = mg_find(lsv, 'g');
1300 else if (!SvOK(sv)) {
1304 len = SvPOK(lsv) ? SvCUR(lsv) : sv_len(lsv);
1306 pos = SvIV(sv) - PL_curcop->cop_arybase;
1309 ulen = sv_len_utf8(lsv);
1326 sv_pos_u2b(lsv, &p, 0);
1331 mg->mg_flags &= ~MGf_MINMATCH;
1337 magic_getglob(SV *sv, MAGIC *mg)
1339 if (SvFAKE(sv)) { /* FAKE globs can get coerced */
1341 gv_efullname3(sv,((GV*)sv), "*");
1345 gv_efullname3(sv,((GV*)sv), "*"); /* a gv value, be nice */
1350 magic_setglob(SV *sv, MAGIC *mg)
1359 if (*s == '*' && s[1])
1361 gv = gv_fetchpv(s,TRUE, SVt_PVGV);
1366 GvGP(sv) = gp_ref(GvGP(gv));
1371 magic_getsubstr(SV *sv, MAGIC *mg)
1374 SV *lsv = LvTARG(sv);
1375 char *tmps = SvPV(lsv,len);
1376 I32 offs = LvTARGOFF(sv);
1377 I32 rem = LvTARGLEN(sv);
1381 if (rem + offs > len)
1383 sv_setpvn(sv, tmps + offs, (STRLEN)rem);
1388 magic_setsubstr(SV *sv, MAGIC *mg)
1391 char *tmps = SvPV(sv,len);
1392 sv_insert(LvTARG(sv),LvTARGOFF(sv),LvTARGLEN(sv), tmps, len);
1397 magic_gettaint(SV *sv, MAGIC *mg)
1400 TAINT_IF((mg->mg_len & 1) ||
1401 (mg->mg_len & 2) && mg->mg_obj == sv); /* kludge */
1406 magic_settaint(SV *sv, MAGIC *mg)
1409 if (PL_localizing) {
1410 if (PL_localizing == 1)
1415 else if (PL_tainted)
1423 magic_getvec(SV *sv, MAGIC *mg)
1425 SV *lsv = LvTARG(sv);
1427 unsigned long retnum;
1437 s = (unsigned char *) SvPV(lsv, lsvlen);
1438 offset = LvTARGOFF(sv);
1439 size = LvTARGLEN(sv);
1440 len = (offset + size + 7) / 8;
1442 /* Copied from pp_vec() */
1450 if (offset >= lsvlen)
1453 retnum = (unsigned long) s[offset] << 8;
1455 else if (size == 32) {
1456 if (offset >= lsvlen)
1458 else if (offset + 1 >= lsvlen)
1459 retnum = (unsigned long) s[offset] << 24;
1460 else if (offset + 2 >= lsvlen)
1461 retnum = ((unsigned long) s[offset] << 24) +
1462 ((unsigned long) s[offset + 1] << 16);
1464 retnum = ((unsigned long) s[offset] << 24) +
1465 ((unsigned long) s[offset + 1] << 16) +
1466 (s[offset + 2] << 8);
1471 retnum = (s[offset >> 3] >> (offset & 7)) & ((1 << size) - 1);
1476 else if (size == 16)
1477 retnum = ((unsigned long) s[offset] << 8) + s[offset+1];
1478 else if (size == 32)
1479 retnum = ((unsigned long) s[offset] << 24) +
1480 ((unsigned long) s[offset + 1] << 16) +
1481 (s[offset + 2] << 8) + s[offset+3];
1484 sv_setuv(sv, (UV)retnum);
1489 magic_setvec(SV *sv, MAGIC *mg)
1491 do_vecset(sv); /* XXX slurp this routine */
1496 magic_getdefelem(SV *sv, MAGIC *mg)
1499 if (LvTARGLEN(sv)) {
1501 SV *ahv = LvTARG(sv);
1502 if (SvTYPE(ahv) == SVt_PVHV) {
1503 HE *he = hv_fetch_ent((HV*)ahv, mg->mg_obj, FALSE, 0);
1508 SV **svp = avhv_fetch_ent((AV*)ahv, mg->mg_obj, FALSE, 0);
1514 AV* av = (AV*)LvTARG(sv);
1515 if ((I32)LvTARGOFF(sv) <= AvFILL(av))
1516 targ = AvARRAY(av)[LvTARGOFF(sv)];
1518 if (targ && targ != &PL_sv_undef) {
1519 dTHR; /* just for SvREFCNT_dec */
1520 /* somebody else defined it for us */
1521 SvREFCNT_dec(LvTARG(sv));
1522 LvTARG(sv) = SvREFCNT_inc(targ);
1524 SvREFCNT_dec(mg->mg_obj);
1525 mg->mg_obj = Nullsv;
1526 mg->mg_flags &= ~MGf_REFCOUNTED;
1531 sv_setsv(sv, targ ? targ : &PL_sv_undef);
1536 magic_setdefelem(SV *sv, MAGIC *mg)
1541 sv_setsv(LvTARG(sv), sv);
1542 SvSETMAGIC(LvTARG(sv));
1548 vivify_defelem(SV *sv)
1550 dTHR; /* just for SvREFCNT_inc and SvREFCNT_dec*/
1554 if (!LvTARGLEN(sv) || !(mg = mg_find(sv, 'y')))
1557 SV *ahv = LvTARG(sv);
1559 if (SvTYPE(ahv) == SVt_PVHV) {
1560 HE *he = hv_fetch_ent((HV*)ahv, mg->mg_obj, TRUE, 0);
1565 SV **svp = avhv_fetch_ent((AV*)ahv, mg->mg_obj, TRUE, 0);
1569 if (!value || value == &PL_sv_undef)
1570 croak(PL_no_helem, SvPV(mg->mg_obj, n_a));
1573 AV* av = (AV*)LvTARG(sv);
1574 if ((I32)LvTARGLEN(sv) < 0 && (I32)LvTARGOFF(sv) > AvFILL(av))
1575 LvTARG(sv) = Nullsv; /* array can't be extended */
1577 SV** svp = av_fetch(av, LvTARGOFF(sv), TRUE);
1578 if (!svp || (value = *svp) == &PL_sv_undef)
1579 croak(PL_no_aelem, (I32)LvTARGOFF(sv));
1582 (void)SvREFCNT_inc(value);
1583 SvREFCNT_dec(LvTARG(sv));
1586 SvREFCNT_dec(mg->mg_obj);
1587 mg->mg_obj = Nullsv;
1588 mg->mg_flags &= ~MGf_REFCOUNTED;
1592 magic_setmglob(SV *sv, MAGIC *mg)
1600 magic_setbm(SV *sv, MAGIC *mg)
1602 sv_unmagic(sv, 'B');
1608 magic_setfm(SV *sv, MAGIC *mg)
1610 sv_unmagic(sv, 'f');
1616 magic_setuvar(SV *sv, MAGIC *mg)
1618 struct ufuncs *uf = (struct ufuncs *)mg->mg_ptr;
1620 if (uf && uf->uf_set)
1621 (*uf->uf_set)(uf->uf_index, sv);
1626 magic_freeregexp(SV *sv, MAGIC *mg)
1628 regexp *re = (regexp *)mg->mg_obj;
1633 #ifdef USE_LOCALE_COLLATE
1635 magic_setcollxfrm(SV *sv, MAGIC *mg)
1638 * RenE<eacute> Descartes said "I think not."
1639 * and vanished with a faint plop.
1642 Safefree(mg->mg_ptr);
1648 #endif /* USE_LOCALE_COLLATE */
1651 magic_set(SV *sv, MAGIC *mg)
1657 switch (*mg->mg_ptr) {
1658 case '\001': /* ^A */
1659 sv_setsv(PL_bodytarget, sv);
1661 case '\002': /* ^B */
1662 if ( ! (PL_dowarn & G_WARN_ALL_MASK)) {
1663 if (memEQ(SvPVX(sv), WARN_ALLstring, WARNsize))
1664 PL_compiling.cop_warnings = WARN_ALL;
1665 else if (memEQ(SvPVX(sv), WARN_NONEstring, WARNsize))
1666 PL_compiling.cop_warnings = WARN_NONE;
1668 if (PL_compiling.cop_warnings != WARN_NONE &&
1669 PL_compiling.cop_warnings != WARN_ALL)
1670 sv_setsv(PL_compiling.cop_warnings, sv);
1672 PL_compiling.cop_warnings = newSVsv(sv) ;
1677 case '\003': /* ^C */
1678 PL_minus_c = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
1681 case '\004': /* ^D */
1682 PL_debug = (SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)) | 0x80000000;
1683 DEBUG_x(dump_all());
1685 case '\005': /* ^E */
1687 set_vaxc_errno(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
1690 SetLastError( SvIV(sv) );
1692 /* will anyone ever use this? */
1693 SETERRNO(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv), 4);
1697 case '\006': /* ^F */
1698 PL_maxsysfd = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
1700 case '\010': /* ^H */
1701 PL_hints = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
1703 case '\011': /* ^I */ /* NOT \t in EBCDIC */
1705 Safefree(PL_inplace);
1707 PL_inplace = savepv(SvPV(sv,len));
1709 PL_inplace = Nullch;
1711 case '\017': /* ^O */
1713 Safefree(PL_osname);
1715 PL_osname = savepv(SvPV(sv,len));
1719 case '\020': /* ^P */
1720 PL_perldb = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
1722 case '\024': /* ^T */
1724 PL_basetime = (Time_t)(SvNOK(sv) ? SvNVX(sv) : sv_2nv(sv));
1726 PL_basetime = (Time_t)(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
1729 case '\027': /* ^W */
1730 if ( ! (PL_dowarn & G_WARN_ALL_MASK)) {
1731 i = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
1732 PL_dowarn = (i ? G_WARN_ON : G_WARN_OFF) ;
1736 if (PL_localizing) {
1737 if (PL_localizing == 1)
1738 save_sptr((SV**)&PL_last_in_gv);
1740 else if (SvOK(sv) && GvIO(PL_last_in_gv))
1741 IoLINES(GvIOp(PL_last_in_gv)) = (long)SvIV(sv);
1744 Safefree(IoTOP_NAME(GvIOp(PL_defoutgv)));
1745 IoTOP_NAME(GvIOp(PL_defoutgv)) = s = savepv(SvPV(sv,len));
1746 IoTOP_GV(GvIOp(PL_defoutgv)) = gv_fetchpv(s,TRUE, SVt_PVIO);
1749 Safefree(IoFMT_NAME(GvIOp(PL_defoutgv)));
1750 IoFMT_NAME(GvIOp(PL_defoutgv)) = s = savepv(SvPV(sv,len));
1751 IoFMT_GV(GvIOp(PL_defoutgv)) = gv_fetchpv(s,TRUE, SVt_PVIO);
1754 IoPAGE_LEN(GvIOp(PL_defoutgv)) = (long)(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
1757 IoLINES_LEFT(GvIOp(PL_defoutgv)) = (long)(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
1758 if (IoLINES_LEFT(GvIOp(PL_defoutgv)) < 0L)
1759 IoLINES_LEFT(GvIOp(PL_defoutgv)) = 0L;
1762 IoPAGE(GvIOp(PL_defoutgv)) = (long)(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
1766 IO *io = GvIOp(PL_defoutgv);
1767 if ((SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)) == 0)
1768 IoFLAGS(io) &= ~IOf_FLUSH;
1770 if (!(IoFLAGS(io) & IOf_FLUSH)) {
1771 PerlIO *ofp = IoOFP(io);
1773 (void)PerlIO_flush(ofp);
1774 IoFLAGS(io) |= IOf_FLUSH;
1780 i = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
1781 PL_multiline = (i != 0);
1784 SvREFCNT_dec(PL_nrs);
1785 PL_nrs = newSVsv(sv);
1786 SvREFCNT_dec(PL_rs);
1787 PL_rs = SvREFCNT_inc(PL_nrs);
1792 if (SvOK(sv) || SvGMAGICAL(sv))
1793 PL_ors = savepv(SvPV(sv,PL_orslen));
1802 PL_ofs = savepv(SvPV(sv, PL_ofslen));
1807 PL_ofmt = savepv(SvPV(sv,len));
1810 PL_compiling.cop_arybase = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
1813 #ifdef COMPLEX_STATUS
1814 if (PL_localizing == 2) {
1815 PL_statusvalue = LvTARGOFF(sv);
1816 PL_statusvalue_vms = LvTARGLEN(sv);
1820 #ifdef VMSISH_STATUS
1822 STATUS_NATIVE_SET((U32)(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)));
1825 STATUS_POSIX_SET(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
1828 SETERRNO(SvIOK(sv) ? SvIVX(sv) : SvOK(sv) ? sv_2iv(sv) : 0,
1829 (SvIV(sv) == EVMSERR) ? 4 : vaxc$errno);
1832 PL_uid = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
1833 if (PL_delaymagic) {
1834 PL_delaymagic |= DM_RUID;
1835 break; /* don't do magic till later */
1838 (void)setruid((Uid_t)PL_uid);
1841 (void)setreuid((Uid_t)PL_uid, (Uid_t)-1);
1843 #ifdef HAS_SETRESUID
1844 (void)setresuid((Uid_t)PL_uid, (Uid_t)-1, (Uid_t)-1);
1846 if (PL_uid == PL_euid) /* special case $< = $> */
1847 (void)PerlProc_setuid(PL_uid);
1849 PL_uid = (I32)PerlProc_getuid();
1850 croak("setruid() not implemented");
1855 PL_uid = (I32)PerlProc_getuid();
1856 PL_tainting |= (PL_uid && (PL_euid != PL_uid || PL_egid != PL_gid));
1859 PL_euid = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
1860 if (PL_delaymagic) {
1861 PL_delaymagic |= DM_EUID;
1862 break; /* don't do magic till later */
1865 (void)seteuid((Uid_t)PL_euid);
1868 (void)setreuid((Uid_t)-1, (Uid_t)PL_euid);
1870 #ifdef HAS_SETRESUID
1871 (void)setresuid((Uid_t)-1, (Uid_t)PL_euid, (Uid_t)-1);
1873 if (PL_euid == PL_uid) /* special case $> = $< */
1874 PerlProc_setuid(PL_euid);
1876 PL_euid = (I32)PerlProc_geteuid();
1877 croak("seteuid() not implemented");
1882 PL_euid = (I32)PerlProc_geteuid();
1883 PL_tainting |= (PL_uid && (PL_euid != PL_uid || PL_egid != PL_gid));
1886 PL_gid = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
1887 if (PL_delaymagic) {
1888 PL_delaymagic |= DM_RGID;
1889 break; /* don't do magic till later */
1892 (void)setrgid((Gid_t)PL_gid);
1895 (void)setregid((Gid_t)PL_gid, (Gid_t)-1);
1897 #ifdef HAS_SETRESGID
1898 (void)setresgid((Gid_t)PL_gid, (Gid_t)-1, (Gid_t) 1);
1900 if (PL_gid == PL_egid) /* special case $( = $) */
1901 (void)PerlProc_setgid(PL_gid);
1903 PL_gid = (I32)PerlProc_getgid();
1904 croak("setrgid() not implemented");
1909 PL_gid = (I32)PerlProc_getgid();
1910 PL_tainting |= (PL_uid && (PL_euid != PL_uid || PL_egid != PL_gid));
1913 #ifdef HAS_SETGROUPS
1915 char *p = SvPV(sv, len);
1916 Groups_t gary[NGROUPS];
1918 SET_NUMERIC_STANDARD();
1921 PL_egid = I_V(atof(p));
1922 for (i = 0; i < NGROUPS; ++i) {
1923 while (*p && !isSPACE(*p))
1929 gary[i] = I_V(atof(p));
1932 (void)setgroups(i, gary);
1934 #else /* HAS_SETGROUPS */
1935 PL_egid = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
1936 #endif /* HAS_SETGROUPS */
1937 if (PL_delaymagic) {
1938 PL_delaymagic |= DM_EGID;
1939 break; /* don't do magic till later */
1942 (void)setegid((Gid_t)PL_egid);
1945 (void)setregid((Gid_t)-1, (Gid_t)PL_egid);
1947 #ifdef HAS_SETRESGID
1948 (void)setresgid((Gid_t)-1, (Gid_t)PL_egid, (Gid_t)-1);
1950 if (PL_egid == PL_gid) /* special case $) = $( */
1951 (void)PerlProc_setgid(PL_egid);
1953 PL_egid = (I32)PerlProc_getegid();
1954 croak("setegid() not implemented");
1959 PL_egid = (I32)PerlProc_getegid();
1960 PL_tainting |= (PL_uid && (PL_euid != PL_uid || PL_egid != PL_gid));
1963 PL_chopset = SvPV_force(sv,len);
1969 /* See if all the arguments are contiguous in memory */
1970 for (i = 1; i < PL_origargc; i++) {
1971 if (PL_origargv[i] == s + 1
1973 || PL_origargv[i] == s + 2
1978 s += strlen(s); /* this one is ok too */
1983 /* can grab env area too? */
1984 if (PL_origenviron && (PL_origenviron[0] == s + 1
1986 || (PL_origenviron[0] == s + 9 && (s += 8))
1989 my_setenv("NoNe SuCh", Nullch);
1990 /* force copy of environment */
1991 for (i = 0; PL_origenviron[i]; i++)
1992 if (PL_origenviron[i] == s + 1) {
1999 PL_origalen = s - PL_origargv[0];
2001 s = SvPV_force(sv,len);
2003 if (i >= PL_origalen) {
2005 /* don't allow system to limit $0 seen by script */
2006 /* SvCUR_set(sv, i); *SvEND(sv) = '\0'; */
2007 Copy(s, PL_origargv[0], i, char);
2008 s = PL_origargv[0]+i;
2012 Copy(s, PL_origargv[0], i, char);
2013 s = PL_origargv[0]+i;
2015 while (++i < PL_origalen)
2017 s = PL_origargv[0]+i;
2018 for (i = 1; i < PL_origargc; i++)
2019 PL_origargv[i] = Nullch;
2024 sv_setsv(thr->errsv, sv);
2026 #endif /* USE_THREADS */
2033 magic_mutexfree(SV *sv, MAGIC *mg)
2036 DEBUG_S(PerlIO_printf(PerlIO_stderr(), "0x%lx: magic_mutexfree 0x%lx\n",
2037 (unsigned long)thr, (unsigned long)sv);)
2039 croak("panic: magic_mutexfree");
2040 MUTEX_DESTROY(MgMUTEXP(mg));
2041 COND_DESTROY(MgCONDP(mg));
2044 #endif /* USE_THREADS */
2049 register char **sigv;
2051 for (sigv = PL_sig_name+1; *sigv; sigv++)
2052 if (strEQ(sig,*sigv))
2053 return PL_sig_num[sigv - PL_sig_name];
2055 if (strEQ(sig,"CHLD"))
2059 if (strEQ(sig,"CLD"))
2068 unwind_handler_stack(void *p)
2071 U32 flags = *(U32*)p;
2074 PL_savestack_ix -= 5; /* Unprotect save in progress. */
2075 /* cxstack_ix-- Not needed, die already unwound it. */
2077 SvREFCNT_dec(sig_sv);
2086 SV *sv, *tSv = PL_Sv;
2090 I32 o_save_i = PL_savestack_ix, type;
2093 if (PL_savestack_ix + 15 <= PL_savestack_max)
2095 if (PL_markstack_ptr < PL_markstack_max - 2)
2097 if (PL_retstack_ix < PL_retstack_max - 2)
2099 if (PL_scopestack_ix < PL_scopestack_max - 3)
2102 if (!PL_psig_ptr[sig])
2103 die("Signal SIG%s received, but no signal handler set.\n",
2106 /* Max number of items pushed there is 3*n or 4. We cannot fix
2107 infinity, so we fix 4 (in fact 5): */
2109 PL_savestack_ix += 5; /* Protect save in progress. */
2110 o_save_i = PL_savestack_ix;
2111 SAVEDESTRUCTOR(unwind_handler_stack, (void*)&flags);
2114 PL_markstack_ptr++; /* Protect mark. */
2117 PL_retstack[PL_retstack_ix] = NULL;
2120 PL_scopestack_ix += 1;
2121 /* sv_2cv is too complicated, try a simpler variant first: */
2122 if (!SvROK(PL_psig_ptr[sig]) || !(cv = (CV*)SvRV(PL_psig_ptr[sig]))
2123 || SvTYPE(cv) != SVt_PVCV)
2124 cv = sv_2cv(PL_psig_ptr[sig],&st,&gv,TRUE);
2126 if (!cv || !CvROOT(cv)) {
2127 if (ckWARN(WARN_SIGNAL))
2128 warner(WARN_SIGNAL, "SIG%s handler \"%s\" not defined.\n",
2129 PL_sig_name[sig], (gv ? GvENAME(gv)
2136 if(PL_psig_name[sig]) {
2137 sv = SvREFCNT_inc(PL_psig_name[sig]);
2141 sv = sv_newmortal();
2142 sv_setpv(sv,PL_sig_name[sig]);
2145 PUSHSTACKi(PERLSI_SIGNAL);
2150 perl_call_sv((SV*)cv, G_DISCARD);
2155 PL_savestack_ix -= 8; /* Unprotect save in progress. */
2161 PL_scopestack_ix -= 1;
2164 PL_op = myop; /* Apparently not needed... */
2166 PL_Sv = tSv; /* Restore global temporaries. */