X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=hv.c;h=32503a9366c24aa866e72cbff0bff69259ae69ba;hb=b2b4ec814a5af6e0a2f7557c1a67c4b86af2f630;hp=f1598cbee8e7e8a8d5a65907b6489d31deb9e1a3;hpb=a02a5408b2f199007c4dcb74559cc79066307ada;p=p5sagit%2Fp5-mst-13.2.git diff --git a/hv.c b/hv.c index f1598cb..32503a9 100644 --- a/hv.c +++ b/hv.c @@ -1261,7 +1261,7 @@ S_hsplit(pTHX_ HV *hv) if (was_shared) { /* Unshare it. */ - HEK *new_hek + HEK * const new_hek = save_hek_flags(HeKEY(entry), HeKLEN(entry), hash, HeKFLAGS(entry)); unshare_hek (HeKEY_hek(entry)); @@ -1417,14 +1417,15 @@ Perl_newHVhv(pTHX_ HV *ohv) /* It's an ordinary hash, so copy it fast. AMS 20010804 */ STRLEN i; const bool shared = !!HvSHAREKEYS(ohv); - HE **ents, **oents = (HE **)HvARRAY(ohv); + HE **ents, ** const oents = (HE **)HvARRAY(ohv); char *a; Newx(a, PERL_HV_ARRAY_ALLOC_BYTES(hv_max+1), char); ents = (HE**)a; /* In each bucket... */ for (i = 0; i <= hv_max; i++) { - HE *prev = NULL, *ent = NULL, *oent = oents[i]; + HE *prev = NULL, *ent = NULL; + HE *oent = oents[i]; if (!oent) { ents[i] = NULL; @@ -1432,7 +1433,7 @@ Perl_newHVhv(pTHX_ HV *ohv) } /* Copy the linked list of entries. */ - for (oent = oents[i]; oent; oent = HeNEXT(oent)) { + for (; oent; oent = HeNEXT(oent)) { const U32 hash = HeHASH(oent); const char * const key = HeKEY(oent); const STRLEN len = HeKLEN(oent); @@ -1456,7 +1457,7 @@ Perl_newHVhv(pTHX_ HV *ohv) HvFILL(hv) = hv_fill; HvTOTALKEYS(hv) = HvTOTALKEYS(ohv); HvARRAY(hv) = ents; - } + } /* not magical */ else { /* Iterate over ohv, copying keys and values one at a time. */ HE *entry; @@ -1667,7 +1668,7 @@ S_hfreeentries(pTHX_ HV *hv) entry = array[0]; for (;;) { if (entry) { - register HE *oentry = entry; + register HE * const oentry = entry; entry = HeNEXT(entry); hv_free_ent(hv, oentry); } @@ -1729,7 +1730,7 @@ Perl_hv_undef(pTHX_ HV *hv) if ((name = HvNAME_get(hv))) { if(PL_stashcache) hv_delete(PL_stashcache, name, HvNAMELEN_get(hv), G_DISCARD); - Perl_hv_name_set(aTHX_ hv, 0, 0, 0); + Perl_hv_name_set(aTHX_ hv, Nullch, 0, 0); } SvFLAGS(hv) &= ~SVf_OOK; Safefree(HvARRAY(hv)); @@ -1871,7 +1872,8 @@ Perl_hv_name_set(pTHX_ HV *hv, const char *name, I32 len, int flags) { struct xpvhv_aux *iter; U32 hash; - (void)flags; + + PERL_UNUSED_ARG(flags); if (SvOOK(hv)) { iter = HvAUX(hv); @@ -1981,8 +1983,17 @@ Perl_hv_iternext_flags(pTHX_ HV *hv, I32 flags) return Null(HE*); } #ifdef DYNAMIC_ENV_FETCH /* set up %ENV for iteration */ - if (!entry && SvRMAGICAL((SV*)hv) && mg_find((SV*)hv, PERL_MAGIC_env)) + if (!entry && SvRMAGICAL((SV*)hv) && mg_find((SV*)hv, PERL_MAGIC_env)) { prime_env_iter(); +#ifdef VMS + /* The prime_env_iter() on VMS just loaded up new hash values + * so the iteration count needs to be reset back to the beginning + */ + hv_iterinit(hv); + iter = HvAUX(hv); + oldentry = entry = iter->xhv_eiter; /* HvEITER(hv) */ +#endif + } #endif /* hv_iterint now ensures this. */ @@ -2175,7 +2186,7 @@ S_unshare_hek_or_pvn(pTHX_ const HEK *hek, const char *str, I32 len, U32 hash) bool found = 0; bool is_utf8 = FALSE; int k_flags = 0; - const char *save = str; + const char * const save = str; struct shared_he *he = 0; if (hek) { @@ -2274,7 +2285,7 @@ Perl_share_hek(pTHX_ const char *str, I32 len, register U32 hash) { bool is_utf8 = FALSE; int flags = 0; - const char *save = str; + const char * const save = str; if (len < 0) { STRLEN tmplen = -len;