1 /* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)cur_hash.c 8.1 (Berkeley) 06/04/93"; 10 #endif /* not lint */ 11 12 #include <sys/types.h> 13 14 15 /* 16 * __hash() is "hashpjw" from the Dragon Book, Aho, Sethi & Ullman, p.436. 17 */ 18 u_int 19 __hash(s, len) 20 char *s; 21 int len; 22 { 23 register u_int h, g, i; 24 25 h = 0; 26 i = 0; 27 while (i < len) { 28 h = (h << 4) + s[i]; 29 if (g = h & 0xf0000000) { 30 h = h ^ (g >> 24); 31 h = h ^ g; 32 } 33 i++; 34 } 35 return h; 36 } 37