RETURN;
}
+PP(pp_gelem)
+{
+ GV *gv;
+ SV *sv;
+ SV *ref;
+ char *elem;
+ dSP;
+
+ sv = POPs;
+ elem = SvPV(sv, na);
+ gv = (GV*)POPs;
+ ref = Nullsv;
+ sv = Nullsv;
+ switch (elem ? *elem : '\0')
+ {
+ case 'A':
+ if (strEQ(elem, "ARRAY"))
+ ref = (SV*)GvAV(gv);
+ break;
+ case 'C':
+ if (strEQ(elem, "CODE"))
+ ref = (SV*)GvCV(gv);
+ break;
+ case 'F':
+ if (strEQ(elem, "FILEHANDLE"))
+ ref = (SV*)GvIOp(gv);
+ break;
+ case 'G':
+ if (strEQ(elem, "GLOB"))
+ ref = (SV*)gv;
+ break;
+ case 'H':
+ if (strEQ(elem, "HASH"))
+ ref = (SV*)GvHV(gv);
+ break;
+ case 'N':
+ if (strEQ(elem, "NAME"))
+ sv = newSVpv(GvNAME(gv), GvNAMELEN(gv));
+ break;
+ case 'P':
+ if (strEQ(elem, "PACKAGE"))
+ sv = newSVpv(HvNAME(GvSTASH(gv)), 0);
+ break;
+ case 'S':
+ if (strEQ(elem, "SCALAR"))
+ ref = GvSV(gv);
+ break;
+ }
+ if (ref)
+ sv = newRV(ref);
+ if (sv)
+ sv_2mortal(sv);
+ else
+ sv = &sv_undef;
+ XPUSHs(sv);
+ RETURN;
+}
+
PP(pp_and)
{
dSP;
s = SvPV(left,len);
sv_setpvn(TARG,s,len);
}
- else if (!SvOK(TARG))
+ else if (SvGMAGICAL(TARG))
+ mg_get(TARG);
+ else if (!SvOK(TARG)) {
+ s = SvPV_force(TARG, len);
sv_setpv(TARG, ""); /* Suppress warning. */
+ }
s = SvPV(right,len);
sv_catpvn(TARG,s,len);
SETTARG;
{
dSP; dTARGET;
XPUSHs(TARG);
- if (op->op_private & OPpLVAL_INTRO)
- SAVECLEARSV(curpad[op->op_targ]);
+ if (op->op_flags & OPf_MOD) {
+ if (op->op_private & OPpLVAL_INTRO)
+ SAVECLEARSV(curpad[op->op_targ]);
+ else if (op->op_private & (OPpDEREF_HV|OPpDEREF_AV)) {
+ SV* sv = curpad[op->op_targ];
+ if (SvGMAGICAL(sv))
+ mg_get(sv);
+ if (!SvOK(sv)) {
+ if (SvREADONLY(sv))
+ croak(no_modify);
+ (void)SvUPGRADE(sv, SVt_RV);
+ SvRV(sv) = (op->op_private & OPpDEREF_HV ?
+ (SV*)newHV() : (SV*)newAV());
+ SvROK_on(sv);
+ SvSETMAGIC(sv);
+ }
+ }
+ }
RETURN;
}
if (op->op_flags & OPf_REF ||
op->op_private & HINT_STRICT_REFS)
DIE(no_usym, "an ARRAY");
+ if (GIMME == G_ARRAY)
+ RETURN;
RETPUSHUNDEF;
}
sym = SvPV(sv,na);
if (op->op_flags & OPf_REF ||
op->op_private & HINT_STRICT_REFS)
DIE(no_usym, "a HASH");
+ if (GIMME == G_ARRAY) {
+ SP--;
+ RETURN;
+ }
RETSETUNDEF;
}
sym = SvPV(sv,na);
ary = Null(AV*);
hash = Null(HV*);
while (lelem <= lastlelem) {
+ tainted = 0; /* Each item stands on its own, taintwise. */
sv = *lelem++;
switch (SvTYPE(sv)) {
case SVt_PVAV:
(void)av_store(ary,i++,sv);
if (magic)
mg_set(sv);
+ tainted = 0;
}
break;
case SVt_PVHV: {
(void)hv_store(hash,tmps,len,tmpstr,0);
if (magic)
mg_set(tmpstr);
+ tainted = 0;
}
}
break;
if (delaymagic & DM_UID) {
#ifdef HAS_SETRESUID
(void)setresuid(uid,euid,(Uid_t)-1);
-#else /* not HAS_SETRESUID */
-#ifdef HAS_SETREUID
+#else
+# ifdef HAS_SETREUID
(void)setreuid(uid,euid);
-#else /* not HAS_SETREUID */
-#ifdef HAS_SETRUID
+# else
+# ifdef HAS_SETRUID
if ((delaymagic & DM_UID) == DM_RUID) {
(void)setruid(uid);
delaymagic &= ~DM_RUID;
}
-#endif /* HAS_SETRUID */
-#endif /* HAS_SETRESUID */
-#ifdef HAS_SETEUID
+# endif /* HAS_SETRUID */
+# ifdef HAS_SETEUID
if ((delaymagic & DM_UID) == DM_EUID) {
(void)seteuid(uid);
delaymagic &= ~DM_EUID;
}
-#endif /* HAS_SETEUID */
+# endif /* HAS_SETEUID */
if (delaymagic & DM_UID) {
if (uid != euid)
DIE("No setreuid available");
(void)setuid(uid);
}
-#endif /* not HAS_SETREUID */
+# endif /* HAS_SETREUID */
+#endif /* HAS_SETRESUID */
uid = (int)getuid();
euid = (int)geteuid();
}
if (delaymagic & DM_GID) {
#ifdef HAS_SETRESGID
(void)setresgid(gid,egid,(Gid_t)-1);
-#else /* not HAS_SETREGID */
-#ifdef HAS_SETREGID
+#else
+# ifdef HAS_SETREGID
(void)setregid(gid,egid);
-#else /* not HAS_SETREGID */
-#endif /* not HAS_SETRESGID */
-#ifdef HAS_SETRGID
+# else
+# ifdef HAS_SETRGID
if ((delaymagic & DM_GID) == DM_RGID) {
(void)setrgid(gid);
delaymagic &= ~DM_RGID;
}
-#endif /* HAS_SETRGID */
-#ifdef HAS_SETRESGID
- (void)setresgid(gid,egid,(Gid_t)-1);
-#else /* not HAS_SETREGID */
-#ifdef HAS_SETEGID
+# endif /* HAS_SETRGID */
+# ifdef HAS_SETEGID
if ((delaymagic & DM_GID) == DM_EGID) {
(void)setegid(gid);
delaymagic &= ~DM_EGID;
}
-#endif /* HAS_SETEGID */
+# endif /* HAS_SETEGID */
if (delaymagic & DM_GID) {
if (gid != egid)
DIE("No setregid available");
(void)setgid(gid);
}
-#endif /* not HAS_SETRESGID */
-#endif /* not HAS_SETREGID */
+# endif /* HAS_SETREGID */
+#endif /* HAS_SETRESGID */
gid = (int)getgid();
egid = (int)getegid();
}
- tainting |= (euid != uid || egid != gid);
+ tainting |= (uid && (euid != uid || egid != gid));
}
delaymagic = 0;
if (GIMME == G_ARRAY) {
RETURN;
}
else {
+ dTARGET;
SP = firstrelem;
- for (relem = firstrelem; relem <= lastrelem; ++relem) {
- if (SvOK(*relem)) {
- dTARGET;
- SETi(lastrelem - firstrelem + 1);
- RETURN;
- }
- }
- RETSETUNDEF;
+ SETi(lastrelem - firstrelem + 1);
+ RETURN;
}
}
I32 gimme = GIMME;
STRLEN len;
I32 minmatch = 0;
+ I32 oldsave = savestack_ix;
if (op->op_flags & OPf_STACKED)
TARG = POPs;
pm->op_pmshort = Nullsv; /* opt is being useless */
}
}
- if (regexec(rx, s, strend, truebase, minmatch,
+ if (pregexec(rx, s, strend, truebase, minmatch,
SvSCREAM(TARG) ? TARG : Nullsv,
safebase)) {
curpm = pm;
++rx->endp[0];
goto play_it_again;
}
+ LEAVE_SCOPE(oldsave);
RETURN;
}
else {
else
mg->mg_len = -1;
}
+ LEAVE_SCOPE(oldsave);
RETPUSHYES;
}
tmps = rx->startp[0] = tmps + (s - t);
rx->endp[0] = tmps + SvCUR(pm->op_pmshort);
}
+ LEAVE_SCOPE(oldsave);
RETPUSHYES;
nope:
mg->mg_len = -1;
}
}
+ LEAVE_SCOPE(oldsave);
if (gimme == G_ARRAY)
RETURN;
RETPUSHNO;
if (ok && sts != RMS$_NMF &&
sts != RMS$_DNF && sts != RMS$_FNF) ok = 0;
if (!ok) {
+ if (!(sts & 1)) {
+ SETERRNO((sts == RMS$_SYN ? EINVAL : EVMSERR),sts);
+ }
+ fclose(tmpfp);
fp = NULL;
}
else {
sv_setpvn(tmpcmd, cshname, cshlen);
sv_catpv(tmpcmd, " -cf 'set nonomatch; glob ");
sv_catsv(tmpcmd, tmpglob);
- sv_catpv(tmpcmd, "'|");
+ sv_catpv(tmpcmd, "' 2>/dev/null |");
#else
sv_setpv(tmpcmd, "echo ");
sv_catsv(tmpcmd, tmpglob);
#endif
#endif /* !CSH */
#endif /* !MSDOS */
- (void)do_open(last_in_gv, SvPVX(tmpcmd), SvCUR(tmpcmd),Nullfp);
+ (void)do_open(last_in_gv, SvPVX(tmpcmd), SvCUR(tmpcmd),
+ FALSE, 0, 0, Nullfp);
fp = IoIFP(io);
#endif /* !VMS */
LEAVE;
SP--;
}
if (!fp) {
- if (dowarn && !(IoFLAGS(io) & IOf_START))
+ if (dowarn && io && !(IoFLAGS(io) & IOf_START))
warn("Read on closed filehandle <%s>", GvENAME(last_in_gv));
if (GIMME == G_SCALAR) {
(void)SvOK_off(TARG);
if (type == OP_GLOB) {
char *tmps;
- if (SvCUR(sv) > 0)
- SvCUR(sv)--;
- if (*SvEND(sv) == rschar)
- *SvEND(sv) = '\0';
- else
- SvCUR(sv)++;
+ if (SvCUR(sv) > 0 && SvCUR(rs) > 0) {
+ tmps = SvEND(sv) - 1;
+ if (*tmps == *SvPVX(rs)) {
+ *tmps = '\0';
+ SvCUR(sv)--;
+ }
+ }
for (tmps = SvPVX(sv); *tmps; tmps++)
if (!isALPHA(*tmps) && !isDIGIT(*tmps) &&
strchr("$&*(){}[]'\";\\|?<>~`", *tmps))
dSP;
register CONTEXT *cx;
SV *sv;
+ AV* av;
EXTEND(sp, 1);
cx = &cxstack[cxstack_ix];
if (cx->cx_type != CXt_LOOP)
DIE("panic: pp_iter");
+ av = cx->blk_loop.iterary;
+ if (av == stack && cx->blk_loop.iterix >= cx->blk_oldsp)
+ RETPUSHNO;
- if (cx->blk_loop.iterix >= cx->blk_oldsp)
+ if (cx->blk_loop.iterix >= AvFILL(av))
RETPUSHNO;
- if (sv = AvARRAY(cx->blk_loop.iterary)[++cx->blk_loop.iterix]) {
+ if (sv = AvARRAY(av)[++cx->blk_loop.iterix]) {
SvTEMP_off(sv);
*cx->blk_loop.itervar = sv;
}
register REGEXP *rx = pm->op_pmregexp;
STRLEN len;
int force_on_match = 0;
+ I32 oldsave = savestack_ix;
if (pm->op_pmflags & PMf_CONST) /* known replacement string? */
dstr = POPs;
EXTEND(SP,1);
}
s = SvPV(TARG, len);
- if (!SvPOKp(TARG) || SvREADONLY(TARG))
+ if (!SvPOKp(TARG) || SvREADONLY(TARG) || (SvTYPE(TARG) == SVt_PVGV))
force_on_match = 1;
force_it:
c = SvPV(dstr, clen);
if (clen <= rx->minlen) {
/* can do inplace substitution */
- if (regexec(rx, s, strend, orig, 0,
+ if (pregexec(rx, s, strend, orig, 0,
SvSCREAM(TARG) ? TARG : Nullsv, safebase)) {
if (force_on_match) {
force_on_match = 0;
(void)SvPOK_only(TARG);
SvSETMAGIC(TARG);
PUSHs(&sv_yes);
+ LEAVE_SCOPE(oldsave);
RETURN;
}
/*SUPPRESS 560*/
(void)SvPOK_only(TARG);
SvSETMAGIC(TARG);
PUSHs(&sv_yes);
+ LEAVE_SCOPE(oldsave);
RETURN;
}
else if (clen) {
(void)SvPOK_only(TARG);
SvSETMAGIC(TARG);
PUSHs(&sv_yes);
+ LEAVE_SCOPE(oldsave);
RETURN;
}
else {
(void)SvPOK_only(TARG);
SvSETMAGIC(TARG);
PUSHs(&sv_yes);
+ LEAVE_SCOPE(oldsave);
RETURN;
}
/* NOTREACHED */
d += clen;
}
s = rx->endp[0];
- } while (regexec(rx, s, strend, orig, s == m,
+ } while (pregexec(rx, s, strend, orig, s == m,
Nullsv, TRUE)); /* (don't match same null twice) */
if (s != d) {
i = strend - s;
(void)SvPOK_only(TARG);
SvSETMAGIC(TARG);
PUSHs(sv_2mortal(newSViv((I32)iters)));
+ LEAVE_SCOPE(oldsave);
RETURN;
}
PUSHs(&sv_no);
+ LEAVE_SCOPE(oldsave);
RETURN;
}
}
else
c = Nullch;
- if (regexec(rx, s, strend, orig, 0,
+ if (pregexec(rx, s, strend, orig, 0,
SvSCREAM(TARG) ? TARG : Nullsv, safebase)) {
long_way:
if (force_on_match) {
sv_catpvn(dstr, c, clen);
if (once)
break;
- } while (regexec(rx, s, strend, orig, s == m, Nullsv,
+ } while (pregexec(rx, s, strend, orig, s == m, Nullsv,
safebase));
sv_catpvn(dstr, s, strend - s);
+ (void)SvOOK_off(TARG);
Safefree(SvPVX(TARG));
SvPVX(TARG) = SvPVX(dstr);
SvCUR_set(TARG, SvCUR(dstr));
(void)SvPOK_only(TARG);
SvSETMAGIC(TARG);
PUSHs(sv_2mortal(newSViv((I32)iters)));
+ LEAVE_SCOPE(oldsave);
RETURN;
}
PUSHs(&sv_no);
+ LEAVE_SCOPE(oldsave);
RETURN;
nope:
++BmUSEFUL(pm->op_pmshort);
PUSHs(&sv_no);
+ LEAVE_SCOPE(oldsave);
RETURN;
}
HV *stash;
register CV *cv;
register CONTEXT *cx;
+ I32 gimme;
if (!sv)
DIE("Not a CODE reference");
if (!CvROOT(cv) && !CvXSUB(cv)) {
if (gv = CvGV(cv)) {
- SV *tmpstr = sv_newmortal();
+ SV *tmpstr;
GV *ngv;
+ if (SvFAKE(cv) && GvCV(gv) != cv) { /* autoloaded stub? */
+ cv = GvCV(gv);
+ if (SvTYPE(sv) == SVt_PVGV) {
+ SvREFCNT_dec(GvCV((GV*)sv));
+ GvCV((GV*)sv) = (CV*)SvREFCNT_inc((SV*)cv);
+ }
+ goto retry;
+ }
+ tmpstr = sv_newmortal();
gv_efullname(tmpstr, gv);
ngv = gv_fetchmethod(GvESTASH(gv), "AUTOLOAD");
if (ngv && ngv != gv && (cv = GvCV(ngv))) { /* One more chance... */
gv = ngv;
sv_setsv(GvSV(CvGV(cv)), tmpstr); /* Set CV's $AUTOLOAD */
+ if (tainting)
+ sv_unmagic(GvSV(CvGV(cv)), 't');
goto retry;
}
else
DIE("Undefined subroutine called");
}
- if ((op->op_private & OPpDEREF_DB) && !CvXSUB(cv)) {
+ gimme = GIMME;
+ if ((op->op_private & OPpENTERSUB_DB) && !CvXSUB(cv)) {
sv = GvSV(DBsub);
save_item(sv);
- if (SvFLAGS(cv) & SVpcv_ANON) /* Is GV potentially non-unique? */
+ if (SvFLAGS(cv) & (SVpcv_ANON | SVpcv_CLONED)) /* Is GV potentially non-unique? */
sv_setsv(sv, newRV((SV*)cv));
else {
gv = CvGV(cv);
(void)(*CvXSUB(cv))(cv);
/* Enforce some sanity in scalar context. */
- if (GIMME == G_SCALAR && ++markix != stack_sp - stack_base ) {
+ if (gimme == G_SCALAR && ++markix != stack_sp - stack_base ) {
if (markix > stack_sp - stack_base)
*(stack_base + markix) = &sv_undef;
else
dMARK;
register I32 items = SP - MARK;
I32 hasargs = (op->op_flags & OPf_STACKED) != 0;
- I32 gimme = GIMME;
AV* padlist = CvPADLIST(cv);
SV** svp = AvARRAY(padlist);
push_return(op->op_next);
if (CvDEPTH(cv) > AvFILL(padlist)) {
AV *av;
AV *newpad = newAV();
- AV *oldpad = (AV*)AvARRAY(svp[CvDEPTH(cv)-1]);
+ SV **oldpad = AvARRAY(svp[CvDEPTH(cv)-1]);
I32 ix = AvFILL((AV*)svp[1]);
svp = AvARRAY(svp[0]);
for ( ;ix > 0; ix--) {
char *name = SvPVX(svp[ix]);
if (SvFLAGS(svp[ix]) & SVf_FAKE) { /* outer lexical? */
av_store(newpad, ix,
- SvREFCNT_inc(AvARRAY(oldpad)[ix]) );
+ SvREFCNT_inc(oldpad[ix]) );
}
else { /* our own lexical */
if (*name == '@')
sv = *(stack_base + TOPMARK + 1);
gv = 0;
+ if (SvGMAGICAL(sv))
+ mg_get(sv);
if (SvROK(sv))
- ob = SvRV(sv);
+ ob = (SV*)SvRV(sv);
else {
GV* iogv;
char* packname = 0;
SETs(gv);
RETURN;
}
- *(stack_base + TOPMARK + 1) = iogv;
+ *(stack_base + TOPMARK + 1) = sv_2mortal(newRV(iogv));
}
if (!ob || !SvOBJECT(ob)) {