# endif
#endif
-#define TAINT_FROM_REGEX(sv,rx) \
- if ((rx)->exec_tainted) \
- SvTAINTED_on(sv); \
- else \
- SvTAINTED_off(sv);
-
/*
* Use the "DESTRUCTOR" scope cleanup to reinstate magic.
*/
(t = rx->endp[paren]))
{
i = t - s;
- if (i >= 0) {
- TAINT_IF(rx->exec_tainted);
+ if (i >= 0)
return i;
- }
}
}
return 0;
case '+':
if (curpm && (rx = curpm->op_pmregexp)) {
paren = rx->lastparen;
- if (!paren)
- return 0;
- goto getparen;
+ if (paren)
+ goto getparen;
}
return 0;
break;
case '`':
if (curpm && (rx = curpm->op_pmregexp)) {
- if ((s = rx->subbeg)) {
+ if ((s = rx->subbeg) && rx->startp[0]) {
i = rx->startp[0] - s;
- if (i >= 0) {
- TAINT_IF(rx->exec_tainted);
+ if (i >= 0)
return i;
- }
}
}
return 0;
case '\'':
if (curpm && (rx = curpm->op_pmregexp)) {
- if ((s = rx->endp[0])) {
- TAINT_IF(rx->exec_tainted);
- return (STRLEN) (rx->subend - s);
+ if (rx->subend && (s = rx->endp[0])) {
+ i = rx->subend - s;
+ if (i >= 0)
+ return 0;
}
}
return 0;
(t = rx->endp[paren]))
{
i = t - s;
+ getrx:
if (i >= 0) {
+ bool was_tainted;
+ if (tainting) {
+ was_tainted = tainted;
+ tainted = FALSE;
+ }
sv_setpvn(sv,s,i);
- TAINT_FROM_REGEX(sv,rx);
+ if (tainting)
+ tainted = was_tainted || rx->exec_tainted;
break;
}
}
break;
case '`':
if (curpm && (rx = curpm->op_pmregexp)) {
- if ((s = rx->subbeg)) {
+ if ((s = rx->subbeg) && rx->startp[0]) {
i = rx->startp[0] - s;
- if (i >= 0) {
- sv_setpvn(sv,s,i);
- TAINT_FROM_REGEX(sv,rx);
- break;
- }
+ goto getrx;
}
}
sv_setsv(sv,&sv_undef);
break;
case '\'':
if (curpm && (rx = curpm->op_pmregexp)) {
- if ((s = rx->endp[0])) {
- sv_setpvn(sv,s, rx->subend - s);
- TAINT_FROM_REGEX(sv,rx);
- break;
+ if (rx->subend && (s = rx->endp[0])) {
+ i = rx->subend - s;
+ goto getrx;
}
}
sv_setsv(sv,&sv_undef);
#endif
break;
case '?':
- sv_setiv(sv, (IV)statusvalue);
+ sv_setiv(sv, (IV)STATUS_CURRENT);
+#ifdef COMPLEX_STATUS
+ LvTARGOFF(sv) = statusvalue;
+ LvTARGLEN(sv) = statusvalue_vms;
+#endif
break;
case '^':
s = IoTOP_NAME(GvIOp(defoutgv));
warn("No such signal: SIG%s", s);
return 0;
}
- if(psig_ptr[i])
- SvREFCNT_dec(psig_ptr[i]);
+ SvREFCNT_dec(psig_name[i]);
+ SvREFCNT_dec(psig_ptr[i]);
psig_ptr[i] = SvREFCNT_inc(sv);
- if(psig_name[i])
- SvREFCNT_dec(psig_name[i]);
- psig_name[i] = newSVpv(s,strlen(s));
SvTEMP_off(sv); /* Make sure it doesn't go away on us */
+ psig_name[i] = newSVpv(s, strlen(s));
SvREADONLY_on(psig_name[i]);
}
if (SvTYPE(sv) == SVt_PVGV || SvROK(sv)) {
else if (pos > len)
pos = len;
mg->mg_len = pos;
+ mg->mg_flags &= ~MGf_MINMATCH;
return 0;
}
if (GvGP(sv))
gp_free((GV*)sv);
GvGP(sv) = gp_ref(GvGP(gv));
- if (!GvAV(gv))
- gv_AVadd(gv);
- if (!GvHV(gv))
- gv_HVadd(gv);
- if (!GvIOp(gv))
- GvIOp(gv) = newIO();
return 0;
}
}
int
-magic_setvivary(sv,mg)
+magic_getitervar(sv,mg)
SV* sv;
MAGIC* mg;
{
+ SV *targ = Nullsv;
if (LvTARGLEN(sv)) {
AV* av = (AV*)LvTARG(sv);
- if (LvTARGOFF(sv) <= AvFILL(av)) {
- SV** svp = AvARRAY(av) + LvTARGOFF(sv);
- LvTARG(sv) = newSVsv(*svp);
- SvREFCNT_dec(*svp);
- *svp = SvREFCNT_inc(LvTARG(sv));
- }
- else
- LvTARG(sv) = Nullsv;
- LvTARGLEN(sv) = 0;
- SvREFCNT_dec(av);
+ if (LvTARGOFF(sv) <= AvFILL(av))
+ targ = AvARRAY(av)[LvTARGOFF(sv)];
}
+ else
+ targ = LvTARG(sv);
+ sv_setsv(sv, targ ? targ : &sv_undef);
+ return 0;
+}
+
+int
+magic_setitervar(sv,mg)
+SV* sv;
+MAGIC* mg;
+{
+ if (LvTARGLEN(sv))
+ vivify_itervar(sv);
if (LvTARG(sv))
sv_setsv(LvTARG(sv), sv);
return 0;
}
int
-magic_freevivary(sv,mg)
+magic_freeitervar(sv,mg)
SV* sv;
MAGIC* mg;
{
SvREFCNT_dec(LvTARG(sv));
+ return 0;
+}
+
+void
+vivify_itervar(sv)
+SV* sv;
+{
+ AV* av;
+
+ if (!LvTARGLEN(sv))
+ return;
+ av = (AV*)LvTARG(sv);
+ if (LvTARGOFF(sv) <= AvFILL(av)) {
+ SV** svp = AvARRAY(av) + LvTARGOFF(sv);
+ LvTARG(sv) = newSVsv(*svp);
+ SvREFCNT_dec(*svp);
+ *svp = SvREFCNT_inc(LvTARG(sv));
+ }
+ else
+ LvTARG(sv) = Nullsv;
+ SvREFCNT_dec(av);
+ LvTARGLEN(sv) = 0;
}
int
return 0;
}
+#ifdef USE_LOCALE_COLLATE
int
magic_setcollxfrm(sv,mg)
SV* sv;
* René Descartes said "I think not."
* and vanished with a faint plop.
*/
- sv_unmagic(sv, 'o');
+ if (mg->mg_ptr) {
+ Safefree(mg->mg_ptr);
+ mg->mg_ptr = NULL;
+ mg->mg_len = -1;
+ }
return 0;
}
+#endif /* USE_LOCALE_COLLATE */
int
magic_set(sv,mg)
#ifdef VMS
set_vaxc_errno(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
#else
- SETERRNO(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv),4); /* will anyone ever use this? */
+ /* will anyone ever use this? */
+ SETERRNO(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv), 4);
#endif
break;
case '\006': /* ^F */
case '\\':
if (ors)
Safefree(ors);
- ors = savepv(SvPV(sv,orslen));
+ if (SvOK(sv) || SvGMAGICAL(sv))
+ ors = savepv(SvPV(sv,orslen));
+ else {
+ ors = Nullch;
+ orslen = 0;
+ }
break;
case ',':
if (ofs)
compiling.cop_arybase = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
break;
case '?':
- statusvalue = FIXSTATUS(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
+#ifdef COMPLEX_STATUS
+ if (localizing == 2) {
+ statusvalue = LvTARGOFF(sv);
+ statusvalue_vms = LvTARGLEN(sv);
+ }
+ else
+#endif
+#ifdef VMSISH_STATUS
+ if (VMSISH_STATUS)
+ STATUS_NATIVE_SET((U32)(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)));
+ else
+#endif
+ STATUS_POSIX_SET(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
break;
case '!':
- SETERRNO(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv),SvIV(sv) == EVMSERR ? 4 : vaxc$errno); /* will anyone ever use this? */
+ SETERRNO(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv),
+ (SvIV(sv) == EVMSERR) ? 4 : vaxc$errno);
break;
case '<':
uid = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
SV *sv;
CV *cv;
AV *oldstack;
-
- if(!psig_ptr[sig])
- die("Signal SIG%s received, but no signal handler set.\n",
- sig_name[sig]);
+
+ if (!psig_ptr[sig])
+ die("Signal SIG%s received, but no signal handler set.\n",
+ sig_name[sig]);
cv = sv_2cv(psig_ptr[sig],&st,&gv,TRUE);
if (!cv || !CvROOT(cv)) {
if(psig_name[sig])
sv = SvREFCNT_inc(psig_name[sig]);
else {
- sv = sv_newmortal();
- sv_setpv(sv,sig_name[sig]);
+ sv = sv_newmortal();
+ sv_setpv(sv,sig_name[sig]);
}
PUSHMARK(sp);
PUSHs(sv);