{
register char *s;
char *ptr;
- STRLEN len;
+ STRLEN len, klen;
I32 i;
s = SvPV(sv,len);
- ptr = MgPV(mg);
+ ptr = MgPV(mg,klen);
my_setenv(ptr, s);
#ifdef DYNAMIC_ENV_FETCH
/* We just undefd an environment var. Is a replacement */
/* waiting in the wings? */
if (!len) {
- HE *envhe;
- SV *keysv;
- if (mg->mg_len == HEf_SVKEY)
- keysv = (SV *)mg->mg_ptr;
- else
- keysv = newSVpv(mg->mg_ptr, mg->mg_len);
- if ((envhe = hv_fetch_ent(GvHVn(envgv), keysv, FALSE, 0)))
- s = SvPV(HeVAL(envhe), len);
- if (mg->mg_len != HEf_SVKEY)
- SvREFCNT_dec(keysv);
+ SV **valp;
+ if ((valp = hv_fetch(GvHVn(envgv), ptr, klen, FALSE)))
+ s = SvPV(*valp, len);
}
#endif
if (tainting) {
MgTAINTEDDIR_off(mg);
#ifdef VMS
- if (s && strnEQ(ptr, "DCL$PATH", 8)) {
+ if (s && klen == 8 && strEQ(ptr, "DCL$PATH")) {
char pathbuf[256], eltbuf[256], *cp, *elt = s;
struct stat sbuf;
int i = 0, j = 0;
} while (my_trnlnm(s, pathbuf, i++) && (elt = pathbuf));
}
#endif /* VMS */
- if (s && strEQ(ptr,"PATH")) {
+ if (s && klen == 4 && strEQ(ptr,"PATH")) {
char *strend = s + len;
while (s < strend) {
SV* sv;
MAGIC* mg;
{
- my_setenv(MgPV(mg),Nullch);
+ my_setenv(MgPV(mg,na),Nullch);
return 0;
}
{
I32 i;
/* Are we fetching a signal entry? */
- i = whichsig(MgPV(mg));
+ i = whichsig(MgPV(mg,na));
if (i) {
if(psig_ptr[i])
sv_setsv(sv,psig_ptr[i]);
{
I32 i;
/* Are we clearing a signal entry? */
- i = whichsig(MgPV(mg));
+ i = whichsig(MgPV(mg,na));
if (i) {
if(psig_ptr[i]) {
SvREFCNT_dec(psig_ptr[i]);
I32 i;
SV** svp;
- s = MgPV(mg);
+ s = MgPV(mg,na);
if (*s == '_') {
if (strEQ(s,"__DIE__"))
svp = &diehook;
gv = DBline;
i = SvTRUE(sv);
svp = av_fetch(GvAV(gv),
- atoi(MgPV(mg)), FALSE);
+ atoi(MgPV(mg,na)), FALSE);
if (svp && SvIOKp(*svp) && (o = (OP*)SvSTASH(*svp)))
o->op_private = i;
else
#define MgTAINTEDDIR_on(mg) (mg->mg_flags |= MGf_TAINTEDDIR)
#define MgTAINTEDDIR_off(mg) (mg->mg_flags &= ~MGf_TAINTEDDIR)
-#define MgPV(mg) ((mg)->mg_len == HEf_SVKEY) ? \
- SvPV((SV*)((mg)->mg_ptr),na) : \
- (mg)->mg_ptr
+#define MgPV(mg,lp) (((lp = (mg)->mg_len) == HEf_SVKEY) ? \
+ SvPV((SV*)((mg)->mg_ptr),lp) : \
+ (mg)->mg_ptr)
HV *hv;
GvMULTI_on(envgv);
hv = GvHVn(envgv);
- hv_clear(hv);
+ hv_magic(hv, envgv, 'E');
#ifndef VMS /* VMS doesn't have environ array */
/* Note that if the supplied env parameter is actually a copy
of the global environ then it may now point to free'd memory
*/
if (!env)
env = environ;
- if (env != environ) {
+ if (env != environ)
environ[0] = Nullch;
- hv_magic(hv, envgv, 'E');
- }
for (; *env; env++) {
if (!(s = strchr(*env,'=')))
continue;
*s++ = '\0';
sv = newSVpv(s--,0);
- sv_magic(sv, sv, 'e', *env, s - *env);
(void)hv_store(hv, *env, s - *env, sv, 0);
*s = '=';
}
#ifdef DYNAMIC_ENV_FETCH
HvNAME(hv) = savepv(ENV_HV_NAME);
#endif
- hv_magic(hv, envgv, 'E');
}
TAINT_NOT;
if (tmpgv = gv_fetchpv("$",TRUE, SVt_PV))