diff options
author | Nicholas Clark <nick@ccl4.org> | 2021-09-12 10:42:25 +0000 |
---|---|---|
committer | Craig A. Berry <craigberry@mac.com> | 2021-09-12 15:54:41 -0500 |
commit | 00164771421225a404b0f24a96ce9a65e76b4215 (patch) | |
tree | 5940debbabe873a71de256e0b07eda699636b59f /pp_hot.c | |
parent | 62a725033d9327b2e97960ce74aba9fdf2f5c5bf (diff) | |
download | perl-00164771421225a404b0f24a96ce9a65e76b4215.tar.gz |
On VMS, %ENV in scalar context must call prime_env_iter()
Otherwise it will return wrong results, unless other code happens to
have iterated over %ENV. This bug has probably existed forever.
Diffstat (limited to 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -1813,6 +1813,19 @@ S_padhv_rv2hv_common(pTHX_ HV *hv, U8 gimme, bool is_keys, bool has_targ) } } else { +#if defined(DYNAMIC_ENV_FETCH) && defined(VMS) + /* maybe nothing set up %ENV for iteration yet... + do this always (not just if HvUSEDKEYS(hv) is currently 0) because + we ought to give a *consistent* answer to "how many keys?" + whether we ask this op in scalar context, or get the list of all + keys then check its length, and whether we do either with or without + an %ENV lookup first. prime_env_iter() returns quickly if nothing + needs doing. */ + if (SvRMAGICAL((const SV *)hv) + && mg_find((const SV *)hv, PERL_MAGIC_env)) { + prime_env_iter(); + } +#endif i = HvUSEDKEYS(hv); if (is_bool) { sv = i ? &PL_sv_yes : &PL_sv_zero; |