fixed an obscure bug in the hash function: sometimes the globstep variable

had a value equal to size! Also, sizes of tables must be prime
This commit is contained in:
ceriel 1987-11-11 15:05:41 +00:00
parent 603c65950c
commit f9281be252
4 changed files with 6 additions and 2 deletions

View file

@ -80,6 +80,7 @@ procedure getit; { start the ball rolling }
var cset:set of char;
f:ifset;
insno:byte;
iclass: insclass;
nops:integer;
opcode:byte;
i,j,n:integer;

View file

@ -211,10 +211,13 @@ int i_flag,flag,number ; cons_t val ; {
if ( val<0 ) val = -1-val ;
return val>=0 && val<number*256 ;
case OP16 :
/* Commented out for the time being. This must be in
ip_spec.t ...
if ( i_flag==PAR_G ) {
return val>=0 &&
val<=maxadr && val <= 65535L;
}
*/
return val>= -32768 && val<=32767 ;
case OP32 :
return TRUE ;

View file

@ -35,7 +35,7 @@ static int glohash(aname,size) char *aname; {
for(sum=i=0,p=aname;*p;i += 3)
sum += (*p++)<<(i&07);
sum &= 077777;
globstep = (sum / size) + 7;
globstep = (sum / size) % (size - 7) + 7;
return(sum % size);
}

View file

@ -132,6 +132,6 @@ size_t sizes[NDEFAULT] = {
{ 151, 29, 31, 73, 130 },
{ 307, 127, 151, 401, 460 },
{ 601, 251, 151, 401, 600 },
{2000, 2000, 2000, 2000, 2000 }
{1601, 1601, 1601, 1601, 2000 }
};
size_t *oursize = &sizes[1] ; /* point to selected sizes */