X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=hv.h;h=466f33d2bb51a178097fe21db0217b908c3aae49;hb=cc17ae0be05e2c55b051f093271e76a3ed64c54e;hp=5256eac8ed553cf715d1edb41ec28e8507e462e0;hpb=36477c247f3c188fb8cc7e276c87b739d3e6ab7c;p=p5sagit%2Fp5-mst-13.2.git diff --git a/hv.h b/hv.h index 5256eac..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,11 +110,11 @@ 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 OFFSETOF(HEK, hek_key[0]) +#define HEK_BASESIZE STRUCT_OFFSET(HEK, hek_key[0]) #define HEK_HASH(hek) (hek)->hek_hash #define HEK_LEN(hek) (hek)->hek_len #define HEK_KEY(hek) (hek)->hek_key