X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/71be2cbc73608e37e1a2ab7e459a02111137d1b0..d1b8022985c09823f9032ec74d6ce16d9391f57d:/hv.h?ds=sidebyside diff --git a/hv.h b/hv.h index 7c04cc2..466f33d 100644 --- a/hv.h +++ b/hv.h @@ -1,6 +1,6 @@ /* hv.h * - * Copyright (c) 1991-1994, Larry Wall + * Copyright (c) 1991-1997, Larry Wall * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -22,11 +22,12 @@ struct hek { char hek_key[1]; }; +/* This structure must match the beginning of struct xpvmg in sv.h. */ struct xpvhv { char * xhv_array; /* pointer to malloced string */ STRLEN xhv_fill; /* how full xhv_array currently is */ STRLEN xhv_max; /* subscript of last element of xhv_array */ - I32 xhv_keys; /* how many elements in the array */ + IV xhv_keys; /* how many elements in the array */ double xnv_nv; /* numeric value, if any */ MAGIC* xmg_magic; /* magic for scalar array */ HV* xmg_stash; /* class package */ @@ -44,7 +45,7 @@ struct xpvhv { register U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) \ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ - (hash) = hash_PeRlHaSh; \ + (hash) = hash_PeRlHaSh + (hash_PeRlHaSh>>5); \ } STMT_END @@ -95,9 +96,11 @@ struct xpvhv { #define HeKLEN(he) HEK_LEN(HeKEY_hek(he)) #define HeVAL(he) (he)->hent_val #define HeHASH(he) HEK_HASH(HeKEY_hek(he)) -#define HePV(he) ((HeKLEN(he) == HEf_SVKEY) ? \ - SvPV(HeKEY_sv(he),na) : \ - HeKEY(he)) +#define HePV(he,lp) ((HeKLEN(he) == HEf_SVKEY) ? \ + SvPV(HeKEY_sv(he),lp) : \ + (((lp = HeKLEN(he)) >= 0) ? \ + HeKEY(he) : Nullch)) + #define HeSVKEY(he) ((HeKEY(he) && \ HeKLEN(he) == HEf_SVKEY) ? \ HeKEY_sv(he) : Nullsv) @@ -107,8 +110,8 @@ struct xpvhv { HeKEY_sv(he) : \ sv_2mortal(newSVpv(HeKEY(he), \ HeKLEN(he)))) : \ - &sv_undef) -#define HeSVKEY_set(he,sv) (HeKEY_sv(he) = sv) + &PL_sv_undef) +#define HeSVKEY_set(he,sv) ((HeKLEN(he) = HEf_SVKEY), (HeKEY_sv(he) = sv)) #define Nullhek Null(HEK*) #define HEK_BASESIZE STRUCT_OFFSET(HEK, hek_key[0])