char" but old code using just a "char" doesn't need changes.
(The change is using a temporary pointer instead of a direct
cast to unsigned char* which would blindly cast anything,
not just char pointers.) (The problem arose in MacOS Classic,
as seen by Pudge, the cure by Nicholas Clark.)
p4raw-id: //depot/perl@16656
}
}
- PERL_HASH(hash, (U8*)key, klen);
+ PERL_HASH(hash, key, klen);
/* entry = (HvARRAY(hv))[hash & (I32) HvMAX(hv)]; */
entry = ((HE**)xhv->xhv_array)[hash & (I32) xhv->xhv_max];
}
if (!hash)
- PERL_HASH(hash, (U8*)key, klen);
+ PERL_HASH(hash, key, klen);
/* entry = (HvARRAY(hv))[hash & (I32) HvMAX(hv)]; */
entry = ((HE**)xhv->xhv_array)[hash & (I32) xhv->xhv_max];
HvHASKFLAGS_on((SV*)hv);
if (!hash)
- PERL_HASH(hash, (U8*)key, klen);
+ PERL_HASH(hash, key, klen);
if (!xhv->xhv_array /* !HvARRAY(hv) */)
Newz(505, xhv->xhv_array /* HvARRAY(hv) */,
}
if (!hash)
- PERL_HASH(hash, (U8*)key, klen);
+ PERL_HASH(hash, key, klen);
if (!xhv->xhv_array /* !HvARRAY(hv) */)
Newz(505, xhv->xhv_array /* HvARRAY(hv) */,
k_flags |= HVhek_FREEKEY;
}
- PERL_HASH(hash, (U8*)key, klen);
+ PERL_HASH(hash, key, klen);
/* oentry = &(HvARRAY(hv))[hash & (I32) HvMAX(hv)]; */
oentry = &((HE**)xhv->xhv_array)[hash & (I32) xhv->xhv_max];
}
if (!hash)
- PERL_HASH(hash, (U8*)key, klen);
+ PERL_HASH(hash, key, klen);
/* oentry = &(HvARRAY(hv))[hash & (I32) HvMAX(hv)]; */
oentry = &((HE**)xhv->xhv_array)[hash & (I32) xhv->xhv_max];
k_flags |= HVhek_FREEKEY;
}
- PERL_HASH(hash, (U8*)key, klen);
+ PERL_HASH(hash, key, klen);
#ifdef DYNAMIC_ENV_FETCH
if (!xhv->xhv_array /* !HvARRAY(hv) */) entry = Null(HE*);
k_flags |= HVhek_FREEKEY;
}
if (!hash)
- PERL_HASH(hash, (U8*)key, klen);
+ PERL_HASH(hash, key, klen);
#ifdef DYNAMIC_ENV_FETCH
if (!xhv->xhv_array /* !HvARRAY(hv) */) entry = Null(HE*);
};
/* hash a key */
-/* FYI: This is the "One-at-a-Time" algorithm by Bob Jenkins */
-/* from requirements by Colin Plumb. */
-/* (http://burtleburtle.net/bob/hash/doobs.html) */
+/* FYI: This is the "One-at-a-Time" algorithm by Bob Jenkins
+ * from requirements by Colin Plumb.
+ * (http://burtleburtle.net/bob/hash/doobs.html) */
+/* The use of a temporary pointer and the casting games
+ * is needed to serve the dual purposes of
+ * (a) the hashed data being interpreted as "unsigned char" (new since 5.8,
+ * a "char" can be either signed or signed, depending on the compiler)
+ * (b) catering for old code that uses a "char"
+ */
#define PERL_HASH(hash,str,len) \
STMT_START { \
- register const unsigned char *s_PeRlHaSh = str; \
+ register const char *s_PeRlHaSh_tmp = str; \
+ register const unsigned char *s_PeRlHaSh = (const unsigned char *)s_PeRlHaSh_tmp; \
register I32 i_PeRlHaSh = len; \
register U32 hash_PeRlHaSh = 0; \
while (i_PeRlHaSh--) { \
meth = newSVpvn("import", 6);
(void)SvUPGRADE(meth, SVt_PVIV);
(void)SvIOK_on(meth);
- PERL_HASH(SvUVX(meth), (U8*)SvPVX(meth), SvCUR(meth));
+ PERL_HASH(SvUVX(meth), SvPVX(meth), SvCUR(meth));
imop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL|OPf_WANT_VOID,
append_elem(OP_LIST,
prepend_elem(OP_LIST, pack, list(arg)),
meth = newSVpvn("VERSION",7);
sv_upgrade(meth, SVt_PVIV);
(void)SvIOK_on(meth);
- PERL_HASH(SvUVX(meth), (U8*)SvPVX(meth), SvCUR(meth));
+ PERL_HASH(SvUVX(meth), SvPVX(meth), SvCUR(meth));
veop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
append_elem(OP_LIST,
prepend_elem(OP_LIST, pack, list(version)),
meth = aver ? newSVpvn("import",6) : newSVpvn("unimport", 8);;
(void)SvUPGRADE(meth, SVt_PVIV);
(void)SvIOK_on(meth);
- PERL_HASH(SvUVX(meth), (U8*)SvPVX(meth), SvCUR(meth));
+ PERL_HASH(SvUVX(meth), SvPVX(meth), SvCUR(meth));
imop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
append_elem(OP_LIST,
prepend_elem(OP_LIST, pack, list(arg)),
len = tmplen;
}
if (!hash)
- PERL_HASH(hash, (U8*)src, len);
+ PERL_HASH(hash, src, len);
new_SV(sv);
sv_upgrade(sv, SVt_PVIV);
SvPVX(sv) = sharepvn(src, is_utf8?-len:len, hash);
Perl_warner(aTHX_ packWARN(WARN_INTERNAL),"Ill-formed message in prime_env_iter: |%s|",buf);
continue;
}
- PERL_HASH(hash,(U8*)key,keylen);
+ PERL_HASH(hash,key,keylen);
sv = newSVpvn(cp2,cp1 - cp2 + 1);
SvTAINTED_on(sv);
hv_store(envhv,key,keylen,sv,hash);