From: Abhijit Menon-Sen Date: Sat, 16 Jun 2001 07:41:19 +0000 (+0530) Subject: Re: DYNAMIC_ENV_FETCH HvNAME abuse. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a3f1c6fb5f9cb8f8a03d70550bf7f1ebfba11774;p=p5sagit%2Fp5-mst-13.2.git Re: DYNAMIC_ENV_FETCH HvNAME abuse. Message-ID: <20010616074119.A24720@lustre.linux.in> p4raw-id: //depot/perl@10654 --- diff --git a/hv.c b/hv.c index 14b9682..0f695b4 100644 --- a/hv.c +++ b/hv.c @@ -188,7 +188,7 @@ Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen, I32 lval) if (!xhv->xhv_array) { if (lval #ifdef DYNAMIC_ENV_FETCH /* if it's an %ENV lookup, we may get it on the fly */ - || (HvNAME(hv) && strEQ(HvNAME(hv),ENV_HV_NAME)) + || mg_find((SV*)hv, PERL_MAGIC_env) #endif ) Newz(503, xhv->xhv_array, @@ -222,7 +222,7 @@ Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen, I32 lval) return &HeVAL(entry); } #ifdef DYNAMIC_ENV_FETCH /* %ENV lookup? If so, try to fetch the value now */ - if (HvNAME(hv) && strEQ(HvNAME(hv),ENV_HV_NAME)) { + if (mg_find((SV*)hv, PERL_MAGIC_env)) { unsigned long len; char *env = PerlEnv_ENVgetenv_len(key,&len); if (env) { @@ -317,7 +317,7 @@ Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, register U32 hash) if (!xhv->xhv_array) { if (lval #ifdef DYNAMIC_ENV_FETCH /* if it's an %ENV lookup, we may get it on the fly */ - || (HvNAME(hv) && strEQ(HvNAME(hv),ENV_HV_NAME)) + || mg_find((SV*)hv, PERL_MAGIC_env) #endif ) Newz(503, xhv->xhv_array, @@ -350,7 +350,7 @@ Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, register U32 hash) return entry; } #ifdef DYNAMIC_ENV_FETCH /* %ENV lookup? If so, try to fetch the value now */ - if (HvNAME(hv) && strEQ(HvNAME(hv),ENV_HV_NAME)) { + if (mg_find((SV*)hv, PERL_MAGIC_env)) { unsigned long len; char *env = PerlEnv_ENVgetenv_len(key,&len); if (env) { @@ -886,7 +886,7 @@ Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen) return TRUE; } #ifdef DYNAMIC_ENV_FETCH /* is it out there? */ - if (HvNAME(hv) && strEQ(HvNAME(hv), ENV_HV_NAME)) { + if (mg_find((SV*)hv, PERL_MAGIC_env)) { unsigned long len; char *env = PerlEnv_ENVgetenv_len(key,&len); if (env) { @@ -978,7 +978,7 @@ Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash) return TRUE; } #ifdef DYNAMIC_ENV_FETCH /* is it out there? */ - if (HvNAME(hv) && strEQ(HvNAME(hv), ENV_HV_NAME)) { + if (mg_find((SV*)hv, PERL_MAGIC_env)) { unsigned long len; char *env = PerlEnv_ENVgetenv_len(key,&len); if (env) { @@ -1414,7 +1414,7 @@ Perl_hv_iternext(pTHX_ HV *hv) return Null(HE*); } #ifdef DYNAMIC_ENV_FETCH /* set up %ENV for iteration */ - if (!entry && HvNAME(hv) && strEQ(HvNAME(hv), ENV_HV_NAME)) + if (!entry && mg_find((SV*)hv, PERL_MAGIC_env)) prime_env_iter(); #endif diff --git a/perl.c b/perl.c index ffb5150..a846890 100644 --- a/perl.c +++ b/perl.c @@ -3443,9 +3443,6 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register } #endif /* NEED_ENVIRON_DUP_FOR_MODIFY */ #endif /* USE_ENVIRON_ARRAY */ -#ifdef DYNAMIC_ENV_FETCH - HvNAME(hv) = savepv(ENV_HV_NAME); -#endif } TAINT_NOT; if ((tmpgv = gv_fetchpv("$",TRUE, SVt_PV))) diff --git a/vms/vmsish.h b/vms/vmsish.h index a1f7630..7f4a3b3 100644 --- a/vms/vmsish.h +++ b/vms/vmsish.h @@ -502,7 +502,6 @@ struct utimbuf { /* Look up new %ENV values on the fly */ #define DYNAMIC_ENV_FETCH 1 -#define ENV_HV_NAME "%EnV%VmS%" /* Special getenv function for retrieving %ENV elements. */ #define ENVgetenv(v) my_getenv(v,FALSE) #define ENVgetenv_len(v,l) my_getenv_len(v,l,FALSE) diff --git a/win32/win32.h b/win32/win32.h index dea3f9f..58c19c3 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -15,7 +15,6 @@ #if defined(PERL_OBJECT) || defined(PERL_IMPLICIT_SYS) || defined(PERL_CAPI) # define DYNAMIC_ENV_FETCH -# define ENV_HV_NAME "___ENV_HV_NAME___" # define HAS_GETENV_LEN # define prime_env_iter() # define WIN32IO_IS_STDIO /* don't pull in custom stdio layer */